PDF::API2

NAME

PDF::API2 - The Next Generation API for creating and modifing PDFs.

SYNOPSIS

use PDF::API2;

$pdf = PDF::API2->new;
$pdf = PDF::API2->open('some.pdf');
$page = $pdf->page;
$page = $pdf->openpage($pagenum);
$img = $pdf->image('some.jpg');
$font = $pdf->corefont('Times-Roman');
$font = $pdf->psfont('Times-Roman.pfb','Times-Roman.afm');
$font = $pdf->ttfont('TimesNewRoman.ttf');

METHODS

PDF::API2

$pdf = PDF::API->new %opts

Creates a new pdf-file object. If you know beforehand to save the pdf to file you can give the '-file' option, to minimize possible memory requirements.

Example:

$pdf = PDF::API2->new();

$pdf = PDF::API2->new(-file => 'ournew.pdf');
$pdf = PDF::API->open $pdffile

Opens an existing PDF.

$page = $pdf->page
$page = $pdf->page $index

Returns a new page object or inserts-and-returns a new page at $index.

Note: on $index

-1 ... is inserted before the last page
1 ... is inserted before page number 1
0 ... is simply appended
$pageobj = $pdf->openpage $index

Returns the pageobject of page $index.

Note: on $index

-1,0 ... returns the last page
1 ... returns page number 1
$pageobj = $pdf->clonepage $sourceindex, $targetindex

Returns the pageobject of page $targetindex, cloned from $sourceindex.

Note: on $index

-1,0 ... returns the last page
1 ... returns page number 1

Beware:

Under some circumstances, this method may cause $pdf->update to die. These circumstances remain unresolved but previously generated pdfs via API2 remain unaffected so far.

$pageobj = $pdf->importpage $sourcepdf, $sourceindex, $targetindex

Returns the pageobject of page $targetindex, imported from $sourcepdf,$sourceindex.

Note: on $index

-1,0 ... returns the last page
1 ... returns page number 1
$pagenumber = $pdf->pages

Returns the number of pages in the document.

$pdf->mediabox $w, $h
$pdf->mediabox $llx, $lly, $urx, $ury

Sets the global mediabox.

$pdf->update

Updates a previously "opened" document after all changes have been applied.

$pdf->saveas $file

Saves the document.

$string = $pdf->stringify

Returns the document in a string.

$pdf->end

Destroys the document.

$pdf->info %infohash

Sets the info structure of the document.

$pdf->finishobjects @objects

Force objects to be written to file.

$val = $pdf->default $parameter
$pdf->default $parameter, $val

Gets/Sets default values for the behaviour of ::API2.

$font = $pdf->corefont $fontname [, $lightembed]

Returns a new or existing adobe core font object.

Examples:

$font = $pdf->corefont('Times-Roman',1);
$font = $pdf->corefont('Times-Bold');
$font = $pdf->corefont('Helvetica',1);
$font = $pdf->corefont('ZapfDingbats');
$font = $pdf->psfont $pfbfile,$afmfile

Returns a new or existing adobe type1 font object.

Examples:

$font = $pdf->psfont('Times-Book.pfb','Times-Book.afm');
$font = $pdf->psfont('/fonts/Synest-FB.pfb','/fonts/Synest-FB.afm');
$font = $pdf->psfont('../Highland-URW.pfb','../Highland-URW.afm');
$font = $pdf->ttfont $ttfile

Returns a new or existing truetype font object.

Examples:

$font = $pdf->ttfont('TimesNewRoman.ttf');
$font = $pdf->ttfont('/fonts/Univers-Bold.ttf');
$font = $pdf->ttfont('../Democratica-SmallCaps.ttf');
$img = $pdf->image $file

Returns a new image object from a file or a GD::Image object.

Examples:

$img = $pdf->image('yetanotherfun.jpg');
$img = $pdf->image('truly24bitpic.png');
$img = $pdf->image('reallargefile.pnm');

$gdimgobj=GD::Image->newFromPng('truly24bitpic.png');
$img = $pdf->image($gdimgobj);

Important Note:

As of version 0.2.3.4 the development of the PNG import methods has been discontinued in favor of the GD::Image import facility.

$img = $pdf->pdfimage $file, $page_number

Returns a new image object, which is actually a page from another pdf.

Examples:

$img = $pdf->pdfimage('test1.pdf',1);
$img = $pdf->pdfimage('another-test.pdf',2);
$img = $pdf->pdfimage('really-large.pdf',1000);
$img = $pdf->pdfimageobj $pdfobj, $page_number

As $pdf->pdfimage, but takes an already opened pdfobject (API2->open) as parameter.

Note: This is functionally the same as the one above, but far less resource-intensive, if you use many pages (possible the same) from one single pdf.

$shadeing = $pdf->shade

Returns a new shading object.

$pat = $pdf->pattern

Returns a new pattern object.

$cs = $pdf->colorspace %parameters

Returns a new colorspace object.

Examples:

$cs = $pdf->colorspace(
	-type => 'CalRGB',
	-whitepoint => [ 0.9, 1, 1.1 ],
	-blackpoint => [ 0, 0, 0 ],
	-gamma => [ 2.2, 2.2, 2.2 ],
	-matrix => [
		0.41238, 0.21259, 0.01929,
		0.35757, 0.71519, 0.11919,
		0.1805,  0.07217, 0.95049
	]
);

$cs = $pdf->colorspace(
	-type => 'CalGray',
	-whitepoint => [ 0.9, 1, 1.1 ],
	-blackpoint => [ 0, 0, 0 ],
	-gamma => 2.2
);

$cs = $pdf->colorspace(
	-type => 'Lab',
	-whitepoint => [ 0.9, 1, 1.1 ],
	-blackpoint => [ 0, 0, 0 ],
	-gamma => [ 2.2, 2.2, 2.2 ],
	-range => [ -100, 100, -100, 100 ]
);

$cs = $pdf->colorspace(
	-type => 'Indexed',
	-base => 'DeviceRGB',
	-maxindex => 3,
	-whitepoint => [ 0.9, 1, 1.1 ],
	-blackpoint => [ 0, 0, 0 ],
	-gamma => [ 2.2, 2.2, 2.2 ],
	-colors => [
		[ 0,0,0 ],	# black = 0
		[ 1,1,1 ],	# white = 1
		[ 1,0,0 ],	# red = 2
		[ 0,0,1 ],	# blue = 3
	]
);

$cs = $pdf->colorspace(
	-type => 'ICCBased',
	-base => 'DeviceRGB',
	-components => 3,
	-iccfile => 'codacus.icc'
);
$img = $pdf->barcode %options

Returns a new barcode object.

Note: refer to PDF::API2::Barcode for more details.

$otls = $pdf->outlines

Returns a new or existing outlines object.

$page->resource $type, $key, $obj, $force

Adds a resource to the global page-inheritance tree.

Example:

$pdf->resource('Font',$fontkey,$fontobj);
$pdf->resource('XObject',$imagekey,$imageobj);
$pdf->resource('Shading',$shadekey,$shadeobj);
$pdf->resource('ColorSpace',$spacekey,$speceobj);

Note: You only have to add the required resources, if they are NOT handled by the *font*, *image*, *shade* or *space* methods.

PDF::API2::Pattern

Subclassed from Text::PDF::Dict.

$otls = PDF::API2::Pattern->new

Returns a new pattern object (called from $pdf->pattern).

PDF::API2::Outlines

Subclassed from PDF::API2::Outline.

$otls = PDF::API2::Outlines->new $api

Returns a new outlines object (called from $pdf->outlines).

PDF::API2::Outline

Subclassed from Text::PDF::Dict.

$otl = PDF::API2::Outline->new $api,$parent,$prev

Returns a new outline object (called from $otls->outline).

$otl->title $text

Set the title of the outline.

$sotl=$otl->outline

Returns a new sub-outline.

$otl->dest $pageobj [, %opts]

Sets the destination page of the outline.

$otl->dest( $page, -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.

$otl->dest( $page, -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.

$otl->dest( $page, -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.

$otl->dest( $page, -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.

$otl->dest( $page, -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.

$otl->dest( $page, -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.

$otl->dest( $page, -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.

$otl->dest( $page, -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.

PDF::API2::ColorSpace

Subclassed from Text::PDF::Array.

$cs = PDF::API2::ColorSpace->new $pdf, $key, %parameters

Returns a new colorspace object (called from $pdf->colorspace).

PDF::API2::ExtGState

Subclassed from Text::PDF::Dict.

$egs = PDF::API2::ExtGState->new @parameters

Returns a new extgstate object (called from $pdf->extgstate).

$egs->strokeadjust $boolean
$egs->strokeoverprint $boolean
$egs->filloverprint $boolean
$egs->overprintmode $num
$egs->blackgeneration $obj
$egs->blackgeneration2 $obj
$egs->undercolorremoval $obj
$egs->undercolorremoval2 $obj
$egs->transfer $obj
$egs->transfer2 $obj
$egs->halftone $obj

PDF::API2::Font

$font2 = $font->clone $subkey

Returns a clone of a font object.

@glyphs = $font->glyphs $encoding

Returns an array with glyphnames of the specified encoding.

$font->encode $encoding

Changes the encoding of the font object. If you want more than one encoding for one font use 'clone' and then 'encode'.

Note: The following encodings are supported (as of version 0.1.16_beta):

adobe-standard adobe-symbol adobe-zapf-dingbats
cp1250 cp1251 cp1252
cp437 cp850
es es2 pt pt2
iso-8859-1 iso-8859-2 latin1 latin2
koi8-r koi8-u
macintosh
microsoft-dingbats

Note: Other encodings must be seperately installed via the pdf-api2-unimaps archive.

$pdfstring = $font->text $text

Returns a properly formated string-representation of $text for use in the PDF.

$wd = $font->width $text

Returns the width of $text as if it were at size 1.

@widths = $font->width_array $text

Returns the widths of the words in $text as if they were at size 1.

PDF::API2::CoreFont

Subclassed from Text::PDF::AFont and PDF::API2::Font.

$font = PDF::API2::CoreFont->new @parameters

Returns a adobe core font object (called from $pdf->corefont).

PDF::API2::PSFont

Subclassed from Text::PDF::AFont and PDF::API2::Font.

$font = PDF::API2::PSFont->new @parameters

Returns a adobe type1 font object (called from $pdf->psfont).

PDF::API2::TTFont

Subclassed from Text::PDF::TTFont0 and PDF::API2::Font.

$font = PDF::API2::TTFont->new $pdf,$ttffile,$pdfname

Returns a truetype font object (called from $pdf->ttfont).

$pdfstring = $font->text $text

Returns a properly formated string-representation of $text for use in the PDF.

$pdfstring = $font->text_utf8 $text

Returns a properly formated string-representation of $text for use in the PDF but requires $text to be in UTF8.

$wd = $font->width $text

Returns the width of $text as if it were at size 1.

@widths = $font->width_array $text

Returns the widths of the words in $text as if they were at size 1.

$wd = $font->width_utf8 $text

Returns the width of $text as if it were at size 1, but requires $text to be in UTF8.

($llx,$lly,$urx,$ury) = $font->bbox $text

Returns the texts bounding-box as if it were at size 1.

($llx,$lly,$urx,$ury) = $font->bbox_utf8 $utf8text

Returns the texts bounding-box as if it were at size 1.

$font->encode $encoding

Changes the encoding of the font object. Since encodings are one virtual in ::API2 for truetype fonts you DONT have to use 'clone'.

PDF::API2::Page

Subclassed from Text::PDF::Pages

$page = PDF::API2::Page->new $pdf, $parent, $index

Returns a page object (called from $pdf->page).

$page = PDF::API2::Page->coerce $pdf, $pdfpage

Returns a page object converted from $pdfpage (called from $pdf->openpage).

$page->update

Marks a page to be updated (by $pdf->update).

$page->mediabox $w, $h
$page->mediabox $llx, $lly, $urx, $ury
$page->mediabox $alias

Sets the mediabox. This method supports the following aliases: '4A', '2A', 'A0', 'A1', 'A2', 'A3', 'A4', 'A5', 'A6', '4B', '2B', 'B0', 'B1', 'B2', 'B3', 'B4', 'B5', 'B6', 'LETTER', 'BROADSHEET', 'LEDGER', 'TABLOID', 'LEGAL', 'EXECUTIVE', and '36X36'.

$page->cropbox $w, $h
$page->cropbox $llx, $lly, $urx, $ury
$page->cropbox $alias

Sets the cropbox. This method supports the same aliases as mediabox.

$page->bleedbox $w, $h
$page->bleedbox $llx, $lly, $urx, $ury
$page->bleedbox $alias

Sets the bleedbox. This method supports the same aliases as mediabox.

$page->trimbox $w, $h
$page->trimbox $llx, $lly, $urx, $ury

Sets the trimbox. This method supports the same aliases as mediabox.

$page->artbox $w, $h
$page->artbox $llx, $lly, $urx, $ury
$page->artbox $alias

Sets the artbox. This method supports the same aliases as mediabox.

$gfx = $page->gfx

Returns a graphics content object.

$txt = $page->text

Returns a text content object.

$hyb = $page->hybrid

Returns a hybrid content object.

$ant = $page->annotation

Returns a annotation object.

$page->resource $type, $key, $obj

Adds a resource to the page-inheritance tree.

Example:

$co->resource('Font',$fontkey,$fontobj);
$co->resource('XObject',$imagekey,$imageobj);
$co->resource('Shading',$shadekey,$shadeobj);
$co->resource('ColorSpace',$spacekey,$speceobj);

Note: You only have to add the required resources, if they are NOT handled by the *font*, *image*, *shade* or *space* methods.

PDF::API2::Annotation

Subclassed from Text::PDF::Dict.

$ant = PDF::API2::Annotation->new

Returns a annotation object (called from $page->annotation).

Defines the annotation as launch-page with page $page and options %opts (-rect, -border or 'dest-options').

$ant->url $url, %opts

Defines the annotation as launch-url with url $url and options %opts (-rect and/or -border).

$ant->file $file, %opts

Defines the annotation as launch-file with filepath $file and options %opts (-rect and/or -border).

$ant->text $text, %opts

Defines the annotation as textnote with content $text and options %opts (-rect and/or -open).

$ant->rect $llx, $lly, $urx, $ury

Sets the rectangle of the annotation.

$ant->border @b

Sets the border-styles of the annotation, if applicable.

$ant->content @lines

Sets the text-content of the annotation, if applicable.

$ant->open $bool

Display the annotation either open or closed, if applicable.

$ant->dest( $page, -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.

$ant->dest( $page, -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.

$ant->dest( $page, -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.

$ant->dest( $page, -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.

$ant->dest( $page, -fitb => 1 )

(PDF 1.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.

$ant->dest( $page, -fitbh => $top )

(PDF 1.1) 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.

$ant->dest( $page, -fitbv => $left )

(PDF 1.1) 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.

$ant->dest( $page, -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.

PDF::API2::Content

Subclassed from Text::PDF::Dict.

$co = PDF::API2::Content->new @parameters

Returns a new content object (called from $page->text/gfx).

$co->add @content

Adds @content to the object.

$co->save

Saves the state of the object.

$co->restore

Restores the state of the object.

$co->compress

Marks content for compression on output.

$co->fillcolor $grey
$co->fillcolor $api2colorobject
$co->fillcolor $red, $green, $blue
$co->fillcolor $cyan, $magenta, $yellow, $black
$co->fillcolorbyname $colorname, $ascmyk
$co->fillcolorbyspace $colorspace, @colordef

Sets fillcolor.

$co->strokecolor $grey
$co->strokecolor $api2colorobject
$co->strokecolor $red, $green, $blue
$co->strokecolor $cyan, $magenta, $yellow, $black
$co->strokecolorbyname $colorname, $ascmyk
$co->strokecolorbyspace $colorspace, @colordef

Sets strokecolor.

Defined color-names are:

aliceblue, antiquewhite, aqua, aquamarine, azure,
beige, bisque, black, blanchedalmond, blue,
blueviolet, brown, burlywood, cadetblue, chartreuse,
chocolate, coral, cornflowerblue, cornsilk, crimson,
cyan, darkblue, darkcyan, darkgoldenrod, darkgray,
darkgreen, darkgrey, darkkhaki, darkmagenta,
darkolivegreen, darkorange, darkorchid, darkred,
darksalmon, darkseagreen, darkslateblue, darkslategray,
darkslategrey, darkturquoise, darkviolet, deeppink,
deepskyblue, dimgray, dimgrey, dodgerblue, firebrick,
floralwhite, forestgreen, fuchsia, gainsboro, ghostwhite,
gold, goldenrod, gray, grey, green, greenyellow,
honeydew, hotpink, indianred, indigo, ivory, khaki,
lavender, lavenderblush, lawngreen, lemonchiffon,
lightblue, lightcoral, lightcyan, lightgoldenrodyellow,
lightgray, lightgreen, lightgrey, lightpink, lightsalmon,
lightseagreen, lightskyblue, lightslategray,
lightslategrey, lightsteelblue, lightyellow, lime,
limegreen, linen, magenta, maroon, mediumaquamarine,
mediumblue, mediumorchid, mediumpurple, mediumseagreen,
mediumslateblue, mediumspringgreen, mediumturquoise,
mediumvioletred, midnightblue, mintcream, mistyrose,
moccasin, navajowhite, navy, oldlace, olive, olivedrab,
orange, orangered, orchid, palegoldenrod, palegreen,
paleturquoise, palevioletred, papayawhip, peachpuff,
peru, pink, plum, powderblue, purple, red, rosybrown,
royalblue, saddlebrown, salmon, sandybrown, seagreen,
seashell, sienna, silver, skyblue, slateblue, slategray,
slategrey, snow, springgreen, steelblue, tan, teal,
thistle, tomato, turquoise, violet, wheat, white,
whitesmoke, yellow, yellowgreen

or the rgb-hex-notation:

#rgb, #rrggbb, #rrrgggbbb and #rrrrggggbbbb

or the cmyk-hex-notation:

%cmyk, %ccmmyykk, %cccmmmyyykkk and %ccccmmmmyyyykkkk

and additionally the hsv-hex-notation:

!hsv, !hhssvv, !hhhsssvvv and !hhhhssssvvvv
$co->flatness $flat

Sets flatness.

$co->linecap $cap

Sets linecap.

$co->linedash @dash

Sets linedash.

$co->linejoin $join

Sets linejoin.

$co->linewidth $width

Sets linewidth.

$co->meterlimit $limit

Sets meterlimit.

$co->matrix $a,$b,$c,$d,$e,$f

Sets matrix transformation.

$co->translate $x,$y

Sets translation transformation.

$co->scale $sx,$sy

Sets scaleing transformation.

$co->skew $sa,$sb

Sets skew transformation.

$co->rotate $rot

Sets rotation transformation.

$co->transform %opts

Sets transformations (eg. translate, rotate, scale, skew) in pdf-canonical order.

Example:

$co->transform(
	-translate => [$x,$y],
	-rotate    => $rot,
	-scale     => [$sx,$sy],
	-skew      => [$sa,$sb],
)
$co->resource $type, $key, $obj

Adds a resource to the page-inheritance tree.

Example:

$co->resource('Font',$fontkey,$fontobj);
$co->resource('XObject',$imagekey,$imageobj);
$co->resource('Shading',$shadekey,$shadeobj);
$co->resource('ColorSpace',$spacekey,$speceobj);

Note: You only have to add the required resources, if they are NOT handled by the *font*, *image*, *shade* or *space* methods.

PDF::API2::Gfx

Subclassed from PDF::API2::Content.

$gfx = PDF::API2::Gfx->new @parameters

Returns a new graphics content object (called from $page->gfx).

$gfx->matrix $a, $b, $c, $d, $e, $f

Sets the matrix.

$gfx->move $x, $y
$gfx->line $x, $y
$gfx->hline $x
$gfx->vline $y
$gfx->curve $x1, $y1, $x2, $y2, $x3, $y3
$gfx->arc $x, $y, $a, $b, $alfa, $beta, $move
$gfx->ellipse $x, $y, $a, $b
$gfx->circle $x, $y, $r
$gfx->bogen $x1, $y1, $x2, $y2, $r, $move, $larc, $span
$gfx->pie $x, $y, $a, $b, $alfa, $beta
$gfx->pie3d $x, $y, $a, $b, $alfa, $beta, $thickness [, $sides]
$gfx->rect $x1,$y1, $w1,$h1, ..., $xn,$yn, $wn,$hn
$gfx->rectxy $x1,$y1, $x2,$y2
$gfx->poly $x1,$y1, ..., $xn,$yn
$gfx->close
$gfx->endpath
$gfx->clip $nonzero
$gfx->stroke
$gfx->fill $nonzero
$gfx->fillstroke $nonzero
$gfx->image $imgobj, $x,$y, $w,$h
$gfx->image $imgobj, $x,$y, $scale
$gfx->image $imgobj, $x,$y

Please Note: The width/height or scale given is in user-space coordinates which is subject to transformations which may have been specified beforehand.

Per default this has a 72dpi resolution, so if you want an image to have a 150 or 300dpi resolution, you should specify a scale of 72/150 (or 72/300) or adjust width/height accordingly.

$gfx->pdfimage $imgobj, $x, $y, $sx, $sy
$gfx->pdfimage $imgobj, $x, $y, $scale
$gfx->pdfimage $imgobj, $x, $y

Please Note: *TODO*

$gfx->barcode $barcodeobj, $center_x, $center_y, $scale [,$frame]
$gfx->barcode_inline $barcodeobj, $center_x, $center_y, $scale [,$frame]
$gfx->shade $shadeobj, $x1,$y1, $x2,$y2
$gfx->egstate $egsobj

PDF::API2::Text

Subclassed from PDF::API2::Content.

$txt = PDF::API2::Text->new @parameters

Returns a new text content object (called from $page->text).

%state = $txt->textstate %state

Sets or gets the current text-object state.

($tx,$ty) = $txt->textpos

Gets the current estimated text position.

$txt->matrix $a, $b, $c, $d, $e, $f

Sets the matrix.

PLEASE NOTE: This method is not expected to be called by the user and else will 'die'. This was implemented to keep proper state in the text-object, so please use transform, transform_rel, translate, scale, skew or rotate instead.

$txt->transform_rel %opts

Sets transformations (eg. translate, rotate, scale, skew) in pdf-canonical order, but relative to the previously set values.

Example:

$txt->transform_rel(
	-translate => [$x,$y],
	-rotate    => $rot,
	-scale     => [$sx,$sy],
	-skew      => [$sa,$sb],
)
$txt->font $fontobj,$size
$spacing = $txt->charspace $spacing
$spacing = $txt->wordspace $spacing
$spacing = $txt->hspace $spacing
$leading = $txt->lead $leading
$rise = $txt->rise $rise
$rendering = $txt->render $rendering
$txt->cr $linesize

takes an optional argument giving a custom leading between lines.

$txt->nl
$txt->distance $dx,$dy
$width = $txt->advancewidth $string

Returns the width of the string based on all currently set text-attributes.

$width = $txt->text $string

Applys text to the content and optionally returns the width of the given text.

$txt->text_center $string
$txt->text_right $string
($flowwidth, $overflow) = $txt->text_justify $width, $string [, -overflow => 1 ] [, -underflow => 1 ]

If -overflow is given, $overflow will contain any text, which wont fit into width without exessive scaling and $flowwidth will be 0.

If -underflow is given, and $text is smaller than $width, $flowwidth will contain the delta between $width and the text-advancewidth AND text will typeset using $txt->text.

$txt->text_utf8 $utf8string
$txt->textln $string1, ..., $stringn

Example:

$txt->lead(-10);
$txt->textln($line1,$line2,$line3);
$txt->paragraph $x, $y, $width, $heigth, $indent, @text

PDF::API2::Hybrid

Subclassed from PDF::API2::Gfx+Text+Content.

$hyb = PDF::API2::Hybrid->new @parameters

Returns a new hybrid content object (called from $page->hybrid).

$hyb->matrix $a, $b, $c, $d, $e, $f

Sets the matrix.

$hyb->textstart
$hyb->textend

PDF::API2::PdfImage

Subclassed from PDF::API2::Hybrid.

$wd = $img->width
$ht = $img->height

PDF::API2::Barcode

Subclassed from PDF::API2::Hybrid.

$bc = PDF::API2::Barcode->new $pdfkey, %options

Returns a new barcode object (called from $pdf->barcode).

Example:

PDF::API2::Barcode->new(
	$key,
	-font	=> $fontobj,	# the font to use for text
	-type	=> '3of9',	# the type of barcode
	-code	=> '0123456789', # the code of the barcode
	-extn	=> '012345',	# the extension of the barcode
				# (if applicable)
	-umzn	=> 10,		# (u)pper (m)ending (z)o(n)e
	-lmzn	=> 10,		# (l)ower (m)ending (z)o(n)e
	-zone	=> 50,		# height (zone) of bars
	-quzn	=> 10,		# (qu)iet (z)o(n)e
	-ofwt	=> 0.01,	# (o)ver(f)low (w)id(t)h
	-fnsz	=> 10,		# (f)o(n)t(s)i(z)e
	-text	=> 'alternative text'
);

Note: There is currently only support for the following barcodes:

3of9, 3of9ext, 3of9chk, 3of9extchk,
code128a, code128b, code128c, ean128,
ean13
$wd = $bc->width
$ht = $bc->height

PDF::API2::Image

$img = PDF::API2::Image->new $pdf, $imgfile

Returns a new image object (called from $pdf->image).

$wd = $img->width
$ht = $img->height

AUTHOR

alfred reibenschuh

36 POD Errors

The following errors were encountered while parsing the POD:

Around line 61:

'=item' outside of any '=over'

Around line 1162:

You forgot a '=back' before '=head2'

Around line 1166:

'=item' outside of any '=over'

Around line 1210:

You forgot a '=back' before '=head2'

Around line 1214:

'=item' outside of any '=over'

Around line 1260:

You forgot a '=back' before '=head2'

Around line 1507:

'=item' outside of any '=over'

Around line 1659:

You forgot a '=back' before '=head2'

Around line 1663:

'=item' outside of any '=over'

Around line 1879:

You forgot a '=back' before '=head2'

Around line 1881:

'=item' outside of any '=over'

Around line 2044:

You forgot a '=back' before '=head2'

Around line 2048:

'=item' outside of any '=over'

Around line 2130:

You forgot a '=back' before '=head2'

Around line 2134:

'=item' outside of any '=over'

Around line 2190:

You forgot a '=back' before '=head2'

Around line 2194:

'=item' outside of any '=over'

Around line 2472:

You forgot a '=back' before '=head2'

Around line 2476:

'=item' outside of any '=over'

Around line 2892:

You forgot a '=back' before '=head2'

Around line 2896:

'=item' outside of any '=over'

Around line 3157:

You forgot a '=back' before '=head2'

Around line 3161:

'=item' outside of any '=over'

Around line 3669:

You forgot a '=back' before '=head2'

Around line 3673:

'=item' outside of any '=over'

Around line 4289:

You forgot a '=back' before '=head2'

Around line 4293:

'=item' outside of any '=over'

Around line 4887:

You forgot a '=back' before '=head2'

Around line 4891:

'=item' outside of any '=over'

Around line 5025:

You forgot a '=back' before '=head2'

Around line 5039:

'=item' outside of any '=over'

Around line 5638:

You forgot a '=back' before '=head2'

Around line 5642:

'=item' outside of any '=over'

Around line 5875:

You forgot a '=back' before '=head2'

Around line 5877:

'=item' outside of any '=over'

Around line 6544:

You forgot a '=back' before '=head1'