FPDI Class FPDI
File: /FPDI v1/fpdi.php
Class hierarchy
Summary
Methods
- AddLink()
- AddPage()
- Image()
- Link()
- SetFont()
- SetLink()
- _closeParsers()
- _enddoc()
- _getPdfParser()
- _newobj()
- _out()
- _putformxobjects()
- _putimages()
- _putimportedobjects()
- _putxobjectdict()
- _straightOut()
- _writeValue()
- beginTemplate()
- cleanUp()
- endTemplate()
- getLastUsedPageBox()
- getPdfVersion()
- getTemplateSize()
- importPage()
- setPdfVersion()
- setSourceFile()
- useTemplate()
Constants
VERSION
Properties
$_currentObjId
Current Object Id.
$_doneObjStack
Done object stack
$_objStack
Object stack
$currentFilename
Actual filename
$currentParser
Current parser
$lastUsedPageBox
The name of the last imported page box
$tplPrefix
Name prefix of templates used in Resources dictionary
A String defining the Prefix used as Template-Object-Names. Have to begin with an /
Methods
AddLink()
Creates a new internal link and returns its identifier.
Overwritten because adding links in a template will not work.
See
AddPage()
Adds a new page to the document.
See FPDF/TCPDF documentation.
This method cannot be used if you'd started a template.
Parameters
- $orientation
- $format
- $rotationOrKeepmargins
- $tocpage
See
Image()
Puts an image.
See FPDF/TCPDF documentation.
Parameters
- $file
- $x
- $y
- $w
- $h
- $type
- $link
- $align
- $resize
- $dpi
- $palign
- $ismask
- $imgmask
- $border
- $fitbox
- $hidden
- $fitonpage
- $alt
- $altimgs
See
Link()
Puts a link on a rectangular area of the page.
Overwritten because adding links in a template will not work.
Parameters
- $x
- $y
- $w
- $h
- $link
- $spaces
See
SetFont()
SetLink()
Defines the page and position a link points to.
Overwritten because adding links in a template will not work.
Parameters
- $link
- $y
- $page
See
_putimages()
Output images.
Overwritten to add _putformxobjects() after _putimages().
_putxobjectdict()
Writes the references of XObject resources to the document.
Overwritten to add the the templates to the XObject resource dictionary.
_straightOut()
Modified _out() method so not each call will add a newline to the output.
Parameters
- $s
_writeValue()
Writes a PDF value to the resulting document.
Needed to rebuild the source document
Parameters
- $value : mixed
A PDF-Value. Structure of values see cases in this method
beginTemplate()
Start a template.
This method starts a template. You can give own coordinates to build an own sized template. Pay attention, that the margins are adapted to the new template size. If you want to write outside the template, for example to build a clipped template, you have to set the margins and "cursor"-position manual after beginTemplate()-call.
If no parameter is given, the template uses the current page-size. The method returns an id of the current template. This id is used later for using this template. Warning: A created template is saved in the resulting PDF at all events. Also if you don't use it after creation!
Parameters
- $x : int
The x-coordinate given in user-unit
- $y : int
The y-coordinate given in user-unit
- $w : int
The width given in user-unit
- $h : int
The height given in user-unit
Return Values
The id of new created template
Exceptions
Throws LogicException
endTemplate()
End template.
This method ends a template and reset initiated variables collected in beginTemplate().
Return Values
If a template is opened, the id is returned. If not a false is returned.
getLastUsedPageBox()
Returns the last used page boundary box.
Return Values
The used boundary box: MediaBox, CropBox, BleedBox, TrimBox or ArtBox
getTemplateSize()
Get the calculated size of a template.
If one size is given, this method calculates the other one.
Parameters
- $tplIdx : int
A valid template-id
- $w : int
The width of the template
- $h : int
The height of the template
Return Values
The height and width of the template (array('w' => ..., 'h' => ...))
importPage()
Import a page.
The second parameter defines the bounding box that should be used to transform the page into a form XObject.
Following values are available: MediaBox, CropBox, BleedBox, TrimBox, ArtBox. If a box is not especially defined its default box will be used:
- CropBox: Default -> MediaBox
- BleedBox: Default -> CropBox
- TrimBox: Default -> CropBox
- ArtBox: Default -> CropBox
It is possible to get the used page box by the getLastUsedPageBox() method.
Parameters
- $pageNo : int
The page number
- $boxName : string
The boundary box to use when transforming the page into a form XObject
- $groupXObject : boolean
Define the form XObject as a group XObject to support transparency (if used)
Return Values
An id of the imported page/template to use with e.g. fpdf_tpl::useTemplate()
Exceptions
Throws LogicException,InvalidArgumentException
See
setSourceFile()
Set a source-file.
Depending on the PDF version of the used document the PDF version of the resulting document will be adjusted to the higher version.
Parameters
- $filename : string
A valid path to the PDF document from which pages should be imported from
Return Values
The number of pages in the document
Exceptions
Throws Exception
useTemplate()
Use a template or imported page in current page or other template.
You can use a template in a page or in another template. You can give the used template a new size. All parameters are optional. The width or height is calculated automatically if one is given. If no parameter is given the origin size as defined in beginTemplate() or of the imported page is used.
The calculated or used width and height are returned as an array.
Parameters
- $tplIdx : int
A valid template-id
- $x : int
The x-position
- $y : int
The y-position
- $w : int
The new width of the template
- $h : int
The new height of the template
- $adjustPageSize : boolean
If set to true the current page will be resized to fit the dimensions of the template
Return Values
The height and width of the template (array('w' => ..., 'h' => ...))