setasign\Fpdi\Tcpdf

Fpdi Class Fpdi

File: /FPDI v2/Tcpdf/Fpdi.php

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

Class hierarchy

Uses

Summary

Constants

VERSION

const setasign\Fpdi\Tcpdf\Fpdi::VERSION = '2.1.0'

FPDI version


Properties

$currentObjectNumber

protected int Fpdi::$currentObjectNumber

The currently used object number.

$currentReaderId

The current reader id.

$importedPages

protected array \setasign\Fpdi\FpdiTrait::$importedPages = array()

Data of all imported pages.

$objectMap

protected array \setasign\Fpdi\FpdiTrait::$objectMap = array()

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

$objectsToCopy

protected array \setasign\Fpdi\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 Fpdi::$templateId = 0

A counter for template ids.


Methods

_getxobjectdict()

protected Fpdi::_getxobjectdict (
void
): void

_newobj()

protected 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 Fpdi::_put (
string $s [, bool $newLine = true ]
): void

Append content to the buffer of TCPDF.

Parameters
$s : string
 
$newLine : bool
 

getImportedPageSize()

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

Get the size of an imported page.

Omit 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 Fpdi::getNextTemplateId (
void
): int

Get the next template id.

getPdfParserInstance()

protected \setasign\Fpdi\FpdiTrait::getPdfParserInstance (): \setasign\Fpdi\PdfParser\PdfParser|\setasign\FpdiPdfParser\PdfParser\PdfParser

Get a new pdf parser instance.

Parameters
$streamReader : \setasign\Fpdi\PdfParser\StreamReader
 

getPdfReader()

Get a pdf reader instance by its id.

Parameters
$id : string
 

getPdfReaderId()

Get an unique reader id by the $file parameter.

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

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

getTemplateSize()

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

Get the size of an imported page.

Omit 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 \setasign\Fpdi\FpdiTrait::importPage (
int $pageNumber [, string $box = setasign\Fpdi\PdfReader\PageBoundaries::CROP_BOX [, bool $groupXObject = true ]]
): 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).

Return Values

A unique string identifying the imported page.

Exceptions

Throws \setasign\Fpdi\PdfParser\CrossReference\CrossReferenceException

Throws \setasign\Fpdi\PdfParser\Filter\FilterException

Throws \setasign\Fpdi\PdfParser\PdfParserException

Throws \setasign\Fpdi\PdfParser\Type\PdfTypeException

Throws \setasign\Fpdi\PdfReader\PdfReaderException

See
  • PageBoundaries

setMinPdfVersion()

protected \setasign\Fpdi\FpdiTrait::setMinPdfVersion (
string $pdfVersion
): void

Set the minimal PDF version.

Parameters
$pdfVersion : string
 

setSourceFile()

Set the source PDF file.

Parameters
$file : string|resource|\setasign\Fpdi\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 \setasign\Fpdi\PdfParser\PdfParserException

useImportedPage()

public 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.

Omit 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 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.

Omit 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

writePdfType()

Writes a PdfType object to the resulting buffer.

Parameters
$value : \setasign\Fpdi\PdfParser\Type\PdfType
 
Exceptions

Throws \setasign\Fpdi\PdfParser\Type\PdfTypeException