Printing multiple pdf files from command line


#1

Hi, I love this tool. Discovered it when having trouble with other pdfprinter options. My problem is that the -print-to description says that it prints all files on the command line. I put one file following the -print-to and it works as expected. If I put more than one following the -print-to, I get the first one as expected but then the command window closes.

My code, I think, is rather straight forward:
"%ProgramFiles%\SumatraPDF\SumatraPDF.exe" -print-to “Foxit PhantomPDF Printer”
“M:\CNHB_DigitizedScores-20161130\A Charlie Brown Christmas\A Charlie Brown Christmas~trmb1.pdf”
“M:\CNHB_DigitizedScores-20161130\A Charlie Brown Christmas\A Charlie Brown Christmas~trmpt1.pdf”
“M:\CNHB_DigitizedScores-20161130\A Charlie Brown Christmas\A Charlie Brown Christmas~clrnt1.pdf”
“M:\CNHB_DigitizedScores-20161130\A Charlie Brown Christmas\A Charlie Brown Christmas~flte1.pdf”

As mentioned, the above works in the sense that I do get a dialog box open for “M:\CNHB_DigitizedScores-20161130\A Charlie Brown Christmas\A Charlie Brown Christmas~trmb1.pdf” … but every file after that is ignored and the command window closes.

Any hints as what I am doing wrong? All help appreciated.

Frank Mc


#2

That’s just how it works.

Sumatra was never meant to be used primarily as a printer from command line so it’s not designed for that. -print-to only handles a single file.

As a work-around, you can launch program multiple times.


#3

Well, thanks for response … but I just discoverd it does work like this:
"%ProgramFiles%\SumatraPDF\SumatraPDF.exe" -print-to “Foxit PhantomPDF Printer” “M:\CNHB_DigitizedScores-20161130\A Charlie Brown Christmas\A Charlie Brown Christmas~trmb1.pdf” “M:\CNHB_DigitizedScores-20161130\A Charlie Brown Christmas\A Charlie Brown Christmas~trmpt1.pdf” “M:\CNHB_DigitizedScores-20161130\A Charlie Brown Christmas\A Charlie Brown Christmas~clrnt1.pdf” “M:\CNHB_DigitizedScores-20161130\A Charlie Brown Christmas\A Charlie Brown Christmas~flte1.pdf”

In my previous example I had a return after each of the file names so it was not seeing those following the first one as part of the file list.

The above works perfectly well, which BTW, is how Sumatra’s instructions show it with this from their manual: “-print-to :Prints all files indicated on this command line to the named printer. After printing, SumatraPDF exits immediately (check the error code for failure). E.g. -print-to “Microsoft XPS Document Writer” prints all indicated files to the XPS virtual printer.”

Thanks for getting back to me, but I had just discovered the answer about five minutes before.

Frank


#4

My bad. Sorry for misleading comment. I’ve mis-read the code for parsing cmd-line args.


#5

No worries. Been there, done that and have the proverbial t-shirt.