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.

brian d foy
  • 129,424
  • 31
  • 207
  • 592
KTLind
  • 147
  • 1
  • 2
  • 5

3 Answers3

4

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.

brian d foy
  • 129,424
  • 31
  • 207
  • 592
ConcernedOfTunbridgeWells
  • 64,444
  • 15
  • 143
  • 197
0

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.

brian d foy
  • 129,424
  • 31
  • 207
  • 592
Mark Bessey
  • 19,598
  • 4
  • 47
  • 69
0

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
  • 334,560
  • 70
  • 407
  • 495
  • 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 Dec 23 '09 at 11:00
  • @CharlesStewart `copypage` was present in Level-1 interpreters and the PLRM 1ed. – luser droog Feb 02 '13 at 11:30