Helpers
in package
Table of Contents
- build_url() : string
- builds a full url given a protocol, hostname, base path and url
- buildContentDispositionHeader() : string
- Builds a HTTP Content-Disposition header string using `$dispositionType` and `$filename`.
- cmyk_to_rgb() : array<string|int, float>
- Converts a CMYK color to RGB
- dec2roman() : string
- Converts decimal numbers to roman numerals
- dompdf_debug() : mixed
- Print debug messages
- dompdf_getimagesize() : array<string|int, mixed>
- getimagesize doesn't give a good size for 32bit BMP image v5
- encodeURI() : string
- Encodes a Uniform Resource Identifier (URI) by replacing non-alphanumeric characters with a percent (%) sign followed by two hex digits, excepting characters in the URI reserved character set.
- explode_url() : array<string|int, mixed>
- parse a full url or pathname and return an array(protocol, host, path, file + query + fragment)
- getFileContent() : array<string|int, string>
- Gets the content of the file at the specified path using one of the following methods, in preferential order: - file_get_contents: if allow_url_fopen is true or the file is local - curl: if allow_url_fopen is false and curl is available
- imagecreatefrombmp() : mixed
- Credit goes to mgutt http://www.programmierer-forum.de/function-imagecreatefrombmp-welche-variante-laeuft-t143137.htm Modified by Fabien Menager to support RGB555 BMP format
- is_percent() : bool
- Determines whether $value is a percentage or not
- mb_ucwords() : mixed
- parse_data_uri() : array<string|int, mixed>|bool
- Parses a data URI scheme http://en.wikipedia.org/wiki/Data_URI_scheme
- pre_r() : string|null
- print_r wrapper for html/cli output
- record_warnings() : mixed
- Stores warnings in an array for display later This function allows warnings generated by the DomDocument parser and CSS loader ({@link Stylesheet}) to be captured and displayed later. Without this function, errors are displayed immediately and PDF streaming is impossible.
- rle4_decode() : string
- Decoder for RLE4 compression in windows bitmaps see http://msdn.microsoft.com/library/default.asp?url=/library/en-us/gdi/bitmaps_6x0u.asp
- rle8_decode() : string
- Decoder for RLE8 compression in windows bitmaps http://msdn.microsoft.com/library/default.asp?url=/library/en-us/gdi/bitmaps_6x0u.asp
- unichr() : bool|string
Methods
build_url()
builds a full url given a protocol, hostname, base path and url
public
static build_url(string $protocol, string $host, string $base_path, string $url) : string
Parameters
- $protocol : string
- $host : string
- $base_path : string
- $url : string
Return values
string —Initially the trailing slash of $base_path was optional, and conditionally appended. However on dynamically created sites, where the page is given as url parameter, the base path might not end with an url. Therefore do not append a slash, and require the $base_url to ending in a slash when needed. Vice versa, on using the local file system path of a file, make sure that the slash is appended (o.k. also for Windows)
buildContentDispositionHeader()
Builds a HTTP Content-Disposition header string using `$dispositionType` and `$filename`.
public
static buildContentDispositionHeader(string $dispositionType, string $filename) : string
If the filename contains any characters not in the ISO-8859-1 character
set, a fallback filename will be included for clients not supporting the
filename* parameter.
Parameters
- $dispositionType : string
- $filename : string
Return values
string —cmyk_to_rgb()
Converts a CMYK color to RGB
public
static cmyk_to_rgb(float|array<string|int, float> $c[, float $m = null ][, float $y = null ][, float $k = null ]) : array<string|int, float>
Parameters
- $c : float|array<string|int, float>
- $m : float = null
- $y : float = null
- $k : float = null
Return values
array<string|int, float> —dec2roman()
Converts decimal numbers to roman numerals
public
static dec2roman(int $num) : string
Parameters
- $num : int
Tags
Return values
string —dompdf_debug()
Print debug messages
public
static dompdf_debug(string $type, string $msg) : mixed
Parameters
- $type : string
-
The type of debug messages to print
- $msg : string
-
The message to show
Return values
mixed —dompdf_getimagesize()
getimagesize doesn't give a good size for 32bit BMP image v5
public
static dompdf_getimagesize(string $filename[, resource $context = null ]) : array<string|int, mixed>
Parameters
- $filename : string
- $context : resource = null
Return values
array<string|int, mixed> —The same format as getimagesize($filename)
encodeURI()
Encodes a Uniform Resource Identifier (URI) by replacing non-alphanumeric characters with a percent (%) sign followed by two hex digits, excepting characters in the URI reserved character set.
public
static encodeURI(string $uri) : string
Assumes that the URI is a complete URI, so does not encode reserved characters that have special meaning in the URI.
Simulates the encodeURI function available in JavaScript https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/encodeURI
Source: http://stackoverflow.com/q/4929584/264628
Parameters
- $uri : string
-
The URI to encode
Return values
string —The original URL with special characters encoded
explode_url()
parse a full url or pathname and return an array(protocol, host, path, file + query + fragment)
public
static explode_url(string $url) : array<string|int, mixed>
Parameters
- $url : string
Return values
array<string|int, mixed> —getFileContent()
Gets the content of the file at the specified path using one of the following methods, in preferential order: - file_get_contents: if allow_url_fopen is true or the file is local - curl: if allow_url_fopen is false and curl is available
public
static getFileContent(string $uri[, resource $context = null ], int $offset[, int $maxlen = null ]) : array<string|int, string>
Parameters
- $uri : string
- $context : resource = null
-
(ignored if curl is used)
- $offset : int
- $maxlen : int = null
-
(ignored if curl is used)
Return values
array<string|int, string> —imagecreatefrombmp()
Credit goes to mgutt http://www.programmierer-forum.de/function-imagecreatefrombmp-welche-variante-laeuft-t143137.htm Modified by Fabien Menager to support RGB555 BMP format
public
static imagecreatefrombmp(mixed $filename[, mixed $context = null ]) : mixed
Parameters
- $filename : mixed
- $context : mixed = null
Return values
mixed —is_percent()
Determines whether $value is a percentage or not
public
static is_percent(float $value) : bool
Parameters
- $value : float
Return values
bool —mb_ucwords()
public
static mb_ucwords(mixed $str) : mixed
Parameters
- $str : mixed
Return values
mixed —parse_data_uri()
Parses a data URI scheme http://en.wikipedia.org/wiki/Data_URI_scheme
public
static parse_data_uri(string $data_uri) : array<string|int, mixed>|bool
Parameters
- $data_uri : string
-
The data URI to parse
Return values
array<string|int, mixed>|bool —The result with charset, mime type and decoded data
pre_r()
print_r wrapper for html/cli output
public
static pre_r(mixed $mixed[, bool $return = false ]) : string|null
Wraps print_r() output in < pre > tags if the current sapi is not 'cli'. Returns the output string instead of displaying it if $return is true.
Parameters
- $mixed : mixed
-
variable or expression to display
- $return : bool = false
Return values
string|null —record_warnings()
Stores warnings in an array for display later This function allows warnings generated by the DomDocument parser and CSS loader ({@link Stylesheet}) to be captured and displayed later. Without this function, errors are displayed immediately and PDF streaming is impossible.
public
static record_warnings(int $errno, string $errstr, string $errfile, string $errline) : mixed
Parameters
- $errno : int
- $errstr : string
- $errfile : string
- $errline : string
Tags
Return values
mixed —rle4_decode()
Decoder for RLE4 compression in windows bitmaps see http://msdn.microsoft.com/library/default.asp?url=/library/en-us/gdi/bitmaps_6x0u.asp
public
static rle4_decode(string $str, int $width) : string
Parameters
- $str : string
-
Data to decode
- $width : int
-
Image width
Return values
string —rle8_decode()
Decoder for RLE8 compression in windows bitmaps http://msdn.microsoft.com/library/default.asp?url=/library/en-us/gdi/bitmaps_6x0u.asp
public
static rle8_decode(string $str, int $width) : string
Parameters
- $str : string
-
Data to decode
- $width : int
-
Image width
Return values
string —unichr()
public
static unichr( $c) : bool|string