setasign\Fpdi

TcpdfFpdi Class TcpdfFpdi

File: /FPDI v2/TcpdfFpdi.php

WARNING: This class is marked as deprecated!

Class was moved to Tcpdf\Fpdi

This class let you import pages of existing PDF documents into a reusable structure for TCPDF.

Class hierarchy

Summary

Constants

VERSION

public const Tcpdf\Fpdi::VERSION = '2.6.0'

FPDI version


Properties

$createdReaders

protected array FpdiTrait::$createdReaders = array()

Instances created internally.

$currentObjectNumber

protected int|null Tcpdf\Fpdi::$currentObjectNumber

The currently used object number.

$currentReaderId

protected string|null FpdiTrait::$currentReaderId

The current reader id.

$importedPages

protected array FpdiTrait::$importedPages = array()

Data of all imported pages.

$objectMap

protected array FpdiTrait::$objectMap = array()

A map from object numbers of imported objects to new assigned object numbers by FPDF.

$objectsToCopy

protected array FpdiTrait::$objectsToCopy = array()

An array with information about objects, which needs to be copied to the resulting document.

$readers

The pdf reader instances.

$templateId

protected int Tcpdf\Fpdi::$templateId = 0

A counter for template ids.


Methods

_enddoc()

protected Tcpdf\Fpdi::_enddoc (
void
): void

_getxobjectdict()

protected Tcpdf\Fpdi::_getxobjectdict (
void
): string

_newobj()

protected Tcpdf\Fpdi::_newobj (
[ int|string $objid = '' ]
): int

Begin a new object and return the object number.

Parameters
$objid : int|string

Object ID (leave empty to get a new ID).

Return Values

object number

_put()

protected Tcpdf\Fpdi::_put (
string $s [, bool $newLine = true ]
): void

Append content to the buffer of TCPDF.

Parameters
$s : string
 
$newLine : bool
 

_putxobjects()

adjustLastLink()

protected Tcpdf\Fpdi::adjustLastLink (
array $externalLink, float|int $xPt, float|int $scaleX, float|int $yPt, float|int $newHeightPt, float|int $scaleY, array $importedPage
): void

This method will add additional data to the last created link/annotation.

It will copy styling properties (supported by TCPDF) of the imported link.

Parameters
$externalLink : array
 
$xPt : float|int
 
$scaleX : float|int
 
$yPt : float|int
 
$newHeightPt : float|int
 
$scaleY : float|int
 
$importedPage : array
 

cleanUp()

public FpdiTrait::cleanUp (
[ bool $allReaders = false ]
): void

Release resources and file handles.

This method is called internally when the document is created successfully. By default it only cleans up stream reader instances which were created internally.

Parameters
$allReaders : bool
 

fpdiUseImportedPage()

public FpdiTrait::fpdiUseImportedPage (
mixed $pageId [, float|int|array $x = 0 [, float|int $y = 0 [, float|int|null $width = null [, float|int|null $height = null [, bool $adjustPageSize = false ]]]]]
): array

Draws an imported page onto the page.

Give only one of the size parameters (width, height) to calculate the other one automatically in view to the aspect ratio.

Parameters
$pageId : mixed

The page id

$x : float|int|array

The abscissa of upper-left corner. Alternatively you could use an assoc array with the keys "x", "y", "width", "height", "adjustPageSize".

$y : float|int

The ordinate of upper-left corner.

$width : float|int|null

The width.

$height : float|int|null

The height.

$adjustPageSize : bool
 
Return Values

The size.

See

fpdiWritePdfType()

Writes a PdfType object to the resulting buffer.

Parameters
$value : PdfParser\Type\PdfType
 
Exceptions

Throws PdfParser\Type\PdfTypeException

getImportedPageSize()

public FpdiTrait::getImportedPageSize (
mixed $tpl [, float|int|null $width = null [, float|int|null $height = null ]]
): array|bool

Get the size of an imported page.

Give only one of the size parameters (width, height) to calculate the other one automatically in view to the aspect ratio.

Parameters
$tpl : mixed

The template id

$width : float|int|null

The width.

$height : float|int|null

The height.

Return Values

An array with following keys: width, height, 0 (=width), 1 (=height), orientation (L or P)

getNextTemplateId()

protected Tcpdf\Fpdi::getNextTemplateId (
void
): int

Get the next template id.

getPdfParserInstance()

protected FpdiTrait::getPdfParserInstance (
PdfParser\StreamReader $streamReader [, array $parserParams = array ( ) ]
): PdfParser\PdfParser|\setasign\FpdiPdfParser\PdfParser\PdfParser

Get a new pdf parser instance.

Parameters
$streamReader : PdfParser\StreamReader
 
$parserParams : array

Individual parameters passed to the parser instance.

getPdfReader()

protected FpdiTrait::getPdfReader (
string $id
): PdfReader\PdfReader

Get a pdf reader instance by its id.

Parameters
$id : string
 

getPdfReaderId()

protected FpdiTrait::getPdfReaderId (
string|resource|PdfReader\PdfReader|PdfParser\StreamReader $file [, array $parserParams = array ( ) ]
): string

Get an unique reader id by the $file parameter.

Parameters
$file : string|resource|PdfReader\PdfReader|PdfParser\StreamReader

An open file descriptor, a path to a file, a PdfReader instance or a StreamReader instance.

$parserParams : array

Individual parameters passed to the parser instance.

getTemplateSize()

public Tcpdf\Fpdi::getTemplateSize (
mixed $tpl [, float|int|null $width = null [, float|int|null $height = null ]]
): array|bool

Get the size of an imported page.

Give only one of the size parameters (width, height) to calculate the other one automatically in view to the aspect ratio.

Parameters
$tpl : mixed

The template id

$width : float|int|null

The width.

$height : float|int|null

The height.

Return Values

An array with following keys: width, height, 0 (=width), 1 (=height), orientation (L or P)

importPage()

public FpdiTrait::importPage (
int $pageNumber [, string $box = PdfReader\PageBoundaries::CROP_BOX [, bool $groupXObject = true [, bool $importExternalLinks = false ]]]
): string

Imports a page.

Parameters
$pageNumber : int

The page number.

$box : string

The page boundary to import. Default set to PageBoundaries::CROP_BOX.

$groupXObject : bool

Define the form XObject as a group XObject to support transparency (if used).

$importExternalLinks : bool

Define whether external links are imported or not.

Return Values

A unique string identifying the imported page.

Exceptions

Throws PdfParser\CrossReference\CrossReferenceException

Throws PdfParser\Filter\FilterException

Throws PdfParser\PdfParserException

Throws PdfParser\Type\PdfTypeException

Throws PdfReader\PdfReaderException

See
  • PageBoundaries

setMinPdfVersion()

protected FpdiTrait::setMinPdfVersion (
string $pdfVersion
): void

Set the minimal PDF version.

Parameters
$pdfVersion : string
 

setSourceFile()

public FpdiTrait::setSourceFile (
string|resource|PdfParser\StreamReader $file
): int

Set the source PDF file.

Parameters
$file : string|resource|PdfParser\StreamReader

Path to the file or a stream resource or a StreamReader instance.

Return Values

The page count of the PDF document.

Exceptions

Throws PdfParser\PdfParserException

setSourceFileWithParserParams()

public FpdiTrait::setSourceFileWithParserParams (
string|resource|PdfParser\StreamReader $file [, array $parserParams = array ( ) ]
): int

Set the source PDF file with parameters which are passed to the parser instance.

This method allows us to pass e.g. authentication information to the parser instance.

Parameters
$file : string|resource|PdfParser\StreamReader

Path to the file or a stream resource or a StreamReader instance.

$parserParams : array

Individual parameters passed to the parser instance.

Return Values

The page count of the PDF document.

Exceptions

Throws PdfParser\CrossReference\CrossReferenceException

Throws PdfParser\PdfParserException

Throws PdfParser\Type\PdfTypeException

useImportedPage()

public Tcpdf\Fpdi::useImportedPage (
mixed $pageId [, float|int|array $x = 0 [, float|int $y = 0 [, float|int|null $width = null [, float|int|null $height = null [, bool $adjustPageSize = false ]]]]]
): array

Draws an imported page onto the page.

Give only one of the size parameters (width, height) to calculate the other one automatically in view to the aspect ratio.

Parameters
$pageId : mixed

The page id

$x : float|int|array

The abscissa of upper-left corner. Alternatively you could use an assoc array with the keys "x", "y", "width", "height", "adjustPageSize".

$y : float|int

The ordinate of upper-left corner.

$width : float|int|null

The width.

$height : float|int|null

The height.

$adjustPageSize : bool
 
Return Values

The size.

See

useTemplate()

public Tcpdf\Fpdi::useTemplate (
mixed $tpl [, float|int|array $x = 0 [, float|int $y = 0 [, float|int|null $width = null [, float|int|null $height = null [, bool $adjustPageSize = false ]]]]]
): array

Draws an imported page onto the page or another template.

Give only one of the size parameters (width, height) to calculate the other one automatically in view to the aspect ratio.

Parameters
$tpl : mixed

The template id

$x : float|int|array

The abscissa of upper-left corner. Alternatively you could use an assoc array with the keys "x", "y", "width", "height", "adjustPageSize".

$y : float|int

The ordinate of upper-left corner.

$width : float|int|null

The width.

$height : float|int|null

The height.

$adjustPageSize : bool
 
Return Values

The size

See
  • \setasign\Fpdi\Tcpdf\FpdiTrait::getTemplateSize()

writePdfType()

protected Tcpdf\Fpdi::writePdfType (): void

Writes a PdfType object to the resulting buffer.

Parameters
$value : PdfParser\Type\PdfType
 
Exceptions

Throws PdfParser\Type\PdfTypeException