.\" Automatically generated by Pod::Man 2.25 (Pod::Simple 3.16) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .ie \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . nr % 0 . rr F .\} .el \{\ . de IX .. .\} .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "PDF::API2 3pm" .TH PDF::API2 3pm "2011-03-10" "perl v5.14.2" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" PDF::API2 \- Facilitates the creation and modification of PDF files .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& use PDF::API2; \& \& # Create a blank PDF file \& $pdf = PDF::API2\->new(); \& \& # Open an existing PDF file \& $pdf = PDF::API2\->open(\*(Aqsome.pdf\*(Aq); \& \& # Add a blank page \& $page = $pdf\->page(); \& \& # Retrieve an existing page \& $page = $pdf\->openpage($page_number); \& \& # Set the page size \& $page\->mediabox(\*(AqLetter\*(Aq); \& \& # Add a built\-in font to the PDF \& $font = $pdf\->corefont(\*(AqHelvetica\-Bold\*(Aq); \& \& # Add an external TTF font to the PDF \& $font = $pdf\->ttfont(\*(Aq/path/to/font.ttf\*(Aq); \& \& # Add some text to the page \& $text = $page\->text(); \& $text\->font($font, 20); \& $text\->translate(200, 700); \& $text\->text(\*(AqHello World!\*(Aq); \& \& # Save the PDF \& $pdf\->saveas(\*(Aq/path/to/new.pdf\*(Aq); .Ve .SH "GENERIC METHODS" .IX Header "GENERIC METHODS" .ie n .IP "$pdf = \s-1PDF::API2\-\s0>new(%options)" 4 .el .IP "\f(CW$pdf\fR = \s-1PDF::API2\-\s0>new(%options)" 4 .IX Item "$pdf = PDF::API2->new(%options)" Creates a new \s-1PDF\s0 object. If you will be saving it as a file and already know the filename, you can give the '\-file' option to minimize possible memory requirements later on. .Sp \&\fBExample:\fR .Sp .Vb 3 \& $pdf = PDF::API2\->new(); \& ... \& print $pdf\->stringify(); \& \& $pdf = PDF::API2\->new(); \& ... \& $pdf\->saveas(\*(Aqour/new.pdf\*(Aq); \& \& $pdf = PDF::API2\->new(\-file => \*(Aqour/new.pdf\*(Aq); \& ... \& $pdf\->save(); .Ve .ie n .IP "$pdf = \s-1PDF::API2\-\s0>open($pdf_file)" 4 .el .IP "\f(CW$pdf\fR = \s-1PDF::API2\-\s0>open($pdf_file)" 4 .IX Item "$pdf = PDF::API2->open($pdf_file)" Opens an existing \s-1PDF\s0 file. .Sp \&\fBExample:\fR .Sp .Vb 3 \& $pdf = PDF::API2\->open(\*(Aqour/old.pdf\*(Aq); \& ... \& $pdf\->saveas(\*(Aqour/new.pdf\*(Aq); \& \& $pdf = PDF::API2\->open(\*(Aqour/to/be/updated.pdf\*(Aq); \& ... \& $pdf\->update(); .Ve .ie n .IP "$pdf = \s-1PDF::API2\-\s0>openScalar($pdf_string)" 4 .el .IP "\f(CW$pdf\fR = \s-1PDF::API2\-\s0>openScalar($pdf_string)" 4 .IX Item "$pdf = PDF::API2->openScalar($pdf_string)" Opens a \s-1PDF\s0 contained in a string. .Sp \&\fBExample:\fR .Sp .Vb 4 \& # Read a PDF into a string, for the purpose of demonstration \& open $fh, \*(Aqour/old.pdf\*(Aq or die $@; \& undef $/; # Read the whole file at once \& $pdf_string = <$fh>; \& \& $pdf = PDF::API2\->openScalar($pdf_string); \& ... \& $pdf\->saveas(\*(Aqour/new.pdf\*(Aq); .Ve .ie n .IP "$pdf\->preferences(%options)" 4 .el .IP "\f(CW$pdf\fR\->preferences(%options)" 4 .IX Item "$pdf->preferences(%options)" Controls viewing preferences for the \s-1PDF\s0. .Sp \&\fBPage Mode Options:\fR .RS 4 .IP "\-fullscreen" 4 .IX Item "-fullscreen" Full-screen mode, with no menu bar, window controls, or any other window visible. .IP "\-thumbs" 4 .IX Item "-thumbs" Thumbnail images visible. .IP "\-outlines" 4 .IX Item "-outlines" Document outline visible. .RE .RS 4 .Sp \&\fBPage Layout Options:\fR .IP "\-singlepage" 4 .IX Item "-singlepage" Display one page at a time. .IP "\-onecolumn" 4 .IX Item "-onecolumn" Display the pages in one column. .IP "\-twocolumnleft" 4 .IX Item "-twocolumnleft" Display the pages in two columns, with oddnumbered pages on the left. .IP "\-twocolumnright" 4 .IX Item "-twocolumnright" Display the pages in two columns, with oddnumbered pages on the right. .RE .RS 4 .Sp \&\fBViewer Options:\fR .IP "\-hidetoolbar" 4 .IX Item "-hidetoolbar" Specifying whether to hide tool bars. .IP "\-hidemenubar" 4 .IX Item "-hidemenubar" Specifying whether to hide menu bars. .IP "\-hidewindowui" 4 .IX Item "-hidewindowui" Specifying whether to hide user interface elements. .IP "\-fitwindow" 4 .IX Item "-fitwindow" Specifying whether to resize the document's window to the size of the displayed page. .IP "\-centerwindow" 4 .IX Item "-centerwindow" Specifying whether to position the document's window in the center of the screen. .IP "\-displaytitle" 4 .IX Item "-displaytitle" Specifying whether the window's title bar should display the document title taken from the Title entry of the document information dictionary. .IP "\-afterfullscreenthumbs" 4 .IX Item "-afterfullscreenthumbs" Thumbnail images visible after Full-screen mode. .IP "\-afterfullscreenoutlines" 4 .IX Item "-afterfullscreenoutlines" Document outline visible after Full-screen mode. .IP "\-printscalingnone" 4 .IX Item "-printscalingnone" Set the default print setting for page scaling to none. .RE .RS 4 .Sp \&\fBInitial Page Options\fR: .ie n .IP "\-firstpage => [ $page, %options ]" 4 .el .IP "\-firstpage => [ \f(CW$page\fR, \f(CW%options\fR ]" 4 .IX Item "-firstpage => [ $page, %options ]" Specifying the page to be displayed, plus one of the following options: .RS 4 .IP "\-fit => 1" 4 .IX Item "-fit => 1" Display the page designated by page, with its contents magnified just enough to fit the entire page within the window both horizontally and vertically. If the required horizontal and vertical magnification factors are different, use the smaller of the two, centering the page within the window in the other dimension. .ie n .IP "\-fith => $top" 4 .el .IP "\-fith => \f(CW$top\fR" 4 .IX Item "-fith => $top" Display the page designated by page, with the vertical coordinate top positioned at the top edge of the window and the contents of the page magnified just enough to fit the entire width of the page within the window. .ie n .IP "\-fitv => $left" 4 .el .IP "\-fitv => \f(CW$left\fR" 4 .IX Item "-fitv => $left" Display the page designated by page, with the horizontal coordinate left positioned at the left edge of the window and the contents of the page magnified just enough to fit the entire height of the page within the window. .ie n .IP "\-fitr => [ $left, $bottom, $right, $top ]" 4 .el .IP "\-fitr => [ \f(CW$left\fR, \f(CW$bottom\fR, \f(CW$right\fR, \f(CW$top\fR ]" 4 .IX Item "-fitr => [ $left, $bottom, $right, $top ]" Display the page designated by page, with its contents magnified just enough to fit the rectangle specified by the coordinates left, bottom, right, and top entirely within the window both horizontally and vertically. If the required horizontal and vertical magnification factors are different, use the smaller of the two, centering the rectangle within the window in the other dimension. .IP "\-fitb => 1" 4 .IX Item "-fitb => 1" Display the page designated by page, with its contents magnified just enough to fit its bounding box entirely within the window both horizontally and vertically. If the required horizontal and vertical magnification factors are different, use the smaller of the two, centering the bounding box within the window in the other dimension. .ie n .IP "\-fitbh => $top" 4 .el .IP "\-fitbh => \f(CW$top\fR" 4 .IX Item "-fitbh => $top" Display the page designated by page, with the vertical coordinate top positioned at the top edge of the window and the contents of the page magnified just enough to fit the entire width of its bounding box within the window. .ie n .IP "\-fitbv => $left" 4 .el .IP "\-fitbv => \f(CW$left\fR" 4 .IX Item "-fitbv => $left" Display the page designated by page, with the horizontal coordinate left positioned at the left edge of the window and the contents of the page magnified just enough to fit the entire height of its bounding box within the window. .ie n .IP "\-xyz => [ $left, $top, $zoom ]" 4 .el .IP "\-xyz => [ \f(CW$left\fR, \f(CW$top\fR, \f(CW$zoom\fR ]" 4 .IX Item "-xyz => [ $left, $top, $zoom ]" Display the page designated by page, with the coordinates (left, top) positioned at the top-left corner of the window and the contents of the page magnified by the factor zoom. A zero (0) value for any of the parameters left, top, or zoom specifies that the current value of that parameter is to be retained unchanged. .RE .RS 4 .RE .RE .RS 4 .Sp \&\fBExample:\fR .Sp .Vb 6 \& $pdf\->preferences( \& \-fullscreen => 1, \& \-onecolumn => 1, \& \-afterfullscreenoutlines => 1, \& \-firstpage => [$page, \-fit => 1], \& ); .Ve .RE .ie n .IP "$val = $pdf\->default($parameter)" 4 .el .IP "\f(CW$val\fR = \f(CW$pdf\fR\->default($parameter)" 4 .IX Item "$val = $pdf->default($parameter)" .PD 0 .ie n .IP "$pdf\->default($parameter, $value)" 4 .el .IP "\f(CW$pdf\fR\->default($parameter, \f(CW$value\fR)" 4 .IX Item "$pdf->default($parameter, $value)" .PD Gets/sets the default value for a behaviour of \s-1PDF::API2\s0. .Sp \&\fBSupported Parameters:\fR .RS 4 .IP "nounrotate" 4 .IX Item "nounrotate" prohibits \s-1API2\s0 from rotating imported/opened page to re-create a default pdf-context. .IP "pageencaps" 4 .IX Item "pageencaps" enables than \s-1API2\s0 will add save/restore commands upon imported/opened pages to preserve graphics-state for modification. .IP "copyannots" 4 .IX Item "copyannots" enables importing of annotations (\fB*EXPERIMENTAL*\fR). .RE .RS 4 .RE .ie n .IP "$bool = $pdf\->\fIisEncrypted()\fR" 4 .el .IP "\f(CW$bool\fR = \f(CW$pdf\fR\->\fIisEncrypted()\fR" 4 .IX Item "$bool = $pdf->isEncrypted()" Checks if the previously opened \s-1PDF\s0 is encrypted. .ie n .IP "%infohash = $pdf\->info(%infohash)" 4 .el .IP "\f(CW%infohash\fR = \f(CW$pdf\fR\->info(%infohash)" 4 .IX Item "%infohash = $pdf->info(%infohash)" Gets/sets the info structure of the document. .Sp \&\fBExample:\fR .Sp .Vb 11 \& %h = $pdf\->info( \& \*(AqAuthor\*(Aq => "Alfred Reibenschuh", \& \*(AqCreationDate\*(Aq => "D:20020911000000+01\*(Aq00\*(Aq", \& \*(AqModDate\*(Aq => "D:YYYYMMDDhhmmssOHH\*(Aqmm\*(Aq", \& \*(AqCreator\*(Aq => "fredos\-script.pl", \& \*(AqProducer\*(Aq => "PDF::API2", \& \*(AqTitle\*(Aq => "some Publication", \& \*(AqSubject\*(Aq => "perl ?", \& \*(AqKeywords\*(Aq => "all good things are pdf" \& ); \& print "Author: $h{Author}\en"; .Ve .ie n .IP "@metadata_attributes = $pdf\->infoMetaAttributes(@metadata_attributes)" 4 .el .IP "\f(CW@metadata_attributes\fR = \f(CW$pdf\fR\->infoMetaAttributes(@metadata_attributes)" 4 .IX Item "@metadata_attributes = $pdf->infoMetaAttributes(@metadata_attributes)" Gets/sets the supported info-structure tags. .Sp \&\fBExample:\fR .Sp .Vb 2 \& @attributes = $pdf\->infoMetaAttributes; \& print "Supported Attributes: @attr\en"; \& \& @attributes = $pdf\->infoMetaAttributes(\*(AqCustomField1\*(Aq); \& print "Supported Attributes: @attributes\en"; .Ve .ie n .IP "$xml = $pdf\->xmpMetadata($xml)" 4 .el .IP "\f(CW$xml\fR = \f(CW$pdf\fR\->xmpMetadata($xml)" 4 .IX Item "$xml = $pdf->xmpMetadata($xml)" Gets/sets the \s-1XMP\s0 \s-1XML\s0 data stream. .Sp \&\fBExample:\fR .Sp .Vb 10 \& $xml = $pdf\->xmpMetadata(); \& print "PDFs Metadata reads: $xml\en"; \& $xml=< \& \& \& \& \& \& \& \& \& \& Adobe Portable Document Format (PDF) \& \& \& \& \& Adobe Systems Incorporated \& \& \& \& \& PDF Reference, version 1.6 \& \& \& \& \& \& \& EOT \& \& $xml = $pdf\->xmpMetadata($xml); \& print "PDF metadata now reads: $xml\en"; .Ve .ie n .IP "$pdf\->pageLabel($index, $options)" 4 .el .IP "\f(CW$pdf\fR\->pageLabel($index, \f(CW$options\fR)" 4 .IX Item "$pdf->pageLabel($index, $options)" Sets page label options. .Sp \&\fBSupported Options:\fR .RS 4 .IP "\-style" 4 .IX Item "-style" Roman, roman, decimal, Alpha or alpha. .IP "\-start" 4 .IX Item "-start" Restart numbering at given number. .IP "\-prefix" 4 .IX Item "-prefix" Text prefix for numbering. .RE .RS 4 .Sp \&\fBExample:\fR .Sp .Vb 4 \& # Start with Roman Numerals \& $pdf\->pageLabel(0, { \& \-style => \*(Aqroman\*(Aq, \& }); \& \& # Switch to Arabic \& $pdf\->pageLabel(4, { \& \-style => \*(Aqdecimal\*(Aq, \& }); \& \& # Numbering for Appendix A \& $pdf\->pageLabel(32, { \& \-start => 1, \& \-prefix => \*(AqA\-\*(Aq \& }); \& \& # Numbering for Appendix B \& $pdf\->pageLabel( 36, { \& \-start => 1, \& \-prefix => \*(AqB\-\*(Aq \& }); \& \& # Numbering for the Index \& $pdf\->pageLabel(40, { \& \-style => \*(AqRoman\*(Aq \& \-start => 1, \& \-prefix => \*(AqIndex \*(Aq \& }); .Ve .RE .ie n .IP "$pdf\->finishobjects(@objects)" 4 .el .IP "\f(CW$pdf\fR\->finishobjects(@objects)" 4 .IX Item "$pdf->finishobjects(@objects)" Force objects to be written to file if possible. .Sp \&\fBExample:\fR .Sp .Vb 5 \& $pdf = PDF::API2\->new(\-file => \*(Aqour/new.pdf\*(Aq); \& ... \& $pdf\->finishobjects($page, $gfx, $txt); \& ... \& $pdf\->save(); .Ve .ie n .IP "$pdf\->\fIupdate()\fR" 4 .el .IP "\f(CW$pdf\fR\->\fIupdate()\fR" 4 .IX Item "$pdf->update()" Saves a previously opened document. .Sp \&\fBExample:\fR .Sp .Vb 3 \& $pdf = PDF::API2\->open(\*(Aqour/to/be/updated.pdf\*(Aq); \& ... \& $pdf\->update(); .Ve .ie n .IP "$pdf\->saveas($file)" 4 .el .IP "\f(CW$pdf\fR\->saveas($file)" 4 .IX Item "$pdf->saveas($file)" Saves the document to file. .Sp \&\fBExample:\fR .Sp .Vb 3 \& $pdf = PDF::API2\->new(); \& ... \& $pdf\->saveas(\*(Aqour/new.pdf\*(Aq); .Ve .ie n .IP "$string = $pdf\->\fIstringify()\fR" 4 .el .IP "\f(CW$string\fR = \f(CW$pdf\fR\->\fIstringify()\fR" 4 .IX Item "$string = $pdf->stringify()" Returns the document as a string. .Sp \&\fBExample:\fR .Sp .Vb 3 \& $pdf = PDF::API2\->new(); \& ... \& print $pdf\->stringify(); .Ve .ie n .IP "$pdf\->\fIend()\fR" 4 .el .IP "\f(CW$pdf\fR\->\fIend()\fR" 4 .IX Item "$pdf->end()" Destroys the document. .SH "PAGE METHODS" .IX Header "PAGE METHODS" .ie n .IP "$page = $pdf\->\fIpage()\fR" 4 .el .IP "\f(CW$page\fR = \f(CW$pdf\fR\->\fIpage()\fR" 4 .IX Item "$page = $pdf->page()" .PD 0 .ie n .IP "$page = $pdf\->page($page_number)" 4 .el .IP "\f(CW$page\fR = \f(CW$pdf\fR\->page($page_number)" 4 .IX Item "$page = $pdf->page($page_number)" .PD Returns a new page object. By default, the page is added to the end of the document. If you include an existing page number, the new page will be inserted in that position, pushing existing pages back. .Sp \&\f(CW$page_number\fR can also have one of the following values: .RS 4 .IP "\-1 inserts the new page as the second-last page" 4 .IX Item "-1 inserts the new page as the second-last page" .PD 0 .IP "0 inserts the page as the last page" 4 .IX Item "0 inserts the page as the last page" .RE .RS 4 .PD .Sp \&\fBExample:\fR .Sp .Vb 1 \& $pdf = PDF::API2\->new(); \& \& # Add a page. This becomes page 1. \& $page = $pdf\->page(); \& \& # Add a new first page. $page becomes page 2. \& $another_page = $pdf\->page(1); .Ve .RE .ie n .IP "$page = $pdf\->openpage($page_number)" 4 .el .IP "\f(CW$page\fR = \f(CW$pdf\fR\->openpage($page_number)" 4 .IX Item "$page = $pdf->openpage($page_number)" Returns the PDF::API2::Page object of page \f(CW$page_number\fR. .Sp If \f(CW$page_number\fR is 0 or \-1, it will return the last page in the document. .Sp \&\fBExample:\fR .Sp .Vb 5 \& $pdf = PDF::API2\->open(\*(Aqour/99page.pdf\*(Aq); \& $page = $pdf\->openpage(1); # returns the first page \& $page = $pdf\->openpage(99); # returns the last page \& $page = $pdf\->openpage(\-1); # returns the last page \& $page = $pdf\->openpage(999); # returns undef .Ve .ie n .IP "$xoform = $pdf\->importPageIntoForm($source_pdf, $source_page_number)" 4 .el .IP "\f(CW$xoform\fR = \f(CW$pdf\fR\->importPageIntoForm($source_pdf, \f(CW$source_page_number\fR)" 4 .IX Item "$xoform = $pdf->importPageIntoForm($source_pdf, $source_page_number)" Returns a Form XObject created by extracting the specified page from \f(CW$source_pdf\fR. .Sp This is useful if you want to transpose the imported page somewhat differently onto a page (e.g. two-up, four-up, etc.). .Sp If \f(CW$source_page_number\fR is 0 or \-1, it will return the last page in the document. .Sp \&\fBExample:\fR .Sp .Vb 4 \& $pdf = PDF::API2\->new(); \& $old = PDF::API2\->open(\*(Aqour/old.pdf\*(Aq); \& $page = $pdf\->page(); \& $gfx = $page\->gfx(); \& \& # Import Page 2 from the old PDF \& $xo = $pdf\->importPageIntoForm($old, 2); \& \& # Add it to the new PDF\*(Aqs first page at 1/2 scale \& $gfx\->formimage($xo, 0, 0, 0.5); \& \& $pdf\->saveas(\*(Aqour/new.pdf\*(Aq); .Ve .Sp \&\fBNote:\fR You can only import a page from an existing \s-1PDF\s0 file. .ie n .IP "$page = $pdf\->importpage($source_pdf, $source_page_number, $target_page_number)" 4 .el .IP "\f(CW$page\fR = \f(CW$pdf\fR\->importpage($source_pdf, \f(CW$source_page_number\fR, \f(CW$target_page_number\fR)" 4 .IX Item "$page = $pdf->importpage($source_pdf, $source_page_number, $target_page_number)" Imports a page from \f(CW$source_pdf\fR and adds it to the specified position in \f(CW$pdf\fR. .Sp If \f(CW$source_page_number\fR or \f(CW$target_page_number\fR is 0 or \-1, the last page in the document is used. .Sp \&\fBNote:\fR If you pass a page object instead of a page number for \&\f(CW$target_page_number\fR, the contents of the page will be merged into the existing page. .Sp \&\fBExample:\fR .Sp .Vb 2 \& $pdf = PDF::API2\->new(); \& $old = PDF::API2\->open(\*(Aqour/old.pdf\*(Aq); \& \& # Add page 2 from the old PDF as page 1 of the new PDF \& $page = $pdf\->importpage($old, 2); \& \& $pdf\->saveas(\*(Aqour/new.pdf\*(Aq); .Ve .Sp \&\fBNote:\fR You can only import a page from an existing \s-1PDF\s0 file. .ie n .IP "$count = $pdf\->\fIpages()\fR" 4 .el .IP "\f(CW$count\fR = \f(CW$pdf\fR\->\fIpages()\fR" 4 .IX Item "$count = $pdf->pages()" Returns the number of pages in the document. .ie n .IP "$pdf\->mediabox($name)" 4 .el .IP "\f(CW$pdf\fR\->mediabox($name)" 4 .IX Item "$pdf->mediabox($name)" .PD 0 .ie n .IP "$pdf\->mediabox($w, $h)" 4 .el .IP "\f(CW$pdf\fR\->mediabox($w, \f(CW$h\fR)" 4 .IX Item "$pdf->mediabox($w, $h)" .ie n .IP "$pdf\->mediabox($llx, $lly, $urx, $ury)" 4 .el .IP "\f(CW$pdf\fR\->mediabox($llx, \f(CW$lly\fR, \f(CW$urx\fR, \f(CW$ury\fR)" 4 .IX Item "$pdf->mediabox($llx, $lly, $urx, $ury)" .PD Sets the global mediabox. .Sp \&\fBExample:\fR .Sp .Vb 4 \& $pdf = PDF::API2\->new(); \& $pdf\->mediabox(\*(AqA4\*(Aq); \& ... \& $pdf\->saveas(\*(Aqour/new.pdf\*(Aq); \& \& $pdf = PDF::API2\->new(); \& $pdf\->mediabox(595, 842); \& ... \& $pdf\->saveas(\*(Aqour/new.pdf\*(Aq); \& \& $pdf = PDF::API2\->new; \& $pdf\->mediabox(0, 0, 595, 842); \& ... \& $pdf\->saveas(\*(Aqour/new.pdf\*(Aq); .Ve .ie n .IP "$pdf\->cropbox($name)" 4 .el .IP "\f(CW$pdf\fR\->cropbox($name)" 4 .IX Item "$pdf->cropbox($name)" .PD 0 .ie n .IP "$pdf\->cropbox($w, $h)" 4 .el .IP "\f(CW$pdf\fR\->cropbox($w, \f(CW$h\fR)" 4 .IX Item "$pdf->cropbox($w, $h)" .ie n .IP "$pdf\->cropbox($llx, $lly, $urx, $ury)" 4 .el .IP "\f(CW$pdf\fR\->cropbox($llx, \f(CW$lly\fR, \f(CW$urx\fR, \f(CW$ury\fR)" 4 .IX Item "$pdf->cropbox($llx, $lly, $urx, $ury)" .PD Sets the global cropbox. .ie n .IP "$pdf\->bleedbox($name)" 4 .el .IP "\f(CW$pdf\fR\->bleedbox($name)" 4 .IX Item "$pdf->bleedbox($name)" .PD 0 .ie n .IP "$pdf\->bleedbox($w, $h)" 4 .el .IP "\f(CW$pdf\fR\->bleedbox($w, \f(CW$h\fR)" 4 .IX Item "$pdf->bleedbox($w, $h)" .ie n .IP "$pdf\->bleedbox($llx, $lly, $urx, $ury)" 4 .el .IP "\f(CW$pdf\fR\->bleedbox($llx, \f(CW$lly\fR, \f(CW$urx\fR, \f(CW$ury\fR)" 4 .IX Item "$pdf->bleedbox($llx, $lly, $urx, $ury)" .PD Sets the global bleedbox. .ie n .IP "$pdf\->trimbox($name)" 4 .el .IP "\f(CW$pdf\fR\->trimbox($name)" 4 .IX Item "$pdf->trimbox($name)" .PD 0 .ie n .IP "$pdf\->trimbox($w, $h)" 4 .el .IP "\f(CW$pdf\fR\->trimbox($w, \f(CW$h\fR)" 4 .IX Item "$pdf->trimbox($w, $h)" .ie n .IP "$pdf\->trimbox($llx, $lly, $urx, $ury)" 4 .el .IP "\f(CW$pdf\fR\->trimbox($llx, \f(CW$lly\fR, \f(CW$urx\fR, \f(CW$ury\fR)" 4 .IX Item "$pdf->trimbox($llx, $lly, $urx, $ury)" .PD Sets the global trimbox. .ie n .IP "$pdf\->artbox($name)" 4 .el .IP "\f(CW$pdf\fR\->artbox($name)" 4 .IX Item "$pdf->artbox($name)" .PD 0 .ie n .IP "$pdf\->artbox($w, $h)" 4 .el .IP "\f(CW$pdf\fR\->artbox($w, \f(CW$h\fR)" 4 .IX Item "$pdf->artbox($w, $h)" .ie n .IP "$pdf\->artbox($llx, $lly, $urx, $ury)" 4 .el .IP "\f(CW$pdf\fR\->artbox($llx, \f(CW$lly\fR, \f(CW$urx\fR, \f(CW$ury\fR)" 4 .IX Item "$pdf->artbox($llx, $lly, $urx, $ury)" .PD Sets the global artbox. .SH "FONT METHODS" .IX Header "FONT METHODS" .ie n .IP "@directories = PDF::API2::addFontDirs($dir1, $dir2, ...)" 4 .el .IP "\f(CW@directories\fR = PDF::API2::addFontDirs($dir1, \f(CW$dir2\fR, ...)" 4 .IX Item "@directories = PDF::API2::addFontDirs($dir1, $dir2, ...)" Adds one or more directories to the search path for finding font files. .Sp Returns the list of searched directories. .ie n .IP "$font = $pdf\->corefont($fontname, [%options])" 4 .el .IP "\f(CW$font\fR = \f(CW$pdf\fR\->corefont($fontname, [%options])" 4 .IX Item "$font = $pdf->corefont($fontname, [%options])" Returns a new Adobe core font object. .Sp \&\fBExamples:\fR .Sp .Vb 4 \& $font = $pdf\->corefont(\*(AqTimes\-Roman\*(Aq); \& $font = $pdf\->corefont(\*(AqTimes\-Bold\*(Aq); \& $font = $pdf\->corefont(\*(AqHelvetica\*(Aq); \& $font = $pdf\->corefont(\*(AqZapfDingbats\*(Aq); .Ve .Sp Valid \f(CW%options\fR are: .RS 4 .IP "\-encode" 4 .IX Item "-encode" Changes the encoding of the font from its default. .IP "\-dokern" 4 .IX Item "-dokern" Enables kerning if data is available. .RE .RS 4 .Sp See Also: PDF::API2::Resource::Font::CoreFont. .RE .ie n .IP "$font = $pdf\->psfont($ps_file, [%options])" 4 .el .IP "\f(CW$font\fR = \f(CW$pdf\fR\->psfont($ps_file, [%options])" 4 .IX Item "$font = $pdf->psfont($ps_file, [%options])" Returns a new Adobe Type1 font object. .Sp \&\fBExamples:\fR .Sp .Vb 2 \& $font = $pdf\->psfont(\*(AqTimes\-Book.pfa\*(Aq, \-afmfile => \*(AqTimes\-Book.afm\*(Aq); \& $font = $pdf\->psfont(\*(Aq/fonts/Synest\-FB.pfb\*(Aq, \-pfmfile => \*(Aq/fonts/Synest\-FB.pfm\*(Aq); .Ve .Sp Valid \f(CW%options\fR are: .RS 4 .IP "\-encode" 4 .IX Item "-encode" Changes the encoding of the font from its default. .IP "\-afmfile" 4 .IX Item "-afmfile" Specifies the location of the font metrics file. .IP "\-pfmfile" 4 .IX Item "-pfmfile" Specifies the location of the printer font metrics file. This option overrides the \-encode option. .IP "\-dokern" 4 .IX Item "-dokern" Enables kerning if data is available. .RE .RS 4 .RE .ie n .IP "$font = $pdf\->ttfont($ttf_file, [%options])" 4 .el .IP "\f(CW$font\fR = \f(CW$pdf\fR\->ttfont($ttf_file, [%options])" 4 .IX Item "$font = $pdf->ttfont($ttf_file, [%options])" Returns a new TrueType or OpenType font object. .Sp \&\fBExamples:\fR .Sp .Vb 2 \& $font = $pdf\->ttfont(\*(AqTimes.ttf\*(Aq); \& $font = $pdf\->ttfont(\*(AqGeorgia.otf\*(Aq); .Ve .Sp Valid \f(CW%options\fR are: .RS 4 .IP "\-encode" 4 .IX Item "-encode" Changes the encoding of the font from its default. .IP "\-isocmap" 4 .IX Item "-isocmap" Use the \s-1ISO\s0 Unicode Map instead of the default \s-1MS\s0 Unicode Map. .IP "\-dokern" 4 .IX Item "-dokern" Enables kerning if data is available. .IP "\-noembed" 4 .IX Item "-noembed" Disables embedding of the font file. .RE .RS 4 .RE .ie n .IP "$font = $pdf\->cjkfont($cjkname, [%options])" 4 .el .IP "\f(CW$font\fR = \f(CW$pdf\fR\->cjkfont($cjkname, [%options])" 4 .IX Item "$font = $pdf->cjkfont($cjkname, [%options])" Returns a new \s-1CJK\s0 font object. .Sp \&\fBExamples:\fR .Sp .Vb 2 \& $font = $pdf\->cjkfont(\*(Aqkorean\*(Aq); \& $font = $pdf\->cjkfont(\*(Aqtraditional\*(Aq); .Ve .Sp Valid \f(CW%options\fR are: .RS 4 .IP "\-encode" 4 .IX Item "-encode" Changes the encoding of the font from its default. .RE .RS 4 .Sp See Also: PDF::API2::Resource::CIDFont::CJKFont .RE .ie n .IP "$font = $pdf\->synfont($basefont, [%options])" 4 .el .IP "\f(CW$font\fR = \f(CW$pdf\fR\->synfont($basefont, [%options])" 4 .IX Item "$font = $pdf->synfont($basefont, [%options])" Returns a new synthetic font object. .Sp \&\fBExamples:\fR .Sp .Vb 4 \& $cf = $pdf\->corefont(\*(AqTimes\-Roman\*(Aq, \-encode => \*(Aqlatin1\*(Aq); \& $sf = $pdf\->synfont($cf, \-slant => 0.85); # compressed 85% \& $sfb = $pdf\->synfont($cf, \-bold => 1); # embolden by 10em \& $sfi = $pdf\->synfont($cf, \-oblique => \-12); # italic at \-12 degrees .Ve .Sp Valid \f(CW%options\fR are: .RS 4 .IP "\-slant" 4 .IX Item "-slant" Slant/expansion factor (0.1\-0.9 = slant, 1.1+ = expansion). .IP "\-oblique" 4 .IX Item "-oblique" Italic angle (+/\-) .IP "\-bold" 4 .IX Item "-bold" Emboldening factor (0.1+, bold = 1, heavy = 2, ...) .IP "\-space" 4 .IX Item "-space" Additional character spacing in ems (0\-1000) .RE .RS 4 .Sp See Also: PDF::API2::Resource::Font::SynFont .RE .ie n .IP "$font = $pdf\->bdfont($bdf_file)" 4 .el .IP "\f(CW$font\fR = \f(CW$pdf\fR\->bdfont($bdf_file)" 4 .IX Item "$font = $pdf->bdfont($bdf_file)" Returns a new \s-1BDF\s0 font object, based on the specified Adobe \s-1BDF\s0 file. .Sp See Also: PDF::API2::Resource::Font::BdFont .ie n .IP "$font = $pdf\->unifont(@fontspecs, %options)" 4 .el .IP "\f(CW$font\fR = \f(CW$pdf\fR\->unifont(@fontspecs, \f(CW%options\fR)" 4 .IX Item "$font = $pdf->unifont(@fontspecs, %options)" Returns a new uni-font object, based on the specified fonts and options. .Sp \&\fB\s-1BEWARE:\s0\fR This is not a true pdf-object, but a virtual/abstract font definition! .Sp See Also: PDF::API2::Resource::UniFont. .Sp Valid \f(CW%options\fR are: .RS 4 .IP "\-encode" 4 .IX Item "-encode" Changes the encoding of the font from its default. .RE .RS 4 .RE .SH "IMAGE METHODS" .IX Header "IMAGE METHODS" .ie n .IP "$jpeg = $pdf\->image_jpeg($file)" 4 .el .IP "\f(CW$jpeg\fR = \f(CW$pdf\fR\->image_jpeg($file)" 4 .IX Item "$jpeg = $pdf->image_jpeg($file)" Imports and returns a new \s-1JPEG\s0 image object. .ie n .IP "$tiff = $pdf\->image_tiff($file)" 4 .el .IP "\f(CW$tiff\fR = \f(CW$pdf\fR\->image_tiff($file)" 4 .IX Item "$tiff = $pdf->image_tiff($file)" Imports and returns a new \s-1TIFF\s0 image object. .ie n .IP "$pnm = $pdf\->image_pnm($file)" 4 .el .IP "\f(CW$pnm\fR = \f(CW$pdf\fR\->image_pnm($file)" 4 .IX Item "$pnm = $pdf->image_pnm($file)" Imports and returns a new \s-1PNM\s0 image object. .ie n .IP "$png = $pdf\->image_png($file)" 4 .el .IP "\f(CW$png\fR = \f(CW$pdf\fR\->image_png($file)" 4 .IX Item "$png = $pdf->image_png($file)" Imports and returns a new \s-1PNG\s0 image object. .ie n .IP "$gif = $pdf\->image_gif($file)" 4 .el .IP "\f(CW$gif\fR = \f(CW$pdf\fR\->image_gif($file)" 4 .IX Item "$gif = $pdf->image_gif($file)" Imports and returns a new \s-1GIF\s0 image object. .ie n .IP "$gdf = $pdf\->image_gd($gd_object, %options)" 4 .el .IP "\f(CW$gdf\fR = \f(CW$pdf\fR\->image_gd($gd_object, \f(CW%options\fR)" 4 .IX Item "$gdf = $pdf->image_gd($gd_object, %options)" Imports and returns a new image object from GD::Image. .Sp \&\fBOptions:\fR The only option currently supported is \f(CW\*(C`\-lossless => 1\*(C'\fR. .SH "COLORSPACE METHODS" .IX Header "COLORSPACE METHODS" .ie n .IP "$cs = $pdf\->colorspace_act($file)" 4 .el .IP "\f(CW$cs\fR = \f(CW$pdf\fR\->colorspace_act($file)" 4 .IX Item "$cs = $pdf->colorspace_act($file)" Returns a new colorspace object based on an Adobe Color Table file. .Sp See PDF::API2::Resource::ColorSpace::Indexed::ACTFile for a reference to the file format's specification. .ie n .IP "$cs = $pdf\->\fIcolorspace_web()\fR" 4 .el .IP "\f(CW$cs\fR = \f(CW$pdf\fR\->\fIcolorspace_web()\fR" 4 .IX Item "$cs = $pdf->colorspace_web()" Returns a new colorspace-object based on the web color palette. .ie n .IP "$cs = $pdf\->\fIcolorspace_hue()\fR" 4 .el .IP "\f(CW$cs\fR = \f(CW$pdf\fR\->\fIcolorspace_hue()\fR" 4 .IX Item "$cs = $pdf->colorspace_hue()" Returns a new colorspace-object based on the hue color palette. .Sp See PDF::API2::Resource::ColorSpace::Indexed::Hue for an explanation. .ie n .IP "$cs = $pdf\->colorspace_separation($tint, $color)" 4 .el .IP "\f(CW$cs\fR = \f(CW$pdf\fR\->colorspace_separation($tint, \f(CW$color\fR)" 4 .IX Item "$cs = $pdf->colorspace_separation($tint, $color)" Returns a new separation colorspace object based on the parameters. .Sp \&\fI\f(CI$tint\fI\fR can be any valid ink identifier, including but not limited to: 'Cyan', 'Magenta', 'Yellow', 'Black', 'Red', 'Green', 'Blue' or \&'Orange'. .Sp \&\fI\f(CI$color\fI\fR must be a valid color specification limited to: '#rrggbb', \&'!hhssvv', '%ccmmyykk' or a \*(L"named color\*(R" (rgb). .Sp The colorspace model will automatically be chosen based on the specified color. .ie n .IP "$cs = $pdf\->colorspace_devicen(\e@tintCSx, [$samples])" 4 .el .IP "\f(CW$cs\fR = \f(CW$pdf\fR\->colorspace_devicen(\e@tintCSx, [$samples])" 4 .IX Item "$cs = $pdf->colorspace_devicen(@tintCSx, [$samples])" Returns a new DeviceN colorspace object based on the parameters. .Sp \&\fBExample:\fR .Sp .Vb 4 \& $cy = $pdf\->colorspace_separation(\*(AqCyan\*(Aq, \*(Aq%f000\*(Aq); \& $ma = $pdf\->colorspace_separation(\*(AqMagenta\*(Aq, \*(Aq%0f00\*(Aq); \& $ye = $pdf\->colorspace_separation(\*(AqYellow\*(Aq, \*(Aq%00f0\*(Aq); \& $bk = $pdf\->colorspace_separation(\*(AqBlack\*(Aq, \*(Aq%000f\*(Aq); \& \& $pms023 = $pdf\->colorspace_separation(\*(AqPANTONE 032CV\*(Aq, \*(Aq%0ff0\*(Aq); \& \& $dncs = $pdf\->colorspace_devicen( [ $cy,$ma,$ye,$bk,$pms023 ] ); .Ve .Sp The colorspace model will automatically be chosen based on the first colorspace specified. .SH "BARCODE METHODS" .IX Header "BARCODE METHODS" .ie n .IP "$bc = $pdf\->xo_codabar(%options)" 4 .el .IP "\f(CW$bc\fR = \f(CW$pdf\fR\->xo_codabar(%options)" 4 .IX Item "$bc = $pdf->xo_codabar(%options)" .PD 0 .ie n .IP "$bc = $pdf\->xo_code128(%options)" 4 .el .IP "\f(CW$bc\fR = \f(CW$pdf\fR\->xo_code128(%options)" 4 .IX Item "$bc = $pdf->xo_code128(%options)" .ie n .IP "$bc = $pdf\->xo_2of5int(%options)" 4 .el .IP "\f(CW$bc\fR = \f(CW$pdf\fR\->xo_2of5int(%options)" 4 .IX Item "$bc = $pdf->xo_2of5int(%options)" .ie n .IP "$bc = $pdf\->xo_3of9(%options)" 4 .el .IP "\f(CW$bc\fR = \f(CW$pdf\fR\->xo_3of9(%options)" 4 .IX Item "$bc = $pdf->xo_3of9(%options)" .ie n .IP "$bc = $pdf\->xo_ean13(%options)" 4 .el .IP "\f(CW$bc\fR = \f(CW$pdf\fR\->xo_ean13(%options)" 4 .IX Item "$bc = $pdf->xo_ean13(%options)" .PD Creates the specified barcode object as a form XObject. .SH "OTHER METHODS" .IX Header "OTHER METHODS" .ie n .IP "$xo = $pdf\->\fIxo_form()\fR" 4 .el .IP "\f(CW$xo\fR = \f(CW$pdf\fR\->\fIxo_form()\fR" 4 .IX Item "$xo = $pdf->xo_form()" Returns a new form XObject. .ie n .IP "$egs = $pdf\->\fIegstate()\fR" 4 .el .IP "\f(CW$egs\fR = \f(CW$pdf\fR\->\fIegstate()\fR" 4 .IX Item "$egs = $pdf->egstate()" Returns a new extended graphics state object. .ie n .IP "$obj = $pdf\->\fIpattern()\fR" 4 .el .IP "\f(CW$obj\fR = \f(CW$pdf\fR\->\fIpattern()\fR" 4 .IX Item "$obj = $pdf->pattern()" Returns a new pattern object. .ie n .IP "$obj = $pdf\->\fIshading()\fR" 4 .el .IP "\f(CW$obj\fR = \f(CW$pdf\fR\->\fIshading()\fR" 4 .IX Item "$obj = $pdf->shading()" Returns a new shading object. .ie n .IP "$otls = $pdf\->\fIoutlines()\fR" 4 .el .IP "\f(CW$otls\fR = \f(CW$pdf\fR\->\fIoutlines()\fR" 4 .IX Item "$otls = $pdf->outlines()" Returns a new or existing outlines object. .SH "RESOURCE METHODS" .IX Header "RESOURCE METHODS" .ie n .IP "$pdf\->resource($type, $key, $obj, $force)" 4 .el .IP "\f(CW$pdf\fR\->resource($type, \f(CW$key\fR, \f(CW$obj\fR, \f(CW$force\fR)" 4 .IX Item "$pdf->resource($type, $key, $obj, $force)" Adds a resource to the global \s-1PDF\s0 tree. .Sp \&\fBExample:\fR .Sp .Vb 4 \& $pdf\->resource(\*(AqFont\*(Aq, $fontkey, $fontobj); \& $pdf\->resource(\*(AqXObject\*(Aq, $imagekey, $imageobj); \& $pdf\->resource(\*(AqShading\*(Aq, $shadekey, $shadeobj); \& $pdf\->resource(\*(AqColorSpace\*(Aq, $spacekey, $speceobj); .Ve .Sp \&\fBNote:\fR You only have to add the required resources if they are \s-1NOT\s0 handled by the font, image, shade or space methods. .SH "BUGS" .IX Header "BUGS" This module does not work with perl's \-l command-line switch. .SH "AUTHOR" .IX Header "AUTHOR" \&\s-1PDF::API2\s0 was originally written by Alfred Reibenschuh. .PP It is currently being maintained by Steve Simms.