sumatrapdf icon indicating copy to clipboard operation
sumatrapdf copied to clipboard

When I used the cmd command to connect the virtual printer for printing, the page number set in the command line was always inconsistent with the expected print page.

Open zetor2018 opened this issue 2 months ago • 3 comments

SumatraPDF version

  • Version [e.g. 3.6.0, prerel-64]

Describe the bug When I used the cmd command to connect the virtual printer for printing, the page number set in the command line was always inconsistent with the expected print page.

To Reproduce The printer I use is HP LaserJet Pro 4004, The connection mode is network printing.

  1. When printing with the following command: SumatraPDF.exe -print-to "HPC960D4 (HP LaserJet Pro 4004)" -print-settings "1,1,A4,P" -silent page87.pdf Will print out two first pages
  2. When printing with the following command: SumatraPDF.exe -print-to "HPC960D4 (HP LaserJet Pro 4004)" -print-settings "2,1,A4,P" -silent output.pdf The first and second pages can be printed
  3. When printing with the following command: SumatraPDF.exe -print-to "HPC960D4 (HP LaserJet Pro 4004)" -print-settings "1-,1,A4,P" -silent output.pdf Only the first page is output.

Expected behavior Reproduce 1, I think it will only output the first page. Reproduce 2, I think it will only output the second page. Reproduce 3, I think it will output all pages.

Additional context I didn't understand the output rule of this page number, which is quite different from the output standard of normal printing page numbers. Is this a bug in the program? If I want to print all the pages without knowing the number of pdf pages, how should I write this pdf command?

zetor2018 avatar Oct 28 '25 05:10 zetor2018

The first command should be -print-to "HPC960D4 (HP LaserJet Pro 4004)" -print-settings "1" page87.pdf to print just page 1 on an A4 portrait printer unless the defaults are different so your second command should be 2 sheets as you used 2 positive numbers
and if you want all pages in the 3rd command try -print-settings "1000-1" PrintReverse.pdf

GitHubRulesOK avatar Oct 28 '25 13:10 GitHubRulesOK

The first command should be -print-to "HPC960D4 (HP LaserJet Pro 4004)" -print-settings "1" page87.pdf to print just page 1 on an A4 portrait printer unless the defaults are different so your second command should be 2 sheets as you used 2 positive numbers and if you want all pages in the 3rd command try -print-settings "1000-1" PrintReverse.pdf

Thank you for your answer. But the other params (1,A4,P) are also very import for me. The page Size and direct are equivocal in my project. Since this is the official command, why is it inconsistent with the expected printing results?

zetor2018 avatar Oct 29 '25 05:10 zetor2018

The commands are in effect over-rides to printers own default settings to print all pages from 1- end at WinPrint2 Defaults so if the printer has A4 paper there is no need to set a different paperkind and rotation is an odd beast which does not always mean what you consider it should so most printers use portrait by default. You need to check what is functional at the time as set by windows.

The only setting that may have a real effect in settings is shrink fit and none (preferred) and this can be reinforced on command line via noscale, shrink and fit

PrinterDefaults [
    default value for scaling (shrink, fit, none)
    PrintScale = shrink
]

the same as for GhostScript, in WinPrint the default is auto rotate which might be overridden by "portrait" or "landscape" wording in the command

portrait or landscape : can provide 90 degree rotation of contents (NOT the rotation of paper which must be pre-set by the choice of printer defaults)

one command not shown is paperkind (printer media size abilities for extended sizes) but has common defaults by use "paper=A4"

GitHubRulesOK avatar Oct 29 '25 10:10 GitHubRulesOK