Text::PDF::API - a wrapper api for the Text::PDF::* modules of Martin Hosken.
use Text::PDF::API;
$pdf = Text::PDF::API->new( %defaults );
$pdf->end;
This creates a new pdf-object initializes it with the given defaults and returns it. See the functions getDefault and setDefault for a list of supported parameters.
This saves the pdf-object to a file indicated by $file.
This destroys the pdf-object and frees its memory.
This returns the pdf-object default indicated by $parameter.
The current supported defaults are:
PageSize, valid values:
'a0' => [ 2380 , 3368 ] 'a1' => [ 1684 , 2380 ] 'a2' => [ 1190 , 1684 ] 'a3' => [ 842 , 1190 ] 'a4' => [ 595 , 842 ] 'a5' => [ 421 , 595 ] 'a6' => [ 297 , 421 ] 'letter' => [ 612 , 792 ] 'broadsheet' => [ 1296 , 1584 ] 'ledger' => [ 1224 , 792 ] 'tabloid' => [ 792 , 1224 ] 'legal' => [ 612 , 1008 ] 'executive' => [ 522 , 756 ] '36x36' => [ 2592 , 2592 ]
PageWidth, valid values:
0 .. 32535 points (remember default = 72dpi) PageHeight, valid values:
0 .. 32535 points (remember default = 72dpi)
PageOrientation, valid values: Landscape, Portrait
Compression
0, 1 (= off, on)
PDFVersion
0 .. 3 (corresponding to the adobe acrobat versions up to 4.0)
This sets the pdf-object defaults (see $pdf->getDefault for details).
This creates a new page in the pdf-object and assigns it to the default
page context. If $width
and $height
are not given
the funtion falls back to any given defaults (PageSize then
PageWidth+PageHeight) and as a last resort to 'A4'. You can use also
specify oonly the Pagesize as given under the defaults.
This closes the current page.
Saves and restores the state of the pdf-document BUT NOT of the pdf-object.
BEWARE: Don't cross page boundaries with save/restore, if you really don't know the pdf-specification well enough.
Saves and restores the state of the pdf-object and the underlying document.
NOTE: All states are automagically restored if you issue a $pdf->endpage.
Sets the default font search directory.
Gets the default font search directory.
Adds a directory to the font search path.
Adds a new font to the pdf-object. Based on the fonts name either a core, truetype or postscript font is assumed: TrueType have a ',' between the family and style names whereas the postscript and core fonts use a '-'.
BEWARE: Postscript fonts other than the core fonts are supported, BUT the implementation is still somewhere in alpha/beta stage and may not result in valid pdf-files under certain conditions.
NOTE: this function is for BACKWARD COMPATIBLITY ONLY (as of version 0.5) and will be removed sometime before version 1.0.
RECOMMENDATION: Start using the following three functions below.
Although you can add a font thru the $pdf->newFont function, these three new functions are much more stable (newFontPS is alpha-quality) and reliable.
The $encoding
is the name of one of the encoding schemes
supported by Unicode::Map8, 'asis' or 'custom'. If you use 'custom' as
encoding, you have to supply the @glyphs
array which should
specify 256 glyph-names as defined by the ``PostScript(R) Language
Reference 3rd. Ed. -- Appendix E''
If you do not give $encoding
or 'asis', than the afms internal
encoding is used.
If you give an unknown $encoding, the encoding defaults to WinAnsiEncoding.
This is a shortcut to add all pdf-core-fonts to the pdf-object.
This selects the font at the specified size and encoding. The font must
have been loaded with the same $name
parameter with
$pdf->newFont
If you do not give $encoding, than the encoding from $pdf->newFont??? is used.
NOTE: As of version API 0.5 you can specify any encoding supported by Unicode::Map8, since the fonts are automagically reencoded to use the new encoding if it differs from that encoding specified at $pdf->newFont???.
Sets the translation (aka. x,y-offset) in the Font-Transformation-Matrices.
Sets the scale in the Font-Transformation-Matrices.
Sets the skew in the Font-Transformation-Matrices specified in degrees (0..360).
Sets the rotation in the Font-Transformation-Matrices specified in degrees (0..360) counter-clock-wise from the right horizontal.
Resets all Font-Transformation-Matrices.
Calculates the final Transformation-Matrix for use with the *Text* functions.
Sets the final Transformation-Matrix directly.
Returns the final Transformation-Matrix. Use $pdf->calcFontMatrix and then $pdf->getFontMatrix to retrive the combined effects of Translate, Skew, Scale & Rotate.
Displays the $text
based on the parameters given by the *Font*
functions.
Like $pdf->showText but overrides the x,y-offsets of the Matrices. The
*_R
and *_C
variants perform right and center
alignment !
Like a $pdf->useFont followed by a $pdf->showTextXY.
Calculates the width of the text based on the parameters set by useFont.
BEWARE: Does not consider parameters specified by setFont* and *Matrix
functions.
These functions behave like the the font functions BUT affect the whole global graphics state.
BEWARE: If you use both the Gfx and Font versions of these functions the final result for Text would be the combined effects of both the Gfx and Font parameters.
Adds the parameters of the functions above to the current graphics state. To revert to the former parameters use $pdf->savePdfState and $pdf->restorePdfState.
quot errat demonstrandum
Current loading support includes NetPBM images of the RAW_BITS variation and non-interlaced/non-filtered PNG. Transperancy/Opacity information is currently ignored as well as Alpha-Channel information.
This function supports loading of point-arrays for embedding image
information into the pdf. $type
must be one of the following:
'-rgb' ... each element of the array is a color component in the range of 0..255 '-RGB' ... each element of the array is a hex-encoded color pixel with two hex-digits per color component
$name
must be a unique name for this image (at least 8
characters long).
GENESIS
inital implementation without documentation
you can create pages, still no docs
various conceptual design stages
first public snapshot with some docs and first implementation of font caching (released as 0.01_12_snapshot)
reimplementaion of font-handling with unification of core and truetype fonts under the function ``newFont''
implementaion of font-encoding for truetypes
reimplementaion of font-encoding thru CID because Acrobat seems to ignore encoding tables for TTs when using normal embedding
implementaion of printText, useFont, showText & showTextXY
implementaion of *FontMatrix
functions, changes in showText
& showTextXY
addition of setFontTranslate, Skew, Rotate & Scale with cleanup in
*FontMatrix
end of text/font implementation, let it stabilize :)
genesis of the graphical interface (CTM handling copied from fonts)
added text and graphic state functions
cleanup/extension of dokumentation, but still not finished
proposed implementation of drawing functions (NOT FINISHED)
finished implemetation of needed drawing functions
bugfixes in drawing and font functions first implementation of state functions
first implementation of bitmap functions
bugfixes in text/font functions
added support for loading of PNM(netpbm)
and PNG bitmaps
added circle and ellipsis drawing functions
fixed calcTextWidth to allow the type1 core fonts to be measured too. added showTextXY_R and _C functions for alignment procedures :)
rewrite of type1 core-font handling to ease development support for other type1 fonts in future releases of Text::PDF and Text::PDF::API.
small bugfixes in calcTextWidth and showTextXY_[RC].
small documentation update
major rewrite to use Unicode::Map8 instead of the homegrown functions :) , add another dependency but at least a fast one
major rewrite of font-handling routines stalls the tutorial/exaples collection. now adobe-type1 fonts (pfb/pfa + afm) and the core-fonts can be used the same way as truetype with the Unicode::Map8 encodings.
documetaion update and release of the much hacked 0.5_pre??? code :)
MANY! If you find some report them to perl-text-pdf-modules@egroups.com.
documentation ?
drawing functions ?
more encodings ?
fix encoding for core fonts ?
bitmap import functions (jpeg,xbm,xpm, ...?)