Forum moved here!

Home / Printing to PDF entirely via the command line

xiaogou

Hi all,

is there a way to pint a pdf to pdf entirely in command line?

some commands i’ve tried are:

SumatraPDF.exe -exit-on-print -print-settings bin='test.pdf' -print-to "Microsoft Print to PDF" in.pdf
SumatraPDF.exe -exit-on-print -named-dest test.pdf -print-to "Microsoft Print to PDF" in.pdf

but i think i might have understood the documentation wrongly.

my ultimate goal is to use sumatra in linux using wine. thus am looking to run the entire program in terminal.

SumatraPeter

Not sure why you’re testing with the Windows-specific Microsoft Print to PDF printer driver when your goal is to run the program under Wine? Even if you get it to work under Windows, how would that possibly help you when you run Sumatra under Wine? :confused:

My advice would be to actually do your testing under Wine itself, with a Linux pdf printer driver such as cups-pdf. Also, if you get it to work then do let us know!

GitHubRulesOK

I am even more intrigued why you would even atempt to use SumatraPDF to convert to an image only PDF? There are many cross platform cli apps that can do that way way much better or could give more control over output (dont know linux, but consider many similar stackexchange etc. questions are answered using for example ghostscript and or image magic)

GitHubRulesOK

I see we did not answer your question, (poor show)

Both commands are not good but work perfectly well by default, that is I can get a test.pdf from both of them.

so ignoring the errors they both are equivalent and behave the same as a much simpler
SumatraPDF.exe -print-to "Microsoft Print to PDF" in.pdf
and usually you supply each output filename manually.

To direct the output of MS PDF driver to an ImageOnly.PDF is similar to the way other print redirectors work and fiddly, so as SumatraPeter suggested use a dedicated distiller.

The first example sets bins that dont exist so those entries would be ignored

The second example should have borked because a -named-dest is a bookmark internally in said file thus should have complained at not finding a bookmark called “test.pdf” inside in.pdf