Multipage Documents with PostScript::Document
The PostScript::Document module comes with the PostScript package. It creates an abstract interface for creating generic multiple page textual documents. You can think of a Document object as a big text block with additional attributes and methods that allow it to span multiple pages. You can also include page numbers, and textual headers and footers that appear on each page of the document.
The Document object is used in a similar manner to the TextBlock object to do the following:
Instantiate a new document with the
new( )
method and a number of optional parameters defining the attributes of the page.Add text elements to the document with the
addText( )
method.Create the PostScript as a string of code with the
Write( )
method.Write the code to a file, and pipe or append it to other code.
A sample script using this module that reads a text file and appends a title, header, and footer to it would look something like this:
#!/usr/bin/perl -w use strict; use PostScript::Document; my $doc = new PostScript::Document; $doc->addText( text => "Hullabalo in Hoosick Falls.\n", font => 'CenturySchL-Ital', size => 24, leading => 100 ); $doc->addText( text => "by Charba Gaspee.\n", font => 'URWGothicL-Demi', size => 18, leading => 36 ); $doc->addHeader(text => "Hullabaloo in Hoosick Falls", font => 'URWGothicL-Demi', size => 9, leading => 11 ); $doc->addFooter(text => "Page ##Page", font => 'URWGothicL-Demi', size => 9, leading => 11 ); # Now read ...
Get Programming Web Graphics with Perl and GNU Softwar now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.