Name
Write( ) — return the PostScript code for a block
Synopsis
$tb->Write( $width, $height, $xoffset, $yoffset
)
The Write( )
method will generate the PostScript code that
will render the text on a page when passed to a PostScript
interpreter such as Ghostscript. The four parameters are expressed in
points and indicate the width and height of the box within which the
text should be printed, and the x and y offset of the upper left
corner of this box.
Tip
Unlike all of the other tools described in this book which define the origin (0, 0) as the upper left-hand corner of the image, PostScript uses a Cartesian coordinate system. That is, the origin is at the lower left corner of the page.
Standard page sizes in points are listed earlier in Table 11.1.
The Write( )
method returns two values: a string
consisting of the PostScript code (suitable for printing to a file),
and a TextBlock object containing the elements (and partial elements)
that did not fit within the specified area, if any. If the entire
text block fits with the area, the remainder will be
undef
. The remainder can be used to lay out
multiple pages and columns in a similar manner to most modern desktop
publishing programs. In general, the Write( )
method should be called as in the following example, which
writes the PostScript code to a file called
psoutput.ps
:
#!/usr/bin/perl -w use PostScript::TextBlock; my $tb = PostScript::TextBlock->new; $tb->addText( text => "The next sentence is false. "); $tb->addText( text => "The previous ...
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.