classes-Com-Tecnick-Pdf-Tcpdf

It appears that you are using AdBlocking software. The cost of running this website is covered by advertisements. If you like it please feel free to a small amount of money to secure the future of this website.

Tcpdf extends ClassObjects

in package

Com\Tecnick\Pdf\Tcpdf

Tcpdf PDF class

Tags
since
2002-08-03
category

Library

author

Nicola Asuni info@tecnick.com

copyright

2002-2024 Nicola Asuni - Tecnick.com LTD

license

http://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE.TXT)

link
https://github.com/tecnickcom/tc-lib-pdf
phpstan-import-type

StyleDataOpt from \Com\Tecnick\Pdf\Graph\Base

phpstan-import-type

PageData from \Com\Tecnick\Pdf\Page\Box

phpstan-import-type

PageInputData from \Com\Tecnick\Pdf\Page\Box

phpstan-import-type

TFontMetric from \Com\Tecnick\Pdf\Font\Stack

phpstan-import-type

TAnnotOpts from Output

phpstan-import-type

TSignature from Output

phpstan-import-type

TSignTimeStamp from Output

phpstan-import-type

TGTransparency from Output

phpstan-import-type

TUserRights from Output

phpstan-import-type

TXOBject from Output

SuppressWarnings

(PHPMD.DepthOfInheritance)

Table of Contents

Constants

BORDERPOS_DEFAULT  = 0
The default relative position of the cell origin when the border is centered on the cell edge.
BORDERPOS_EXTERNAL  = -0.5
The relative position of the cell origin when the border is external to the cell edge.
BORDERPOS_INTERNAL  = 0.5
The relative position of the cell origin when the border is internal to the cell edge.
ZEROCELL  = ['margin' => ['T' => 0, 'R' => 0, 'B' => 0, 'L' => 0], 'padding' => ['T' => 0, 'R' => 0, 'B' => 0, 'L' => 0], 'borderpos' => self::BORDERPOS_DEFAULT]
Default values for cell.

Properties

$barcode  : Barcode
Barcode object.
$cache  : Cache
Cache object.
$color  : Pdf
Color object.
$encrypt  : Encrypt
Encrypt object.
$file  : File
File object.
$font  : Stack
Font object.
$graph  : Draw
Graph object.
$image  : Import
Image Import object.
$page  : Page
Page object.
$pon  : int
Current PDF object number.
$uniconv  : Convert
Unicode Convert object.

Methods

__construct()  : mixed
Initialize a new PDF object.
addEmptySignatureAppearance()  : void
Add an empty digital signature appearance (a cliccable rectangle area to get signature properties).
addInternalLink()  : string
Defines the page and vertical position an internal link points to.
addPage()  : PageData
Add a new page (wrapper function for $this->page->add()).
addTextCell()  : void
Adds a text block inside a rectangular cell.
addTOC()  : void
Add a Table of Contents (TOC) to the document.
addXObjectContent()  : void
Add the specified raw PDF content to the XObject template.
addXObjectExtGStateID()  : void
Add the specified ExtGState ID to the XObject template.
addXObjectFontID()  : void
Add the specified Font ID to the XObject template.
addXObjectGradientID()  : void
Add the specified Gradient ID to the XObject template.
addXObjectImageID()  : void
Add the specified Image ID to the XObject template.
addXObjectSpotColorID()  : void
Add the specified SpotColor ID to the XObject template.
addXObjectXObjectID()  : void
Add the specified XObject ID to the XObject template.
closeLayer()  : string
defaultPageContent()  : string
Sets the page common content like Header and Footer.
downloadPDF()  : void
Trigger the browser Download dialog to download the PDF document.
enableDefaultPageContent()  : void
Enable or disable the default page content.
enableZeroWidthBreakPoints()  : void
Enable or disable automatic line breaking points after some non-letter character types.
exitXObjectTemplate()  : void
Exit from the XObject template mode.
getBarcode()  : string
Get a barcode PDF code.
getLastBBox()  : TBBox
Returns the last text bounding box [llx, lly, urx, ury].
getMIMEAttachmentPDF()  : string
Returns the PDF as base64 mime multi-part email attachment (RFC 2045).
getOutPDFString()  : string
Returns the RAW PDF string.
getTextCell()  : string
Returns the PDF code to render a text block inside a rectangular cell.
getTextLine()  : string
Returns the PDF code to render a single line of text.
getVersion()  : string
Return the program version.
getXObjectTemplate()  : string
Returns the PDF code to render the specified XObject template.
initClassObjects()  : void
Initialize dependencies class objects.
loadTexHyphenPatterns()  : array<string, string>
Returns an array of hyphenation patterns.
newLayer()  : string
Creates and return a new PDF Layer.
newXObjectTemplate()  : string
Create a new XObject template and return the object id.
renderPDF()  : void
Render the PDF in the browser or output the RAW data in the CLI.
savePDF()  : void
Save the PDF document to a local file.
setAnnotation()  : int
Add an annotation and returns the object id.
setAuthor()  : static
Defines the author of the document.
setBookmark()  : void
Add a bookmark entry.
setCreator()  : static
Defines the creator of the document.
setDefaultCellBorderPos()  : void
Sets the default cell border position.
setDefaultCellMargin()  : void
Set the default cell margin in user units.
setDefaultCellPadding()  : void
Set the default cell padding in user units.
setDisplayMode()  : static
Defines the way the document is to be displayed by the viewer.
setExtraXMP()  : static
Set additional XMP data to be appended just before the end of "x:xmpmeta" tag.
setExtraXMPRDF()  : static
Set additional XMP data to be appended just before the end of "rdf:RDF" tag.
setKeywords()  : static
Associates keywords with the document, generally in the form 'keyword1 keyword2 ...'.
setLink()  : int
Creates a link in the specified area.
setNamedDestination()  : string
Add a named destination.
setPDFFilename()  : void
Set the pdf document base file name.
setPDFVersion()  : static
Set the PDF version (check PDF reference for valid values).
setPointToPixelRatio()  : void
Set the pixel/point ratio used to convert pixel values to points.
setRTL()  : static
Set the default document language direction.
setSignature()  : void
Enable document signature (requires the OpenSSL Library).
setSignatureAppearance()  : void
Set the digital signature appearance (a cliccable rectangle area to get signature properties).
setSignTimeStamp()  : void
Set the signature timestamp.
setSpaceRegexp()  : void
Set regular expression to detect withespaces or word separators.
setSRGB()  : static
Set the sRGB mode
setSubject()  : static
Defines the subject of the document.
setTexHyphenPatterns()  : void
Sets the hyphen patterns for text.
setTitle()  : static
Defines the title of the document.
setUserRights()  : void
Set User's Rights for the PDF Reader.
setViewerPreferences()  : static
Set the viewer preferences dictionary controlling the way the document is to be presented on the screen or in print.
toPoints()  : float
Convert user units to internal points unit.
toUnit()  : float
Convert internal points to user unit.
toYPoints()  : float
Convert vertical user value to internal points unit.
toYUnit()  : float
Convert vertical internal points value to user unit.

Constants

BORDERPOS_DEFAULT

The default relative position of the cell origin when the border is centered on the cell edge.

public mixed BORDERPOS_DEFAULT = 0

BORDERPOS_EXTERNAL

The relative position of the cell origin when the border is external to the cell edge.

public mixed BORDERPOS_EXTERNAL = -0.5

BORDERPOS_INTERNAL

The relative position of the cell origin when the border is internal to the cell edge.

public mixed BORDERPOS_INTERNAL = 0.5

ZEROCELL

Default values for cell.

public mixed ZEROCELL = ['margin' => ['T' => 0, 'R' => 0, 'B' => 0, 'L' => 0], 'padding' => ['T' => 0, 'R' => 0, 'B' => 0, 'L' => 0], 'borderpos' => self::BORDERPOS_DEFAULT]
Tags
const

TCellDef

Properties

$barcode

Barcode object.

public Barcode $barcode

$cache

Cache object.

public Cache $cache

$color

Color object.

public Pdf $color

$encrypt

Encrypt object.

public Encrypt $encrypt

$file

File object.

public File $file

$font

Font object.

public Stack $font

$graph

Graph object.

public Draw $graph

$image

Image Import object.

public Import $image

$page

Page object.

public Page $page

$pon

Current PDF object number.

public int $pon = 0

$uniconv

Unicode Convert object.

public Convert $uniconv

Methods

__construct()

Initialize a new PDF object.

public __construct([string $unit = 'mm' ][, bool $isunicode = true ][, bool $subsetfont = false ][, bool $compress = true ][, string $mode = '' ][, Encrypt|null $objEncrypt = null ]) : mixed
Parameters
$unit : string = 'mm'

Unit of measure ('pt', 'mm', 'cm', 'in').

$isunicode : bool = true

True if the document is in Unicode mode.

$subsetfont : bool = false

If true subset the embedded fonts to remove the unused characters.

$compress : bool = true

Set to false to disable stream compression.

$mode : string = ''

PDF mode: "pdfa1", "pdfa2", "pdfa3", "pdfx" or empty.

$objEncrypt : Encrypt|null = null

Encryption object.

addEmptySignatureAppearance()

Add an empty digital signature appearance (a cliccable rectangle area to get signature properties).

public addEmptySignatureAppearance([float $posx = 0 ][, float $posy = 0 ][, float $width = 0 ][, float $heigth = 0 ][, int $page = -1 ][, string $name = '' ]) : void
Parameters
$posx : float = 0

Abscissa of the upper-left corner.

$posy : float = 0

Ordinate of the upper-left corner.

$width : float = 0

Width of the signature area.

$heigth : float = 0

Height of the signature area.

$page : int = -1

option page number (if < 0 the current page is used).

$name : string = ''

Name of the signature.

Defines the page and vertical position an internal link points to.

public addInternalLink([int $page = -1 ][, float $posy = 0 ]) : string
Parameters
$page : int = -1

Page number.

$posy : float = 0

Vertical position.

Return values
string

Internal link identifier to be used with setLink().

addPage()

Add a new page (wrapper function for $this->page->add()).

public addPage([PageInputData $data = [] ]) : PageData
Parameters
$data : PageInputData = []

Page data.

Return values
PageData

Page data with additional Page ID property 'pid'.

addTextCell()

Adds a text block inside a rectangular cell.

public addTextCell(string $txt[, int $pid = -1 ][, float $posx = 0 ][, float $posy = 0 ][, float $width = 0 ][, float $height = 0 ][, float $offset = 0 ][, float $linespace = 0 ][, string $valign = 'T' ][, string $halign = '' ][, TCellDef|null $cell = null ][, array<int, StyleDataOpt$styles = [] ][, float $strokewidth = 0 ][, float $wordspacing = 0 ][, float $leading = 0 ][, float $rise = 0 ][, bool $jlast = true ][, bool $fill = true ][, bool $stroke = false ][, bool $underline = false ][, bool $linethrough = false ][, bool $overline = false ][, bool $clip = false ][, bool $drawcell = true ][, string $forcedir = '' ][, TextShadow|null $shadow = null ]) : void

Accounts for automatic line, page and region breaks.

Parameters
$txt : string

Text string to be processed.

$pid : int = -1

Page index. Omit or set it to -1 for the current page ID.

$posx : float = 0

Abscissa of upper-left corner relative to the region origin X coordinate.

$posy : float = 0

Ordinate of upper-left corner relative to the region origin Y coordinate.

$width : float = 0

Width.

$height : float = 0

Height.

$offset : float = 0

Horizontal offset to apply to the line start.

$linespace : float = 0

Additional space to add between lines.

$valign : string = 'T'

Text vertical alignment inside the cell: T=top; C=center; B=bottom.

$halign : string = ''

Text horizontal alignment inside the cell: L=left; C=center; R=right; J=justify.

$cell : TCellDef|null = null

Optional to overwrite cell parameters for padding, margin etc.

$styles : array<int, StyleDataOpt> = []

Cell border styles (see: getCurrentStyleArray).

$strokewidth : float = 0

Stroke width.

$wordspacing : float = 0

Word spacing (use it only when justify == false).

$leading : float = 0

Leading.

$rise : float = 0

Text rise.

$jlast : bool = true

If true does not justify the last line when $halign == J.

$fill : bool = true

If true fills the text.

$stroke : bool = false

If true stroke the text.

$underline : bool = false

If true underline the text.

$linethrough : bool = false

If true line through the text.

$overline : bool = false

If true overline the text.

$clip : bool = false

If true activate clipping mode.

$drawcell : bool = true

If true draw the cell border.

$forcedir : string = ''

If 'R' forces RTL, if 'L' forces LTR.

$shadow : TextShadow|null = null

Text shadow parameters.

addTOC()

Add a Table of Contents (TOC) to the document.

public addTOC([int $page = -1 ][, float $posx = 0 ][, float $posy = 0 ][, float $width = 0 ][, bool $rtl = false ][, StyleDataOpt $linestyle = ['lineWidth' => 0.3, 'lineCap' => 'butt', 'lineJoin' => 'miter', 'dashArray' => [1, 1], 'dashPhase' => 0, 'lineColor' => 'gray', 'fillColor' => ''] ]) : void

The bookmars are created via the setBookmark() method.

Parameters
$page : int = -1

Page number.

$posx : float = 0

Abscissa of the upper-left corner.

$posy : float = 0

Ordinate of the upper-left corner.

$width : float = 0

Width of the signature area.

$rtl : bool = false

Right-To-Left - If true prints the TOC in RTL mode.

$linestyle : StyleDataOpt = ['lineWidth' => 0.3, 'lineCap' => 'butt', 'lineJoin' => 'miter', 'dashArray' => [1, 1], 'dashPhase' => 0, 'lineColor' => 'gray', 'fillColor' => '']

Line style for the space filler.

addXObjectContent()

Add the specified raw PDF content to the XObject template.

public addXObjectContent(string $tid, string $data) : void
Parameters
$tid : string

The XObject Template object as returned by the newXObjectTemplate method.

$data : string

The raw PDF content data to add.

addXObjectExtGStateID()

Add the specified ExtGState ID to the XObject template.

public addXObjectExtGStateID(string $tid, int $key) : void
Parameters
$tid : string

The XObject Template object as returned by the newXObjectTemplate method.

$key : int

The ExtGState key to add.

addXObjectFontID()

Add the specified Font ID to the XObject template.

public addXObjectFontID(string $tid, string $key) : void
Parameters
$tid : string

The XObject Template object as returned by the newXObjectTemplate method.

$key : string

The Font key to add.

addXObjectGradientID()

Add the specified Gradient ID to the XObject template.

public addXObjectGradientID(string $tid, int $key) : void
Parameters
$tid : string

The XObject Template object as returned by the newXObjectTemplate method.

$key : int

The Gradient key to add.

addXObjectImageID()

Add the specified Image ID to the XObject template.

public addXObjectImageID(string $tid, int $key) : void
Parameters
$tid : string

The XObject Template object as returned by the newXObjectTemplate method.

$key : int

TheImage key to add.

addXObjectSpotColorID()

Add the specified SpotColor ID to the XObject template.

public addXObjectSpotColorID(string $tid, string $key) : void
Parameters
$tid : string

The XObject Template object as returned by the newXObjectTemplate method.

$key : string

The SpotColor key to add.

addXObjectXObjectID()

Add the specified XObject ID to the XObject template.

public addXObjectXObjectID(string $tid, string $key) : void
Parameters
$tid : string

The XObject Template object as returned by the newXObjectTemplate method.

$key : string

The XObject key to add.

closeLayer()

public closeLayer() : string
Return values
string

defaultPageContent()

Sets the page common content like Header and Footer.

public defaultPageContent([int $pid = -1 ]) : string

Override this method to add custom content to all pages.

Parameters
$pid : int = -1

Page index. Omit or set it to -1 for the current page ID.

Return values
string

PDF output code.

downloadPDF()

Trigger the browser Download dialog to download the PDF document.

public downloadPDF([string $rawpdf = '' ]) : void
Parameters
$rawpdf : string = ''

Raw PDF data string from getOutPDFString().

Tags
throws
Exception

in case of error.

enableDefaultPageContent()

Enable or disable the default page content.

public enableDefaultPageContent([bool $enable = true ]) : void
Parameters
$enable : bool = true

Enable or disable the default page content.

enableZeroWidthBreakPoints()

Enable or disable automatic line breaking points after some non-letter character types.

public enableZeroWidthBreakPoints(bool $enabled) : void
Parameters
$enabled : bool

exitXObjectTemplate()

Exit from the XObject template mode.

public exitXObjectTemplate() : void

See: newXObjectTemplate.

getBarcode()

Get a barcode PDF code.

public getBarcode(string $type, string $code[, float $posx = 0 ][, float $posy = 0 ][, int $width = -1 ][, int $height = -1 ][, array{: int, : int, : int, : int} $padding = [0, 0, 0, 0] ][, StyleDataOpt $style = [] ]) : string
Parameters
$type : string

Barcode type.

$code : string

Barcode content.

$posx : float = 0

Abscissa of upper-left corner.

$posy : float = 0

Ordinate of upper-left corner.

$width : int = -1

Barcode width in user units (excluding padding). A negative value indicates the multiplication factor for each column.

$height : int = -1

Barcode height in user units (excluding padding). A negative value indicates the multiplication factor for each row.

$padding : array{: int, : int, : int, : int} = [0, 0, 0, 0]

Additional padding to add around the barcode (top, right, bottom, left) in user units. A negative value indicates the multiplication factor for each row or column.

$style : StyleDataOpt = []

Array of style options.

Tags
throws
Exception

in case of error

Return values
string

getLastBBox()

Returns the last text bounding box [llx, lly, urx, ury].

public getLastBBox() : TBBox
Return values
TBBox

Array of bounding box values.

getMIMEAttachmentPDF()

Returns the PDF as base64 mime multi-part email attachment (RFC 2045).

public getMIMEAttachmentPDF([string $rawpdf = '' ]) : string
Parameters
$rawpdf : string = ''

Raw PDF data string from getOutPDFString().

Return values
string

Email attachment as raw string.

getOutPDFString()

Returns the RAW PDF string.

public getOutPDFString() : string
Return values
string

getTextCell()

Returns the PDF code to render a text block inside a rectangular cell.

public getTextCell(string $txt[, float $posx = 0 ][, float $posy = 0 ][, float $width = 0 ][, float $height = 0 ][, float $offset = 0 ][, float $linespace = 0 ][, string $valign = 'C' ][, string $halign = 'C' ][, TCellDef|null $cell = null ][, array<int, StyleDataOpt$styles = [] ][, float $strokewidth = 0 ][, float $wordspacing = 0 ][, float $leading = 0 ][, float $rise = 0 ][, bool $jlast = true ][, bool $fill = true ][, bool $stroke = false ][, bool $underline = false ][, bool $linethrough = false ][, bool $overline = false ][, bool $clip = false ][, bool $drawcell = true ][, string $forcedir = '' ][, TextShadow|null $shadow = null ]) : string
Parameters
$txt : string

Text string to be processed.

$posx : float = 0

Abscissa of upper-left corner.

$posy : float = 0

Ordinate of upper-left corner.

$width : float = 0

Width.

$height : float = 0

Height.

$offset : float = 0

Horizontal offset to apply to the line start.

$linespace : float = 0

Additional space to add between lines.

$valign : string = 'C'

Text vertical alignment inside the cell: T=top; C=center; B=bottom.

$halign : string = 'C'

Text horizontal alignment inside the cell: L=left; C=center; R=right; J=justify.

$cell : TCellDef|null = null

Optional to overwrite cell parameters for padding, margin etc.

$styles : array<int, StyleDataOpt> = []

Cell border styles (see: getCurrentStyleArray).

$strokewidth : float = 0

Stroke width.

$wordspacing : float = 0

Word spacing (use it only when justify == false).

$leading : float = 0

Leading.

$rise : float = 0

Text rise.

$jlast : bool = true

If true does not justify the last line when $halign == J.

$fill : bool = true

If true fills the text.

$stroke : bool = false

If true stroke the text.

$underline : bool = false

If true underline the text.

$linethrough : bool = false

If true line through the text.

$overline : bool = false

If true overline the text.

$clip : bool = false

If true activate clipping mode.

$drawcell : bool = true

If true draw the cell border.

$forcedir : string = ''

If 'R' forces RTL, if 'L' forces LTR.

$shadow : TextShadow|null = null

Text shadow parameters.

Return values
string

getTextLine()

Returns the PDF code to render a single line of text.

public getTextLine(string $txt[, float $posx = 0 ][, float $posy = 0 ][, float $width = 0 ][, float $strokewidth = 0 ][, float $wordspacing = 0 ][, float $leading = 0 ][, float $rise = 0 ][, bool $fill = true ][, bool $stroke = false ][, bool $underline = false ][, bool $linethrough = false ][, bool $overline = false ][, bool $clip = false ][, string $forcedir = '' ][, TextShadow|null $shadow = null ]) : string
Parameters
$txt : string

Text string to be processed.

$posx : float = 0

X position relative to the start of the current line.

$posy : float = 0

Y position relative to the start of the current line (font baseline).

$width : float = 0

Desired string width to force justification via word spacing (0 = automatic).

$strokewidth : float = 0

Stroke width.

$wordspacing : float = 0

Word spacing (use it only when width == 0).

$leading : float = 0

Leading.

$rise : float = 0

Text rise.

$fill : bool = true

If true fills the text.

$stroke : bool = false

If true stroke the text.

$underline : bool = false

If true underline the text.

$linethrough : bool = false

If true line through the text.

$overline : bool = false

If true overline the text.

$clip : bool = false

If true activate clipping mode.

$forcedir : string = ''

If 'R' forces RTL, if 'L' forces LTR.

$shadow : TextShadow|null = null

Text shadow parameters.

Return values
string

getVersion()

Return the program version.

public getVersion() : string
Return values
string

getXObjectTemplate()

Returns the PDF code to render the specified XObject template.

public getXObjectTemplate(string $tid[, float $posx = 0 ][, float $posy = 0 ][, float $width = 0 ][, float $height = 0 ][, string $valign = 'T' ][, string $halign = 'L' ]) : string

See: newXObjectTemplate.

Parameters
$tid : string

The XObject Template object as returned by the newXObjectTemplate method.

$posx : float = 0

Abscissa of upper-left corner.

$posy : float = 0

Ordinate of upper-left corner.

$width : float = 0

Width.

$height : float = 0

Height.

$valign : string = 'T'

Vertical alignment inside the specified box: T=top; C=center; B=bottom.

$halign : string = 'L'

Horizontal alignment inside the specified box: L=left; C=center; R=right.

Return values
string

The PDF code to render the specified XObject template.

initClassObjects()

Initialize dependencies class objects.

public initClassObjects([Encrypt|null $objEncrypt = null ]) : void
Parameters
$objEncrypt : Encrypt|null = null

Encryption object.

loadTexHyphenPatterns()

Returns an array of hyphenation patterns.

public loadTexHyphenPatterns(string $file) : array<string, string>
Parameters
$file : string

TEX file containing hypenation patterns. TEX patterns can be downloaded from https://www.ctan.org/tex-archive/language/hyph-utf8/tex/generic/hyph-utf8/patterns/tex See https://www.ctan.org/tex-archive/language/hyph-utf8/ for more information.

Return values
array<string, string>

Array of hyphenation patterns.

newLayer()

Creates and return a new PDF Layer.

public newLayer([string $name = '' ][, array{view?: bool, design?: bool} $intent = [] ][, bool $print = true ][, bool $view = true ][, bool $lock = true ]) : string
Parameters
$name : string = ''

Layer name (only a-z letters and numbers). Leave empty for automatic name.

$intent : array{view?: bool, design?: bool} = []

intended use of the graphics in the layer.

$print : bool = true

Set the printability of the layer.

$view : bool = true

Set the visibility of the layer.

$lock : bool = true

Set the lock state of the layer.

Return values
string

newXObjectTemplate()

Create a new XObject template and return the object id.

public newXObjectTemplate([float $width = 0 ][, float $heigth = 0 ][, TGTransparency|null $transpgroup = null ]) : string

An XObject Template is a PDF block that is a self-contained description of any sequence of graphics objects (including path objects, text objects, and sampled images). An XObject Template may be painted multiple times, either on several pages or at several locations on the same page and produces the same results each time, subject only to the graphics state at the time it is invoked.

Parameters
$width : float = 0

Width of the XObject.

$heigth : float = 0

Height of the XObject.

$transpgroup : TGTransparency|null = null

Optional group attributes.

Return values
string

XObject template object ID.

renderPDF()

Render the PDF in the browser or output the RAW data in the CLI.

public renderPDF([string $rawpdf = '' ]) : void
Parameters
$rawpdf : string = ''

Raw PDF data string from getOutPDFString().

Tags
throws
Exception

in case of error.

savePDF()

Save the PDF document to a local file.

public savePDF([string $path = '' ][, string $rawpdf = '' ]) : void
Parameters
$path : string = ''

Path to the output file.

$rawpdf : string = ''

Raw PDF data string from getOutPDFString().

setAnnotation()

Add an annotation and returns the object id.

public setAnnotation(float $posx, float $posy, float $width, float $height, string $txt[, TAnnotOpts $opt = ['subtype' => 'text'] ]) : int
Parameters
$posx : float

Abscissa of upper-left corner.

$posy : float

Ordinate of upper-left corner.

$width : float

Width.

$height : float

Height.

$txt : string

Annotation text or alternate content.

$opt : TAnnotOpts = ['subtype' => 'text']

Array of options (Annotation Types) - all lowercase.

Return values
int

Object ID.

setAuthor()

Defines the author of the document.

public setAuthor(string $author) : static
Parameters
$author : string

The name of the author.

Return values
static

setBookmark()

Add a bookmark entry.

public setBookmark(string $name[, string $link = '' ][, int $level = 0 ][, int $page = -1 ][, float $posx = 0 ][, float $posy = 0 ][, string $fstyle = '' ][, string $color = '' ]) : void
Parameters
$name : string

Bookmark description that will be printed in the TOC.

$link : string = ''

(Optional) URL to open when the link is clicked or an identifier returned by addInternalLink(). A single character prefix may be used to specify the link action:

  • '#' = internal destination
  • '%' = embedded PDF file
  • '*' = embedded generic file
$level : int = 0

Bookmark level (minimum 0).

$page : int = -1

Page number.

$posx : float = 0

Abscissa of upper-left corner.

$posy : float = 0

Ordinate of upper-left corner.

$fstyle : string = ''

Font style. Possible values are (case insensitive):

  • regular (default)
  • B: bold
  • I: italic
  • U: underline
  • D: strikeout (linethrough)
  • O: overline
$color : string = ''

Color name.

setCreator()

Defines the creator of the document.

public setCreator(string $creator) : static

This is typically the name of the application that generates the PDF.

Parameters
$creator : string

The name of the creator.

Return values
static

setDefaultCellBorderPos()

Sets the default cell border position.

public setDefaultCellBorderPos(float $borderpos) : void
Parameters
$borderpos : float

The border position to set: BORDERPOS_DEFAULT BORDERPOS_EXTERNAL BORDERPOS_INTERNAL

setDefaultCellMargin()

Set the default cell margin in user units.

public setDefaultCellMargin(float $top, float $right, float $bottom, float $left) : void
Parameters
$top : float

Top.

$right : float

Right.

$bottom : float

Bottom.

$left : float

Left.

setDefaultCellPadding()

Set the default cell padding in user units.

public setDefaultCellPadding(float $top, float $right, float $bottom, float $left) : void
Parameters
$top : float

Top.

$right : float

Right.

$bottom : float

Bottom.

$left : float

Left.

setDisplayMode()

Defines the way the document is to be displayed by the viewer.

public setDisplayMode([int|string $zoom = 'default' ][, string $layout = 'SinglePage' ][, string $mode = 'UseNone' ]) : static
Parameters
$zoom : int|string = 'default'

The zoom to use. It can be one of the following string values or a number indicating the zooming factor to use.

  • fullpage: displays the entire page on screen * fullwidth: uses maximum width of window
  • real: uses real size (equivalent to 100% zoom) * default: uses viewer default mode
$layout : string = 'SinglePage'

The page layout. Possible values are:

  • SinglePage Display one page at a time
  • OneColumn Display the pages in one column
  • TwoColumnLeft Display the pages in two columns, with odd-numbered pages on the left
  • TwoColumnRight Display the pages in two columns, with odd-numbered pages on the right
  • TwoPageLeft Display the pages two at a time, with odd-numbered pages on the left
  • TwoPageRight Display the pages two at a time, with odd-numbered pages on the right
$mode : string = 'UseNone'

A name object specifying how the document should be displayed when opened:

  • UseNone Neither document outline nor thumbnail images visible
  • UseOutlines Document outline visible
  • UseThumbs Thumbnail images visible
  • FullScreen Full screen, with no menu bar, window controls, or any other window visible
  • UseOC (PDF 1.5) Optional content group panel visible
  • UseAttachments (PDF 1.6) Attachments panel visible
Return values
static

setExtraXMP()

Set additional XMP data to be appended just before the end of "x:xmpmeta" tag.

public setExtraXMP(string $xmp) : static

IMPORTANT: This data is added as-is without controls, so you have to validate your data before using this method.

Parameters
$xmp : string

Custom XMP data.

Return values
static

setExtraXMPRDF()

Set additional XMP data to be appended just before the end of "rdf:RDF" tag.

public setExtraXMPRDF(string $xmp) : static

IMPORTANT: This data is added as-is without controls, so you have to validate your data before using this method.

Parameters
$xmp : string

Custom XMP data.

Return values
static

setKeywords()

Associates keywords with the document, generally in the form 'keyword1 keyword2 ...'.

public setKeywords(string $keywords) : static
Parameters
$keywords : string

Space-separated list of keywords.

Return values
static

Creates a link in the specified area.

public setLink(float $posx, float $posy, float $width, float $height, string $link) : int

A link annotation represents either a hypertext link to a destination elsewhere in the document.

Parameters
$posx : float

Abscissa of upper-left corner.

$posy : float

Ordinate of upper-left corner.

$width : float

Width.

$height : float

Height.

$link : string

URL to open when the link is clicked or an identifier returned by addInternalLink(). A single character prefix may be used to specify the link action:

  • '#' = internal destination
  • '%' = embedded PDF file
  • '*' = embedded generic file
Return values
int

Object ID (Add to a page via: $pdf->page->addAnnotRef($aoid);).

setNamedDestination()

Add a named destination.

public setNamedDestination(string $name[, int $page = -1 ][, float $posx = 0 ][, float $posy = 0 ]) : string
Parameters
$name : string

Named destination (must be unique).

$page : int = -1

Page number.

$posx : float = 0

Abscissa of upper-left corner.

$posy : float = 0

Ordinate of upper-left corner.

Return values
string

Destination name.

setPDFFilename()

Set the pdf document base file name.

public setPDFFilename(string $name) : void

If the file extension is present, it must be '.pdf' or '.PDF'.

Parameters
$name : string

File name.

setPDFVersion()

Set the PDF version (check PDF reference for valid values).

public setPDFVersion([string $version = '1.7' ]) : static
Parameters
$version : string = '1.7'

PDF document version.

Tags
throws
Exception

in case of error.

Return values
static

setPointToPixelRatio()

Set the pixel/point ratio used to convert pixel values to points.

public setPointToPixelRatio(float $val) : void
Parameters
$val : float

setRTL()

Set the default document language direction.

public setRTL(bool $enabled) : static
Parameters
$enabled : bool

False = LTR = Left-To-Right; True = RTL = Right-To-Left.

Return values
static

setSignature()

Enable document signature (requires the OpenSSL Library).

public setSignature(TSignature $data) : void

The digital signature improve document authenticity and integrity and allows to enable extra features on PDF Reader.

To create self-signed signature: openssl req -x509 -nodes -days 365000 -newkey rsa:1024 -keyout tcpdf.crt -out tcpdf.crt To export crt to p12: openssl pkcs12 -export -in tcpdf.crt -out tcpdf.p12 To convert pfx certificate to pem: openssl pkcs12 -in tcpdf.pfx -out tcpdf.crt -nodes

Parameters
$data : TSignature

Signature data:

  • appearance (array) Signature appearance.
    • empty (bool) Array of empty signatures:
      • objid (int) Object id.
      • name (string) Name of the signature field.
      • page (int) Page number.
      • rect (array) Rectangle of the signature field.
    • name (string) Name of the signature field.
    • page (int) Page number.
    • rect (array) Rectangle of the signature field.
  • approval (bool) Enable approval signature eg. for PDF incremental update.
  • cert_type (int) The access permissions granted for this document. Valid values shall be: 1 = No changes to the document shall be permitted; any change to the document shall invalidate the signature; 2 = Permitted changes shall be filling in forms, instantiating page templates, and signing; other changes shall invalidate the signature; 3 = Permitted changes shall be the same as for 2, as well as annotation creation, deletion, and modification; other changes shall invalidate the signature.
  • extracerts (string) Specifies the name of a file containing a bunch of extra certificates to include in the signature which can for example be used to help the recipient to verify the certificate that you used.
  • info (array) Optional information.
    • ContactInfo (string)
    • Location (string)
    • Name (string)
    • Reason (string)
  • password (string)
  • privkey (string) Private key (string or filename prefixed with 'file://').
  • signcert (string) Signing certificate (string or filename prefixed with 'file://').

setSignatureAppearance()

Set the digital signature appearance (a cliccable rectangle area to get signature properties).

public setSignatureAppearance([float $posx = 0 ][, float $posy = 0 ][, float $width = 0 ][, float $heigth = 0 ][, int $page = -1 ][, string $name = '' ]) : void
Parameters
$posx : float = 0

Abscissa of the upper-left corner.

$posy : float = 0

Ordinate of the upper-left corner.

$width : float = 0

Width of the signature area.

$heigth : float = 0

Height of the signature area.

$page : int = -1

option page number (if < 0 the current page is used).

$name : string = ''

Name of the signature.

setSignTimeStamp()

Set the signature timestamp.

public setSignTimeStamp(TSignTimeStamp $data) : void
Parameters
$data : TSignTimeStamp

Signature timestamp data:

  • enabled (bool) If true enable timestamp signature.
  • host (string) Time Stamping Authority (TSA) server (prefixed with 'https://')
  • username (string) TSA username or authorization PEM file.
  • password (string) TSA password.
  • cert (string) cURL optional location of TSA certificate for authorization.

setSpaceRegexp()

Set regular expression to detect withespaces or word separators.

public setSpaceRegexp([string $regexp = '/[^\S\xa0]/' ]) : void

The pattern delimiter must be the forward-slash character "/". Some example patterns are:

Non-Unicode or missing PCRE unicode support: "/[^\S\xa0]/"
Unicode and PCRE unicode support: "/(?!\xa0)[\s\p{Z}]/u"
Unicode and PCRE unicode support in Chinese mode: "/(?!\xa0)[\s\p{Z}\p{Lo}]/u"
if PCRE unicode support is turned ON ("\P" is the negate class of "\p"):
     \s     : any whitespace character
     \p{Z}  : any separator
     \p{Lo} : Unicode letter or ideograph that does not have lowercase and uppercase variants.
     \xa0   : Unicode Character 'NO-BREAK SPACE' (U+00A0)
Parameters
$regexp : string = '/[^\S\xa0]/'

regular expression (leave empty for default).

setSRGB()

Set the sRGB mode

public setSRGB(bool $enabled) : static
Parameters
$enabled : bool

Set to true to add the default sRGB ICC color profile

Return values
static

setSubject()

Defines the subject of the document.

public setSubject(string $subject) : static
Parameters
$subject : string

The subject.

Return values
static

setTexHyphenPatterns()

Sets the hyphen patterns for text.

public setTexHyphenPatterns(array<string, string> $patterns) : void
Parameters
$patterns : array<string, string>

Array of hyphenation patterns.

Tags
see
loadTexHyphenPatterns()

setTitle()

Defines the title of the document.

public setTitle(string $title) : static
Parameters
$title : string

The title.

Return values
static

setUserRights()

Set User's Rights for the PDF Reader.

public setUserRights(TUserRights $rights) : void

WARNING: This is experimental and currently doesn't work because requires a private key. Check the PDF Reference 8.7.1 Transform Methods, Table 8.105 Entries in the UR transform parameters dictionary.

Parameters
$rights : TUserRights

User rights:

  • annots (string) Names specifying additional annotation-related usage rights for the document. Valid names in PDF 1.5 and later are /Create/Delete/Modify/Copy/Import/Export, which permit the user to perform the named operation on annotations.
  • document (string) Names specifying additional document-wide usage rights for the document. The only defined value is "/FullSave", which permits a user to save the document along with modified form and/or annotation data.
  • ef (string) Names specifying additional usage rights for named embedded files in the document. Valid names are /Create/Delete/Modify/Import, which permit the user to perform the named operation on named embedded files Names specifying additional embedded-files-related usage rights for the document.
  • enabled (bool) If true enable user's rights on PDF reader.
  • form (string) Names specifying additional form-field-related usage rights for the document. Valid names are: /Add/Delete/FillIn/Import/Export/SubmitStandalone/SpawnTemplate.
  • formex (string) Names specifying additional form-field-related usage rights. The only valid name is BarcodePlaintext, which permits text form field data to be encoded as a plaintext two-dimensional barcode.
  • signature (string) Names specifying additional signature-related usage rights for the document. The only defined value is /Modify, which permits a user to apply a digital signature to an existing signature form field or clear a signed signature form field.

setViewerPreferences()

Set the viewer preferences dictionary controlling the way the document is to be presented on the screen or in print.

public setViewerPreferences(TViewerPref $pref) : static
Parameters
$pref : TViewerPref

Array of options (see PDF reference "Viewer Preferences").

Return values
static

toPoints()

Convert user units to internal points unit.

public toPoints(float $usr) : float
Parameters
$usr : float

Value to convert.

Return values
float

toUnit()

Convert internal points to user unit.

public toUnit(float $pnt) : float
Parameters
$pnt : float

Value to convert in user units.

Return values
float

toYPoints()

Convert vertical user value to internal points unit.

public toYPoints(float $usr[, float $pageh = -1 ]) : float

Note: the internal Y points coordinate starts at the bottom left of the page.

Parameters
$usr : float

Value to convert.

$pageh : float = -1

Optional page height in internal points ($pageh:$this->page->getPage()['pheight']).

Return values
float

toYUnit()

Convert vertical internal points value to user unit.

public toYUnit(float $pnt[, float $pageh = -1 ]) : float

Note: the internal Y points coordinate starts at the bottom left of the page.

Parameters
$pnt : float

Value to convert.

$pageh : float = -1

Optional page height in internal points ($pageh:$this->page->getPage()['pheight']).

Return values
float
On this page
 

© 2004-2024 – Nicola Asuni - Tecnick.com - All rights reserved.
about - disclaimer - privacy