问题
I need to reformat a text file into a PDF. Using Perl, I am modifying an existing PostScript template file based on what is in the text file. Sometimes this text file will be long enough to require a two page PDF.
Can I create a two page PDF file from one .ps file using GhostScript? If so, what tells GhostScript where the page break should occur?
Maybe I need to use two template files. One for a one page pdf and another for a two page PDF.
回答1:
PostScript doesn't directly have the concept of text flows or page breaks. The showpage operator renders the page to the device, clears the page and starts a new one. PS to PDF conversion will create a new page in the PDF on this operator. If you want to chop up a PostScript file into pages, psutils is a series of programs for manipulating PostScript files.
回答2:
It's down to whatever is converting your text file to create appropriate PostScript commands to handle the page break.
A page break will happen if (and only if) your PostScript template invokes showpage
.
回答3:
I would guess it depends on what's in your PostScript template. A PostScript file is a computer program, and page breaks are determined by the logic in the PostScript. If the two-page format is substantially the same as the one-page format, you could have your Perl script split the data up, then create two single-page files concatenated together. GhostScript should render that file correctly.
来源:https://stackoverflow.com/questions/310441/create-two-pdfs-from-one-ps-file