Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
857 views
in Technique[技术] by (71.8m points)

pdf - How to set custom page size with Ghostscript

I have scanned some materials at 600 dpi, ~ 9.36x12.67 inches and prepared in PostScript (PS) format.

Now when I try to transform PS to PDF with Ghostscript (GS), I get clipped output, as I assume GS's default page size is set to A4. I found available templates for GS here: http://www.ghostscript.com/doc/9.06/Use.htm#Known_paper_sizes but none matches closely to dimensions of my PS files, so:

Can I instruct GS to output custom size, and if so how?

-sPAPERSIZE instruction seem to accept only predefined templates name, as in linked documentation.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

You can set the used page size with -gNNNNxMMMM where NNMN is the width in pixels at 720 dpi (720 pixels == 1 inch), and MMMM is the height in pixels at 720 dpi.

Or you can set the custom size in PostScript points (72 points == 1 inch) with -dDEVICEWIDTHPOINTS=w -dDEVICEHEIGHTPOINTS=h.

If I'm not wrong, 9.36 inch ≈= 674 points and 12.67 inch ≈= 912 points.

You'll also have to apply -dPDFFitPage in order to fit your input onto the page.

So you could use either

gs                          
   -o output.pdf            
   -sDEVICE=pdfwrite        
   -dDEVICEWIDTHPOINTS=674  
   -dDEVICEHEIGHTPOINTS=912 
   -dPDFFitPage             
    input.ps

or

gs                   
   -o output.pdf     
   -sDEVICE=pdfwrite 
   -r600             
   -g8112x7596       
   -dPDFFitPage      
    input.ps

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

1.4m articles

1.4m replys

5 comments

57.0k users

...