no commands found in cpdf - pdf

I'm trying to use cpdf to edit a pdf document. Specifically, I'm trying to rescale the page size by using the command
cpdf -scale-page "2 2" in.pdf -o out.pdf
found in the documentation (https://www.coherentpdf.com/cpdfmanual.pdf)
However, this gives me the error No such command 'scale-page', and indeed when running cpdf--help, the scale-page command isn't present. What is going on here?
I'm using anaconda prompt if that matters.

Works fine here:
./cpdf -scale-page "2 2" cpdfmanual.pdf -o out.pdf
"No such command" isn't a cpdf error. If you give an unknown command to cpdf you get:
$ cpdf -foo
cpdf: unknown option '-foo'. Use -help for help.
So it looks like whatever environment you're using isn't quoting this command properly, and cpdf is never being invoked.
Try it at a plain command line first. I am unfamiliar with Anaconda Prompt I'm afraid, but I suspect the answer lies there.

Related

RISC-V: How to fix "file format not recognized" when disassembling a .img file?

I'm playing with RISC-V.
I have a .img file and I want to disassemble it into a .asm file, so I ran the following command:
> riscv64-unknown-elf-objdump -d xxx.img > xxx.asm
However, I got this issue:
riscv64-unknown-elf-objdump: xxx.img: file format not recognized
How can I fix it? I have no idea what to do with this issue.
If you run:
riscv64-unknown-elf-objdump --help
You'll see a line like:
riscv64-unknown-elf-objdump: supported architectures: riscv riscv:rv64 riscv:rv32
These are the supported architectures that you need to pass as the -m argument. Normally, an ELF file will encode this information so there's no guesswork, but in the case of using a flat file, there's no way for objdump to know how the instructions are supposed to be interpreted. The final command is:
riscv64-unknown-elf-objdump -b binary -m riscv:rv64 -D xxx.bin

When adding a -c option to a Ghostscript command the printer popup appears even though it has been suppressed

Consider the following ghostscript command invoked form the command line on windows.
"C:\Program Files\gs\gs9.23\bin\gswin64c.exe" -sDEVICE=mswinpr2 -dORIENT1=false -dNOPROMPT -dNOPAUSE -dPrinted -dBATCH -dNOPAUSE -dNOSAFER -q -dFIXEDMEDIA -dDEVICEWIDTHPOINTS=398 -dDEVICEHEIGHTPOINTS=157 -dNOPAGEPROMPT -dQUIET -dNumCopies=1 -sOutputFile="\\spool\BWLAB05" "c:\print\download\133679.pdf"
This command works great. The print comes out and there is no pop up box. Now I add the following.
-c "<</Orientation 2>>setpagedevice"
to the above command to make
"C:\Program Files\gs\gs9.23\bin\gswin64c.exe" -sDEVICE=mswinpr2 -c "<</Orientation 2>>setpagedevice" -c "quit" -dORIENT1=false -dNOPROMPT -dPrinted -dBATCH -dNOPAUSE -dNOSAFER -q -dFIXEDMEDIA -dDEVICEWIDTHPOINTS=398 -dDEVICEHEIGHTPOINTS=157 -dNumCopies=1 -sOutputFile="\\spool\BWLAB05" "c:\print\download\133679.pdf"
the print window appears. I have changed no other part of the command. What is causing this to happen? How can I stop the print window appearing?
The order of operands to Ghostscript is important. Especially when using the -c switch, which introduces PostScript to be executed.
Effectively you are running two commands here:
-sDEVICE=mswinpr2 -c "<</Orientation 2>>setpagedevice" -c "quit"
-dORIENT1=false -dNOPROMPT -dPrinted -dBATCH -dNOPAUSE -dNOSAFER -q -dFIXEDMEDIA -dDEVICEWIDTHPOINTS=398 -dDEVICEHEIGHTPOINTS=157 -dNumCopies=1 -sOutputFile="\\spool\BWLAB05" "c:\print\download\133679.pdf"
As soon as it hits the -c Ghostscript stops processing the command line, and runs the PostScript. At this point we have not yet encountered the -dNOPROMPT, and as you haven't (yet) set the printer, Ghostscript doesn't know what printer to use so , unsurprisingly, the printer popup appears.
Ghostscript carries on processing the remainder of the command line as PostScript until it reaches a -f, or in fact any switch beginning -. You haven't put a -f in there, but I would very strongly recommend that you do. You also don't need to put a secopnd -c, once you've started processing the command line as PostScript it continues, until you stop it. I also suspect that you really don't want the quit in there. That terminates the interpreter, which means the changes you've introduced via setpagedevice will be discarded, because the interpreter returns to the default state.
After processing the content of the -c, Ghostscript carries on and processes the remainder of the command line. This time there's a -dNOPROMPT so you don't get prompted.
I would expect that this:
"C:\Program Files\gs\gs9.23\bin\gswin64c.exe" -sDEVICE=mswinpr2 -dORIENT1=false -dNOPROMPT -dPrinted -dBATCH -dNOSAFER -q -dFIXEDMEDIA -dDEVICEWIDTHPOINTS=398 -dDEVICEHEIGHTPOINTS=157 -dNumCopies=1 -sOutputFile="\\spool\BWLAB05" -c "<</Orientation 2>>setpagedevice" -f "c:\print\download\133679.pdf"
would work much better. Note your initial command line has a duplicate NOPAUSE and specifies both NOPROMPT and NOPAGEPROMPT (you don't need NOPAGEPROMPT if you set NOPROMPT, and you don't need either if you set NOPAUSE).
Finally I would urge you not to use -dNOSAFER, while it currently has no effect (because that's the default setting) we will soon be making SAFER the default and setting -dNOSAFER will substantially reduce your security when running files.
You should really use -dSAFER right now. There are a number of CVEs against this, and proof of concepts circulating right now which can have undesirable effects on your computer (running arbitrary executables, opening, writing, deleting files etc) if you don't use -dSAFER. If you don't know why you want -dNOSAFER, then use -dSAFER instead.
Oh, you should also upgrade to the current version, 9.27, the version you are using is a year old.

no output file generated when using Ghostscript to convert PDF to TIFF

Here is the command I use:
gs -r300 -q -dNOPAUSE -sDevice=tiffgray -sOutputFile=sample1.tiff sample1.pdf -c quit
I don't see sample1.tiff in my current working directory. I'm running OS Mavericks.
Try running without -q so that the messages aren't suppressed, Ghostscript is probably trying to tell you what's wrong.

Ghostscript loses font while extracting the page from PDF

I split PDF into pages with help of usable command line:
for G in $(seq 1 $(pdfinfo 47.pdf | sed -n 's/Pages:[^0-9]*\([0-9]*\).*/\1/p')) ; do
gs \
-dSAFER \
-sDEVICE=pdfwrite \
-dBATCH \
-dNOPAUSE \
-dFirstPage=$G \
-dLastPage=$G \
-o $G.pdf \
47.pdf ;
done
But some pages appears without text (Graphics are still present)
So, I have tried to extract embedded font from PDF:
gs -q -dNODISPLAY extractFonts.ps -c "(47.pdf) extractFonts quit"
These fonts I have installed in system Fonts folder.
After that, I have repeat splitting and no changes were happened.
How-to be sure that pages will be extracting correctly, I have no idea now.
Ghostscript and pdfwrite are not actually intended for the purpose of splitting PDF files up, there are other tools which will probably work better, why not try pdftk ?
If you really want to use Ghostscript then I would advise you to get hold of the latest bleeding-edge code from the Git repository, in that code the pdfwrite device will accept an output file name containing a '%d' and will write one file per page.
Beyond that, it seems most likely to me that you are simply experiencing a bug, rather than 'losing the font', if the font was missing the text would still be ther but in a differnt font. Which version of GS are you using ?

How do I figure out what -O<num> options do in gcc?

I seem to remember being able to print out (or locate) the specific switches that each -O<num> option turns on. Can you remind?
Thanks!
The list of new features on gcc 4.3 shows a way to do it, via an extension to the --help command line option:
gcc -c -Q -O3 --help=optimizers > /tmp/O3-opts
gcc -c -Q -O2 --help=optimizers > /tmp/O2-opts
diff /tmp/O2-opts /tmp/O3-opts | grep enabled
Note, however that I never tried that, only read about it. The documentation about this command line option is at http://gcc.gnu.org/onlinedocs/gcc/Overall-Options.html#Overall-Options
If you ever read the list of new features on gcc 4.3, perhaps this was what you were recalling.
You may also try the good ol' manual
$ man gcc
at the subsection "Options That Control Optimization".
On many machines, 'info gcc' will produce a wealth of information. Using 'gcc -v --help' produced a very long listing of options from sub-processes (actually, 1001 lines on stdout, and 14 on stderr) on my Mac (PPC G4 and MacOS X 10.4.11).