ps2pdf: preserve page size

前端 未结 4 1245
-上瘾入骨i
-上瘾入骨i 2021-02-13 22:34

I have myfile.ps with a vector image included. But when I run

ps2pdf myfile.ps

it seems that the output page size is A4: the vecto

4条回答
  •  野的像风
    2021-02-13 22:52

    I doubt your quoted 2 lines are really inside the PS file as quoted... Aren't they preceeded by % comment characters?

    • If they weren't preceeded by such characters, no PS interpreter would work, because they are no known PostScript operators.

    • If they are preceeded by such characters, the PS interpreter would simply ignore them, because... they are comments only! :-)

    If you want to convert this PS file to PDF, it is better to run Ghostscript directly (ps2pdf is only a thin shell script wrapper around a Ghostscript command anyway):

    gs -o myfile.pdf     \
       -sDEVICE=pdfwrite \
       -g5775x6207       \
       -dPDFFitPage      \
        myfile.ps
    

    Explanation:

    1. -g... gives the medium size in pixels.
    2. An A4 page has a dimension of 595x842pt (PostScript points).
    3. 1 Inch is the same as 72 PostScript points.
    4. Ghostscript internally by default computes with a resolution of 720 pixels per inch when it comes to PDF output.
    5. Hence for PDF output 595x842pt == 5950x8420px.
    6. Hence for your case in question 8.02x8.62Inches ≈≈ 5775x6207px.

提交回复
热议问题