How to change Ghostscript output file (in printer spooler)

后端 未结 4 812
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-12-11 08:45

I am using Ghostscript to print a PDF by command line arguments. But it shows the printed document\'s name as Ghostscript output in printer spooler. I want to change it to a

4条回答
  •  温柔的废话
    2020-12-11 09:28

    This provides a partial solution to the issue, which is perhaps acceptable for your needs.

    The options to control the output size are (markdown inserts spaces, but there should be none):

    1. -dDEVICEWIDTHPOINTS=w, -dDEVICEHEIGHTPOINTS=h (w,h=595,842 / 612,792 for A4 / letter, respectively), Ref.

    2. -sPAPERSIZE=size, Ref.

    3. -gnumber1xnumber2 (number1,number2=5953,8419 / 6120,7920 for A4 / letter, respectively), Ref.

    4. -dDEVICEWIDTH=number1, -dDEVICEHEIGHT=number2 (number1,number2=5953,8419 / 6120,7920 for A4 / letter, respectively), Ref.

    I have tested the four of them, printing a pdf file to pdf, trying to convert (letter -> A4) and (A4 -> letter). The command line I used is

    gswin32c -dPDF -dBATCH -dNOPAUSE -dFIXEDMEDIA  -sDEVICE=pdfwrite -sOutputFile=output.pdf input.pdf
    

    A4 -> letter always worked well.
    letter -> A4 only worked for the width, so output.pdf was always 210mm x 279.4mm.

    Using, e.g., -dDEVICEWIDTHPOINTS alone for letter -> A4 produced the same result.

    Adding flag -dPDFFitPage was also useful for partially adapting size (in cases I want to do that).

    My conclusion is that there is some bug in Ghostscript specifically related to letter -> A4 conversion. Whether this could be handled via gs_setpd.ps (e.g., this; this would still be a bug), or a crafty combination of (-dUseBleedBox, -dUseTrimBox, -dUseArtBox, -dUseCropBox) I don't know.

提交回复
热议问题