TCPDF_STATIC

class

TCPDF_STATIC Static methods used by the TCPDF class.

package

com.tecnick.tcpdf

brief

PHP class for generating PDF documents without requiring external extensions.

version 1.1.1
author

Nicola Asuni - info@tecnick.com

Methods

Returns the input text encrypted using AES algorithm and the specified key.

_AES(string $key,string $text): string
static

This method requires openssl or mcrypt. Text is padded to 16bytes blocks

author

Nicola Asuni

since 5.0.005

(2010-05-11)

public

static

Arguments

$key

string

encryption key

$text

string

input text to be encrypted

Response

string

encrypted text

Returns the input text encrypted using AES algorithm and the specified key.

_AESnopad(string $key,string $text): string
static

This method requires openssl or mcrypt. Text is not padded

author

Nicola Asuni

since

TODO

public

static

Arguments

$key

string

encryption key

$text

string

input text to be encrypted

Response

string

encrypted text

Add "\" before "\", "(" and ")"

_escape(string $s): string
static
public

static

Arguments

$s

string

string to escape.

Response

string

escaped string.

Escape some special characters (< > &) for XML output.

_escapeXML(string $str): string
static
since 5.9.121

(2011-09-28)

public

static

Arguments

$str

string

Input string to convert.

Response

string

converted string

Read a 4-byte (32 bit) integer from file.

_freadint(resource $f): integer
static
public

static

Arguments

$f

resource

file resource.

Response

integer

4-byte integer

Get BYTE from string (8-bit unsigned integer).

_getBYTE(string $str,integer $offset): integer
static
author

Nicola Asuni

since 5.2.000

(2010-06-02)

public

static

Arguments

$str

string

String from where to extract value.

$offset

integer

Point from where to read the data.

Response

integer

8 bit value

Get FIXED from string (32-bit signed fixed-point number (16.16).

_getFIXED(string $str,integer $offset): integer
static
author

Nicola Asuni

since 5.9.123

(2011-09-30)

public

static

Arguments

$str

string

string from where to extract value

$offset

integer

point from where to read the data

Response

integer

16 bit value

Get FWORD from string (Big Endian 16-bit signed integer).

_getFWORD(string $str,integer $offset): integer
static
author

Nicola Asuni

since 5.9.123

(2011-09-30)

public

static

Arguments

$str

string

String from where to extract value.

$offset

integer

Point from where to read the data.

Response

integer

16 bit value

Get SHORT from string (Big Endian 16-bit signed integer).

_getSHORT(string $str,integer $offset): integer
static
author

Nicola Asuni

since 5.2.000

(2010-06-02)

public

static

Arguments

$str

string

String from where to extract value.

$offset

integer

Point from where to read the data.

Response

integer

16 bit value

Get UFWORD from string (Big Endian 16-bit unsigned integer).

_getUFWORD(string $str,integer $offset): integer
static
author

Nicola Asuni

since 5.9.123

(2011-09-30)

public

static

Arguments

$str

string

string from where to extract value

$offset

integer

point from where to read the data

Response

integer

16 bit value

Get ULONG from string (Big Endian 32-bit unsigned integer).

_getULONG(string $str,integer $offset): integer
static
author

Nicola Asuni

since 5.2.000

(2010-06-02)

public

static

Arguments

$str

string

string from where to extract value

$offset

integer

point from where to read the data

Response

integer

32 bit value

Get USHORT from string (Big Endian 16-bit unsigned integer).

_getUSHORT(string $str,integer $offset): integer
static
author

Nicola Asuni

since 5.2.000

(2010-06-02)

public

static

Arguments

$str

string

string from where to extract value

$offset

integer

point from where to read the data

Response

integer

16 bit value

Encrypts a string using MD5 and returns it's value as a binary string.

_md5_16(string $str): string
static
since 2.0.000

(2008-01-02)

public

static

Arguments

$str

string

input string

Response

string

MD5 encrypted binary string

Returns the input text encrypted using RC4 algorithm and the specified key.

_RC4(string $key,string $text,string &$last_enc_key,string &$last_enc_key_c): string
static

RC4 is the standard encryption algorithm used in PDF format

since 2.0.000

(2008-01-02)

author

Klemen Vodopivec, Nicola Asuni

public

static

Arguments

$key

string

Encryption key.

$text

string

Input text to be encrypted.

$last_enc_key

string

Reference to last RC4 key encrypted.

$last_enc_key_c

string

Reference to last RC4 computed key.

Response

string

encrypted text

Convert hexadecimal string to string

convertHexStringToString(string $bs): string
static
since 5.0.005

(2010-05-12)

author

Nicola Asuni

public

static

Arguments

$bs

string

byte-string to convert

Response

string

Convert string to hexadecimal string (byte string)

convertStringToHexString(string $s): string
static
since 5.0.010

(2010-05-17)

author

Nicola Asuni

public

static

Arguments

$s

string

string to convert

Response

string

byte string

Determine whether a string is empty.

empty_string(string $str): boolean
static
since 4.5.044

(2009-04-16)

public

static

Arguments

$str

string

string to be checked

Response

boolean

true if string is empty

Encode a name object.

encodeNameObject(string $name): string
static
author

Nicola Asuni

since 5.9.097

(2011-06-23)

public

static

Arguments

$name

string

Name object to encode.

Response

string

Encoded name object.

Encode query params in URL

encodeUrlQuery(string $url): string
static
since 6.3.3

(2019-11-01)

public

static

Arguments

$url

string

Response

string

Extracts the CSS properties from a CSS string.

extractCSSproperties(string $cssdata): array
static
author

Nicola Asuni

since 5.1.000

(2010-05-25)

public

static

Arguments

$cssdata

string

string containing CSS definitions.

Response

array

An array where the keys are the CSS selectors and the values are the CSS properties.

Wrapper for file_exists.

file_exists(string $filename): boolean
static

Checks whether a file or directory exists. Only allows some protocols and local files.

public

static

Arguments

$filename

string

Path to the file or directory.

Response

boolean

Returns TRUE if the file or directory specified by filename exists; FALSE otherwise.

Reads entire file into a string.

fileGetContents(string $file): string|false
static

The file can be also an URL.

author

Nicola Asuni

since 6.0.025
public

static

Arguments

$file

string

Name of the file or URL to read.

Response

string|false

The function returns the read data or FALSE on failure.

Cleanup HTML code (requires HTML Tidy library).

fixHTMLCode(string $html,string $default_css,array|null $tagvs,array|null $tidy_options,array &$tagvspaces): string
static
author

Nicola Asuni

since 5.9.017

(2010-11-16)

see \setHtmlVSpace()
public

static

Arguments

$html

string

htmlcode to fix

$default_css

string

CSS commands to add

$tagvs

array|null

parameters for setHtmlVSpace method

$tidy_options

array|null

options for tidy_parse_string function

$tagvspaces

array

Array of vertical spaces for tags.

Response

string

XHTML code cleaned up

Wrapper to use fopen only with local files

fopenLocal(string $filename,string $mode): resource|false
static
public

static

Arguments

$filename

string

Name of the file to open

$mode

string

Response

resource|false

Returns a file pointer resource on success, or FALSE on error.

Format the page numbers.

formatPageNumber(integer $num): string
static

This method can be overridden for custom formats.

since 4.2.005

(2008-11-06)

public

static

Arguments

$num

integer

page number

Response

string

Format the page numbers on the Table Of Content.

formatTOCPageNumber(integer $num): string
static

This method can be overridden for custom formats.

since 4.5.001

(2009-01-04)

see \addTOC(),

addHTMLTOC()

public

static

Arguments

$num

integer

page number

Response

string

Gets the current active configuration setting of magic_quotes_runtime (if the get_magic_quotes_runtime function exist)

get_mqr(): integer
static
since 4.6.025

(2009-08-17)

public

static

Response

integer

Returns 0 if magic quotes runtime is off or get_magic_quotes_runtime doesn't exist, 1 otherwise.

Convert JavaScript form fields properties array to Annotation Properties array.

getAnnotOptFromJSProp(array $prop,array &$spot_colors,boolean $rtl = false): array
static
author

Nicola Asuni

since 4.8.000

(2009-09-06)

public

static

Arguments

$prop

array

javascript field properties. Possible values are described on official Javascript for Acrobat API reference.

$spot_colors

array

Reference to spot colors array.

$rtl

boolean

True if in Right-To-Left text direction mode, false otherwise.

Response

array

of annotation properties

Get the border mode accounting for multicell position (opens bottom side of multicell crossing pages)

getBorderMode(string|array|integer $brd,string $position = 'start',boolean $opencell = true): array
static
since 4.4.002

(2008-12-09)

public

static

Arguments

$brd

string|array|integer

Indicates if borders must be drawn around the cell block. The value can be a number:

  • 0: no border (default)
  • 1: frame
or a string containing some or all of the following characters (in any order):
  • L: left
  • T: top
  • R: right
  • B: bottom
or an array of line styles for each border group: array('LTRB' => array('width' => 2, 'cap' => 'butt', 'join' => 'miter', 'dash' => 0, 'color' => array(0, 0, 0)))

$position

string

multicell position: 'start', 'middle', 'end'

$opencell

boolean

True when the cell is left open at the page bottom, false otherwise.

Response

array

border mode array

Returns the styles array that apply for the selected HTML tag.

getCSSdataArray(array $dom,integer $key,array $css): array
static
since 5.1.000

(2010-05-25)

public

static

Arguments

$dom

array

array of HTML tags and properties

$key

integer

key of the current HTML tag

$css

array

array of CSS properties

Response

array

containing CSS properties

Convert encryption P value to a string of bytes, low-order byte first.

getEncPermissionsString(string $protection): string
static
since 5.0.005

(2010-05-12)

author

Nicola Asuni

public

static

Arguments

$protection

string

32bit encryption permission value (P value)

Response

string

Returns a formatted date-time.

getFormattedDate(integer $time): string
static
since 5.9.152

(2012-03-23)

public

static

Arguments

$time

integer

Time in seconds.

Response

string

escaped date string.

Returns an array of hyphenation patterns.

getHyphenPatternsFromTEX(string $file): array
static
author

Nicola Asuni

since 4.9.012

(2010-04-12)

public

static

Arguments

$file

string

TEX file containing hypenation patterns. TEX patterns can be downloaded from http://www.ctan.org/tex-archive/language/hyph-utf8/tex/generic/hyph-utf8/patterns/

Response

array

of hyphenation patterns

Returns a temporary filename for caching object on filesystem.

getObjFilename(string $type = 'tmp',string $file_id = ''): string
static
since 4.5.000

(2008-12-31)

public

static

Arguments

$type

string

Type of file (name of the subdir on the tcpdf cache folder).

$file_id

string

TCPDF file_id.

Response

string

filename.

Get the canonical page layout mode.

getPageLayoutMode(string $layout = 'SinglePage'): string
static
public

static

Arguments

$layout

string

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 (PDF 1.5) Display the pages two at a time, with odd-numbered pages on the left
  • TwoPageRight (PDF 1.5) Display the pages two at a time, with odd-numbered pages on the right

Response

string

Canonical page layout name.

Get the canonical page layout mode.

getPageMode(string $mode = 'UseNone'): string
static
public

static

Arguments

$mode

string

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 mode, 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

Response

string

Canonical page mode name.

Get page dimensions from format name.

getPageSizeFromFormat(mixed $format): array
static
since 5.0.010

(2010-05-17)

public

static

Arguments

$format

mixed

The format name @see self::$page_format

Response

array

containing page width and height in points

Get the Path-Painting Operators.

getPathPaintOperator(string $style,string $default = 'S'): string
static
author

Nicola Asuni

since 5.0.000

(2010-04-30)

public

static

Arguments

$style

string

Style of rendering. Possible values are:

  • S or D: Stroke the path.
  • s or d: Close and stroke the path.
  • f or F: Fill the path, using the nonzero winding number rule to determine the region to fill.
  • f* or F*: Fill the path, using the even-odd rule to determine the region to fill.
  • B or FD or DF: Fill and then stroke the path, using the nonzero winding number rule to determine the region to fill.
  • B* or F*D or DF*: Fill and then stroke the path, using the even-odd rule to determine the region to fill.
  • b or fd or df: Close, fill, and then stroke the path, using the nonzero winding number rule to determine the region to fill.
  • b or f*d or df*: Close, fill, and then stroke the path, using the even-odd rule to determine the region to fill.
  • CNZ: Clipping mode using the even-odd rule to determine which regions lie inside the clipping path.
  • CEO: Clipping mode using the nonzero winding number rule to determine which regions lie inside the clipping path
  • n: End the path object without filling or stroking it.

$default

string

default style

Response

string

Returns a string containing random data to be used as a seed for encryption methods.

getRandomSeed(string $seed = ''): string
static
author

Nicola Asuni

since 5.9.006

(2010-10-19)

public

static

Arguments

$seed

string

starting seed value

Response

string

containing random data

Get the tranformation matrix from SVG transform attribute

getSVGTransformMatrix(string $attribute): array
static
author

Nicola Asuni

since 5.0.000

(2010-05-02)

public

static

Arguments

$attribute

string

transformation

Response

array

of transformations

Compact CSS data array into single string.

getTagStyleFromCSSarray(array $css): string
static
since 5.9.070

(2011-04-19)

public

static

Arguments

$css

array

array of CSS properties

Response

string

containing merged CSS properties

Return the current TCPDF producer.

getTCPDFProducer(): string
static
since 6.0.000

(2013-03-16)

public

static

Response

string

TCPDF producer string

Return the current TCPDF version.

getTCPDFVersion(): string
static
since 5.9.012

(2010-11-10)

public

static

Response

string

TCPDF version string

Returns timestamp in seconds from formatted date-time.

getTimestamp(string $date): integer
static
since 5.9.152

(2012-03-23)

public

static

Arguments

$date

string

Formatted date-time.

Response

integer

seconds.

Get the product of two SVG tranformation matrices

getTransformationMatrixProduct(array $ta,array $tb): array
static
author

Nicola Asuni

since 5.0.000

(2010-05-02)

public

static

Arguments

$ta

array

first SVG tranformation matrix

$tb

array

second SVG tranformation matrix

Response

array

transformation array

Return the permission code used on encryption (P value).

getUserPermissionCode(array $permissions,integer $mode)
static
since 5.0.005

(2010-05-12)

author

Nicola Asuni

public

static

Arguments

$permissions

array

the set of permissions (specify the ones you want to block).

$mode

integer

encryption strength: 0 = RC4 40 bit; 1 = RC4 128 bit; 2 = AES 128 bit; 3 = AES 256 bit.

Returns the angle in radiants between two vectors

getVectorsAngle(integer $x1,integer $y1,integer $x2,integer $y2)
static
author

Nicola Asuni

since 5.0.000

(2010-05-04)

public

static

Arguments

$x1

integer

X coordinate of first vector point

$y1

integer

Y coordinate of first vector point

$x2

integer

X coordinate of second vector point

$y2

integer

Y coordinate of second vector point

Returns the Roman representation of an integer number

intToRoman(integer $number): string
static
since 4.4.004

(2008-12-10)

public

static

Arguments

$number

integer

number to convert

Response

string

roman representation of the specified number

Returns true if the CSS selector is valid for the selected HTML tag

isValidCSSSelectorForTag(array $dom,integer $key,string $selector): true
static
since 5.1.000

(2010-05-25)

public

static

Arguments

$dom

array

array of HTML tags and properties

$key

integer

key of the current HTML tag

$selector

string

CSS selector string

Response

true

if the selector is valid, false otherwise

Check if the URL exist.

isValidURL(string $url): boolean
static
since 5.9.204

(2013-01-28)

public

static

Arguments

$url

string

URL to check.

Response

boolean

true if the URl exist, false otherwise.

Creates a copy of a class object

objclone(object $object): object
static
since 4.5.029

(2009-03-19)

public

static

Arguments

$object

object

class object to be cloned

Response

object

cloned object

Split string by a regular expression.

pregSplit(string $pattern,string $modifiers,string $subject,integer $limit = NULL,integer $flags = NULL): array
static

This is a wrapper for the preg_split function to avoid the bug: https://bugs.php.net/bug.php?id=45850

author

Nicola Asuni

since 6.0.023
public

static

Arguments

$pattern

string

The regular expression pattern to search for without the modifiers, as a string.

$modifiers

string

The modifiers part of the pattern,

$subject

string

The input string.

$limit

integer

If specified, then only substrings up to limit are returned with the rest of the string being placed in the last substring. A limit of -1, 0 or NULL means "no limit" and, as is standard across PHP, you can use NULL to skip to the flags parameter.

$flags

integer

The flags as specified on the preg_split PHP function.

Response

array

Returns an array containing substrings of subject split along boundaries matched by pattern.modifier

Removes SHY characters from text.

removeSHY(string $txt = '',boolean $unicode = true): string
static

Unicode Data:

  • Name : SOFT HYPHEN, commonly abbreviated as SHY
  • HTML Entity (decimal): "­"
  • HTML Entity (hex): "­"
  • HTML Entity (named): "­"
  • How to type in Microsoft Windows: [Alt +00AD] or [Alt 0173]
  • UTF-8 (hex): 0xC2 0xAD (c2ad)
  • UTF-8 character: chr(194).chr(173)

since

(4.5.019) 2009-02-28

public

static

Arguments

$txt

string

input string

$unicode

boolean

True if we are in unicode mode, false otherwise.

Response

string

without SHY characters.

Replace page number aliases with number.

replacePageNumAliases(string $page,array $replace,integer $diff): array
static
public

static

Arguments

$page

string

Page content.

$replace

array

Array of replacements (array keys are replacement strings, values are alias arrays).

$diff

integer

If passed, this will be set to the total char number difference between alias and replacements.

Response

array

replaced page content and updated $diff parameter as array.

Find position of last occurrence of a substring in a string

revstrpos(string $haystack,string $needle,integer $offset): integer|false
static
since 4.8.038

(2010-03-13)

public

static

Arguments

$haystack

string

The string to search in.

$needle

string

substring to search.

$offset

integer

May be specified to begin searching an arbitrary number of characters into the string.

Response

integer|false

Returns the position where the needle exists. Returns FALSE if the needle was not found.

Binary-safe and URL-safe file read.

rfread(resource $handle,integer $length): string|false
static

Reads up to length bytes from the file pointer referenced by handle. Reading stops as soon as one of the following conditions is met: length bytes have been read; EOF (end of file) is reached.

author

Nicola Asuni

since 4.5.027

(2009-03-16)

public

static

Arguments

$handle

resource

$length

integer

Response

string|false

Returns the read string or FALSE in case of error.

Output input data and compress it if possible.

sendOutputData(string $data,integer $length)
static
since 5.9.086
public

static

Arguments

$data

string

Data to output.

$length

integer

Data length in bytes.

Sets the current active configuration setting of magic_quotes_runtime (if the set_magic_quotes_runtime function exist)

set_mqr(boolean $mqr)
static
since 4.6.025

(2009-08-17)

public

static

Arguments

$mqr

boolean

FALSE for off, TRUE for on.

Set page boundaries.

setPageBoxes(integer $page,string $type,float $llx,float $lly,float $urx,float $ury,boolean $points,float $k,array $pagedim = array()): array
static
since 5.0.010

(2010-05-17)

public

static

Arguments

$page

integer

page number

$type

string

valid values are:

  • 'MediaBox' : the boundaries of the physical medium on which the page shall be displayed or printed;
  • 'CropBox' : the visible region of default user space;
  • 'BleedBox' : the region to which the contents of the page shall be clipped when output in a production environment;
  • 'TrimBox' : the intended dimensions of the finished page after trimming;
  • 'ArtBox' : the page's meaningful content (including potential white space).

$llx

float

lower-left x coordinate in user units.

$lly

float

lower-left y coordinate in user units.

$urx

float

upper-right x coordinate in user units.

$ury

float

upper-right y coordinate in user units.

$points

boolean

If true uses user units as unit of measure, otherwise uses PDF points.

$k

float

Scale factor (number of points in user unit).

$pagedim

array

Array of page dimensions.

Response

array

pagedim array of page dimensions.

Swap X and Y coordinates of page boxes (change page boxes orientation).

swapPageBoxCoordinates(integer $page,array $pagedim): array
static
since 5.0.010

(2010-05-17)

public

static

Arguments

$page

integer

page number

$pagedim

array

Array of page dimensions.

Response

array

pagedim array of page dimensions.

Check if the URL exist.

url_exists(string $url): boolean
static
public

static

since 6.2.25

Arguments

$url

string

URL to check.

Response

boolean

Returns TRUE if the URL exists; FALSE otherwise.

Properties

Current TCPDF version.

tcpdf_version :
static
private

static

Type(s)

String alias for total number of pages.

alias_tot_pages :
static
public

static

Type(s)

String alias for page number.

alias_num_page :
static
public

static

Type(s)

String alias for total number of pages in a single group.

alias_group_tot_pages :
static
public

static

Type(s)

String alias for group page number.

alias_group_num_page :
static
public

static

Type(s)

String alias for right shift compensation used to correctly align page numbers on the right.

alias_right_shift :
static
public

static

Type(s)

Encryption padding string.

enc_padding :
static
public

static

Type(s)

ByteRange placemark used during digital signature process.

byterange_string :
static
since

(2009-08-25)

public

static

Type(s)

Array page boxes names

pageboxes :
static
public

static

Type(s)

Array of page formats measures are calculated in this way: (inches * 72) or (millimeters * 72 / 25.4)

page_formats :\array<string,float[]>
static
public

static

var

Type(s)

\array