tags:

views:

825

answers:

3

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.

A: 

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.

Mark Bessey
A: 

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.

Alnitak
This is true only for ps level 1; level 2 introduced (and level 3 deprecated) the copypage operator, which is like showpage, except it keeps the same page contents, which can then be added to. Cf. http://www.adobe.com/devnet/postscript/pdfs/TN5608.Copypage.pdf
Charles Stewart
+2  A: 

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.

ConcernedOfTunbridgeWells
showpage was what I was looking for. Thanks.
KTLind