Pdf.pm -- A POD to PDF translator
Also from the shell prompt in conjunction with the script "pod2pdf" (see "scripts/pod2pdf"):
$ pod2pdf [options] <file>
pod2pdf translates single
POD (Perl Plain Old Documentation) files and translates them to
POD files into a single book. At this stage the emphasis is on simplicity and ease of use. The output
PDF Outlines are created at three levels corresponding to
outline headings are reproduced as a
Table of Contents page. Long
=item strings are curtailed to a length which will fit reasonably in the space available on the page. When the
outlines (sometimes known as
Bookmarks) provide links to the appropriate page. When the document is printed the
ToC provides the same facility.
Links of the form xyz.pm and links to named destinations are not implemented since it is rarely possible to resolve the link except in the limited instance of links to named destinations in the document itself. Links to
URL addresses (including http, ftp and mailto) are active however and call the resident default browser. How that responds to the call will depend to some extent on the type of browser and the environment in which it finds itself.
perlpod.pod allows blocks of text to be enclosed by
=end markers. The block-type my be indicated by a string after
=begin (for example
=begin html would indicate an
HTML block) of which roff, man, latex, tex and html are recognised entities. Specification
perlpod.pod goes on to say that "A formatter that can utilize that format will use the section, otherwise it will be completely ignored." This seems to defeat the object of the documentation since quite different output might be expected according to which translator was used. It is doubtful if that would necessarily be the author's intention.
Pdf.pm, in all cases reproduces the section enclosed by a
=begin/=end pair (or any paragraph following
=for which is similarly defined in
perlpod.pod) but in a special color so as to give a visual warning to the reader that special meaning might attach to the block of text.
The primary objective is to produce a translation of a
POD file of good typographical quality which can be printed on any printer (particularly low-cost non-PostScript ink-jet printers) in any environment. In this connection it must be recognised that some authors use
POD mark-up more intelligently and to better effect than others. Not infrequently mistakes in formatting (frequently the absence of a blank line to end a block) result in files which do not translate properly on some or all translators.
In the interests of simplicity and ease of use the number of options has been kept to a minimum. However an option to set paper size remains an unavoidable necessity untill such time as the world can agree on one standard. Only A4 and USLetter are preprogrammed, other custom sizes will require an edit to the
Options are implemented using
Getopt::Long using the syntax
--[key]= as indicated below. The order in which options are entered is immaterial.
The default paper size is A4 (which may be re-editied to a custom size):
my $x_size = 595; # default page width (pixels) my $y_size = 842; # default page height (pixels)
sets the North American standard size:
my $x_size = 612; # US letter page width (pixels) my $y_size = 792; # US letter page height (pixels)
The program will accept any (reasonable) paper size.
Limited error reporting to STDERR may be turned on by setting
--verbose=1 # progress reports --verbose=2 # more extensive progress reports about links
The input file name may be entered in various ways on most sytems. It may be included as an option, or as a string argument to
pod2pdf, or as an item in
@ARGV or finally, as a command line entry on systems which support command lines. As an
option the syntax is:
The output is always "duplex" in the sense that the pages are "handed" with the page number (for example) at the bottom right (on odd pages) and the bottom left (on even pages). However not everyone possesses a duplex printer capable of automatically printing on both sides of the paper, but fortunately most if not all printers are capable of printing all the odd sides in one pass and all the even pages (on the reverse side of the paper) in a second pass, which achieves the same result. Even if that is either not possible or not worth the effort, and the whole document is printed single sided, the handing of the pages is no great drawback. There is really no compelling need for the complication of a switch to select simplex or duplex mode.
Since the program is restricted to processing single
POD files the input file name can be used as the output file name distinguished simply by adding the extension
use Pod::Pdf; push @ARGV, qw(--paper usletter --verbose 1); # alternatively "push @ARGV, qw(-paper usletter -verbose 1)" # but NB "push @ARGV, '--verbose 2'" will NOT work push @ARGV, 'podfilename'; pod2pdf(@ARGV);
use Pod::Pdf; pod2pdf( '--paper=usletter', 'podfilename' );
use Pod::Pdf; pod2pdf( '--paper=usletter', '--verbose=2', '--podfile=podfilename' );
use Pod::Pdf; unshift @ARGV, '--paper=usletter'; pod2pdf(@ARGV);
Alan J. Fry
This version supports active URI links and features improved formatting.
For many helpful suggestions sincere thanks (in alphabetical order) to:
Stas Bekman <email@example.com>
Rob Carraretto <firstname.lastname@example.org>
M. Christian Hanson <email@example.com>
Marcus Harnisch <firstname.lastname@example.org>
Johannes la Poutr <email@example.com>
Henrik Tougaard <firstname.lastname@example.org>
This version has essentially the same functionality as version 1.1 but is reshaped into modular format. In reshaping the module grateful thanks are due to Axel Rose http://www.roeslein.de/axel/ whose suggestion to place the opening statements of the program into the subroutine
pod2pdf has been adopted together with his proposals for exporting the function name. This arrangement brings
Pdf.pm more into line with the structure of other POD translators. His assistance in testing the module on a variety of platforms (MacOS, Linux and Windows) has been invaluable as has his advice on the structure of the interface and many fine details too numerous to mention individually.