94 public static $enc_padding =
"\x28\xBF\x4E\x5E\x4E\x75\x8A\x41\x64\x00\x4E\x56\xFF\xFA\x01\x08\x2E\x2E\x00\xB6\xD0\x68\x3E\x80\x2F\x0C\xA9\xFE\x64\x53\x69\x7A";
107 public static $pageboxes =
array(
'MediaBox',
'CropBox',
'BleedBox',
'TrimBox',
'ArtBox');
118 return self::$tcpdf_version;
128 return "\x54\x43\x50\x44\x46\x20".self::getTCPDFVersion().
"\x20\x28\x68\x74\x74\x70\x3a\x2f\x2f\x77\x77\x77\x2e\x74\x63\x70\x64\x66\x2e\x6f\x72\x67\x29";
138 if (!
defined(
'PHP_VERSION_ID')) {
142 if (PHP_VERSION_ID < 50300) {
143 @set_magic_quotes_runtime($mqr);
154 if (!
defined(
'PHP_VERSION_ID')) {
158 if (PHP_VERSION_ID < 50300) {
159 return @get_magic_quotes_runtime();
172 $headers = @get_headers(
$url);
173 return (strpos($headers[0],
'200') !==
false);
194 $txt = preg_replace(
'/([\\xc2]{1}[\\xad]{1})/',
'',
$txt);
196 $txt = preg_replace(
'/([\\xad]{1})/',
'',
$txt);
211 public static function getBorderMode($brd, $position=
'start', $opencell=
true) {
212 if ((!$opencell) OR empty($brd)) {
218 if (is_string($brd)) {
220 $slen = strlen($brd);
222 for ($i = 0; $i < $slen; ++$i) {
223 $newbrd[$brd[$i]] =
array(
'cap' =>
'square',
'join' =>
'miter');
230 if (strpos(
$border,
'B') !==
false) {
232 $newkey = str_replace(
'B',
'',
$border);
233 if (strlen($newkey) > 0) {
241 if (strpos(
$border,
'B') !==
false) {
243 $newkey = str_replace(
'B',
'',
$border);
244 if (strlen($newkey) > 0) {
250 if (strpos(
$border,
'T') !==
false) {
252 $newkey = str_replace(
'T',
'',
$border);
253 if (strlen($newkey) > 0) {
261 if (strpos(
$border,
'T') !==
false) {
263 $newkey = str_replace(
'T',
'',
$border);
264 if (strlen($newkey) > 0) {
284 return (is_null($str) OR (is_string($str) AND (strlen($str) == 0)));
307 return strtr($s,
array(
')' =>
'\\)',
'(' =>
'\\(',
'\\' =>
'\\\\', chr(13) =>
'\r'));
318 $replaceTable =
array(
"\0" =>
'',
'&' =>
'&',
'<' =>
'<',
'>' =>
'>');
319 $str = strtr($str, $replaceTable);
331 if (($object instanceof Imagick) AND (version_compare(phpversion(
'imagick'),
'3.0.1') !== 1)) {
333 return @$object->clone();
335 return @clone($object);
346 if (!isset(
$_SERVER[
'HTTP_ACCEPT_ENCODING']) OR empty(
$_SERVER[
'HTTP_ACCEPT_ENCODING'])) {
348 header(
'Content-Length: '.$length);
362 foreach ($replace as $rep) {
363 foreach ($rep[3] as $a) {
364 if (strpos($page, $a) !==
false) {
365 $page = str_replace($a, $rep[0], $page);
366 $diff += ($rep[2] - $rep[1]);
370 return array($page, $diff);
381 if (($date[0] ==
'D') AND ($date[1] ==
':')) {
383 $date = substr($date, 2);
385 return strtotime($date);
396 return substr_replace(
date(
'YmdHisO', intval($time)),
'\'', (0 - 2), 0).
'\'';
408 $rnd = uniqid(rand().microtime(
true),
true);
409 if (function_exists(
'posix_getpid')) {
410 $rnd .= posix_getpid();
412 if (function_exists(
'openssl_random_pseudo_bytes') AND (strtoupper(substr(PHP_OS, 0, 3)) !==
'WIN')) {
414 $rnd .= openssl_random_pseudo_bytes(512);
416 for ($i = 0; $i < 23; ++$i) {
417 $rnd .= uniqid(
'',
true);
420 return $rnd.$seed.__FILE__.serialize(
$_SERVER).microtime(
true);
431 return pack(
'H*', md5($str));
446 $padding = 16 - (strlen(
$text) % 16);
447 $text .= str_repeat(chr($padding), $padding);
448 if (extension_loaded(
'openssl')) {
449 $iv = openssl_random_pseudo_bytes (openssl_cipher_iv_length(
'aes-256-cbc'));
450 $text = openssl_encrypt(
$text,
'aes-256-cbc', $key, OPENSSL_RAW_DATA, $iv);
451 return $iv.substr(
$text, 0, -16);
453 $iv = mcrypt_create_iv(mcrypt_get_iv_size(MCRYPT_RIJNDAEL_128, MCRYPT_MODE_CBC), MCRYPT_RAND);
454 $text = mcrypt_encrypt(MCRYPT_RIJNDAEL_128, $key,
$text, MCRYPT_MODE_CBC, $iv);
470 if (extension_loaded(
'openssl')) {
471 $iv = str_repeat(
"\x00", openssl_cipher_iv_length(
'aes-256-cbc'));
472 $text = openssl_encrypt(
$text,
'aes-256-cbc', $key, OPENSSL_RAW_DATA, $iv);
473 return substr(
$text, 0, -16);
475 $iv = str_repeat(
"\x00", mcrypt_get_iv_size(MCRYPT_RIJNDAEL_128, MCRYPT_MODE_CBC));
476 $text = mcrypt_encrypt(MCRYPT_RIJNDAEL_128, $key,
$text, MCRYPT_MODE_CBC, $iv);
492 public static function _RC4($key,
$text, &$last_enc_key, &$last_enc_key_c) {
493 if (function_exists(
'mcrypt_encrypt') AND (
$out = @mcrypt_encrypt(MCRYPT_ARCFOUR, $key,
$text, MCRYPT_MODE_STREAM,
''))) {
497 if ($last_enc_key != $key) {
498 $k = str_repeat($key, ((256 / strlen($key)) + 1));
499 $rc4 =
range(0, 255);
501 for ($i = 0; $i < 256; ++$i) {
503 $j = ($j +
$t + ord($k[$i])) % 256;
507 $last_enc_key = $key;
508 $last_enc_key_c = $rc4;
510 $rc4 = $last_enc_key_c;
512 $len = strlen(
$text);
516 for ($i = 0; $i < $len; ++$i) {
519 $b = ($b +
$t) % 256;
522 $k = $rc4[($rc4[$a] + $rc4[$b]) % 256];
548 $protection = 2147422012;
549 foreach ($permissions as $permission) {
551 if (($mode > 0) OR (
$options[$permission] <= 32)) {
555 $protection +=
$options[$permission];
557 $protection -=
$options[$permission];
575 $bslength = strlen($bs);
576 if (($bslength % 2) != 0) {
581 for ($i = 0; $i < $bslength; $i += 2) {
582 $string .= chr(hexdec($bs[$i].$bs[($i + 1)]));
597 $chars = preg_split(
'//', $s, -1, PREG_SPLIT_NO_EMPTY);
598 foreach ($chars as $c) {
599 $bs .= sprintf(
'%02s', dechex(ord($c)));
613 $binprot = sprintf(
'%032b', $protection);
614 $str = chr(bindec(substr($binprot, 24, 8)));
615 $str .= chr(bindec(substr($binprot, 16, 8)));
616 $str .= chr(bindec(substr($binprot, 8, 8)));
617 $str .= chr(bindec(substr($binprot, 0, 8)));
631 $length = strlen($name);
632 for ($i = 0; $i < $length; ++$i) {
634 if (preg_match(
'/[0-9a-zA-Z#_=-]/', $chr) == 1) {
637 $escname .= sprintf(
'#%02X', ord($chr));
654 if (isset($prop[
'aopt']) AND is_array($prop[
'aopt'])) {
656 return $prop[
'aopt'];
660 if (isset($prop[
'alignment'])) {
661 switch ($prop[
'alignment']) {
675 $opt[
'q'] = ($rtl)?2:0;
681 if (isset($prop[
'lineWidth'])) {
682 $linewidth = intval($prop[
'lineWidth']);
687 if (isset($prop[
'borderStyle'])) {
688 switch ($prop[
'borderStyle']) {
691 $opt[
'border'] =
array(0, 0, $linewidth,
array(3, 2));
692 $opt[
'bs'] =
array(
'w'=>$linewidth,
's'=>
'D',
'd'=>
array(3, 2));
697 $opt[
'border'] =
array(0, 0, $linewidth);
698 $opt[
'bs'] =
array(
'w'=>$linewidth,
's'=>
'B');
703 $opt[
'border'] =
array(0, 0, $linewidth);
704 $opt[
'bs'] =
array(
'w'=>$linewidth,
's'=>
'I');
709 $opt[
'border'] =
array(0, 0, $linewidth);
710 $opt[
'bs'] =
array(
'w'=>$linewidth,
's'=>
'U');
715 $opt[
'border'] =
array(0, 0, $linewidth);
716 $opt[
'bs'] =
array(
'w'=>$linewidth,
's'=>
'S');
724 if (isset($prop[
'border']) AND is_array($prop[
'border'])) {
725 $opt[
'border'] = $prop[
'border'];
727 if (!isset($opt[
'mk'])) {
728 $opt[
'mk'] =
array();
730 if (!isset($opt[
'mk'][
'if'])) {
731 $opt[
'mk'][
'if'] =
array();
733 $opt[
'mk'][
'if'][
'a'] =
array(0.5, 0.5);
735 if (isset($prop[
'buttonAlignX'])) {
736 $opt[
'mk'][
'if'][
'a'][0] = $prop[
'buttonAlignX'];
739 if (isset($prop[
'buttonAlignY'])) {
740 $opt[
'mk'][
'if'][
'a'][1] = $prop[
'buttonAlignY'];
743 if (isset($prop[
'buttonFitBounds']) AND ($prop[
'buttonFitBounds'] ==
'true')) {
744 $opt[
'mk'][
'if'][
'fb'] =
true;
747 if (isset($prop[
'buttonScaleHow'])) {
748 switch ($prop[
'buttonScaleHow']) {
749 case 'scaleHow.proportional': {
750 $opt[
'mk'][
'if'][
's'] =
'P';
753 case 'scaleHow.anamorphic': {
754 $opt[
'mk'][
'if'][
's'] =
'A';
760 if (isset($prop[
'buttonScaleWhen'])) {
761 switch ($prop[
'buttonScaleWhen']) {
762 case 'scaleWhen.always': {
763 $opt[
'mk'][
'if'][
'sw'] =
'A';
766 case 'scaleWhen.never': {
767 $opt[
'mk'][
'if'][
'sw'] =
'N';
770 case 'scaleWhen.tooBig': {
771 $opt[
'mk'][
'if'][
'sw'] =
'B';
774 case 'scaleWhen.tooSmall': {
775 $opt[
'mk'][
'if'][
'sw'] =
'S';
781 if (isset($prop[
'buttonPosition'])) {
782 switch ($prop[
'buttonPosition']) {
784 case 'position.textOnly': {
785 $opt[
'mk'][
'tp'] = 0;
789 case 'position.iconOnly': {
790 $opt[
'mk'][
'tp'] = 1;
794 case 'position.iconTextV': {
795 $opt[
'mk'][
'tp'] = 2;
799 case 'position.textIconV': {
800 $opt[
'mk'][
'tp'] = 3;
804 case 'position.iconTextH': {
805 $opt[
'mk'][
'tp'] = 4;
809 case 'position.textIconH': {
810 $opt[
'mk'][
'tp'] = 5;
814 case 'position.overlay': {
815 $opt[
'mk'][
'tp'] = 6;
821 if (isset($prop[
'fillColor'])) {
822 if (is_array($prop[
'fillColor'])) {
823 $opt[
'mk'][
'bg'] = $prop[
'fillColor'];
829 if (isset($prop[
'strokeColor'])) {
830 if (is_array($prop[
'strokeColor'])) {
831 $opt[
'mk'][
'bc'] = $prop[
'strokeColor'];
837 if (isset($prop[
'rotation'])) {
838 $opt[
'mk'][
'r'] = $prop[
'rotation'];
841 if (isset($prop[
'charLimit'])) {
842 $opt[
'maxlen'] = intval($prop[
'charLimit']);
848 if (isset($prop[
'readonly']) AND ($prop[
'readonly'] ==
'true')) {
852 if (isset($prop[
'required']) AND ($prop[
'required'] ==
'true')) {
856 if (isset($prop[
'multiline']) AND ($prop[
'multiline'] ==
'true')) {
860 if (isset($prop[
'password']) AND ($prop[
'password'] ==
'true')) {
864 if (isset($prop[
'NoToggleToOff']) AND ($prop[
'NoToggleToOff'] ==
'true')) {
868 if (isset($prop[
'Radio']) AND ($prop[
'Radio'] ==
'true')) {
872 if (isset($prop[
'Pushbutton']) AND ($prop[
'Pushbutton'] ==
'true')) {
876 if (isset($prop[
'Combo']) AND ($prop[
'Combo'] ==
'true')) {
880 if (isset($prop[
'editable']) AND ($prop[
'editable'] ==
'true')) {
884 if (isset($prop[
'Sort']) AND ($prop[
'Sort'] ==
'true')) {
888 if (isset($prop[
'fileSelect']) AND ($prop[
'fileSelect'] ==
'true')) {
892 if (isset($prop[
'multipleSelection']) AND ($prop[
'multipleSelection'] ==
'true')) {
896 if (isset($prop[
'doNotSpellCheck']) AND ($prop[
'doNotSpellCheck'] ==
'true')) {
900 if (isset($prop[
'doNotScroll']) AND ($prop[
'doNotScroll'] ==
'true')) {
904 if (isset($prop[
'comb']) AND ($prop[
'comb'] ==
'true')) {
908 if (isset($prop[
'radiosInUnison']) AND ($prop[
'radiosInUnison'] ==
'true')) {
912 if (isset($prop[
'richText']) AND ($prop[
'richText'] ==
'true')) {
916 if (isset($prop[
'commitOnSelChange']) AND ($prop[
'commitOnSelChange'] ==
'true')) {
921 if (isset($prop[
'defaultValue'])) {
922 $opt[
'dv'] = $prop[
'defaultValue'];
926 if (isset($prop[
'readonly']) AND ($prop[
'readonly'] ==
'true')) {
930 if (isset($prop[
'display'])) {
931 if ($prop[
'display'] ==
'display.visible') {
933 } elseif ($prop[
'display'] ==
'display.hidden') {
935 } elseif ($prop[
'display'] ==
'display.noPrint') {
937 } elseif ($prop[
'display'] ==
'display.noView') {
943 if (isset($prop[
'currentValueIndices']) AND is_array($prop[
'currentValueIndices'])) {
944 $opt[
'i'] = $prop[
'currentValueIndices'];
947 if (isset($prop[
'value'])) {
948 if (is_array($prop[
'value'])) {
949 $opt[
'opt'] =
array();
950 foreach ($prop[
'value'] AS $key => $optval) {
952 if (isset($prop[
'exportValues'][$key])) {
953 $opt[
'opt'][$key] =
array($prop[
'exportValues'][$key], $prop[
'value'][$key]);
955 $opt[
'opt'][$key] = $prop[
'value'][$key];
959 $opt[
'v'] = $prop[
'value'];
963 if (isset($prop[
'richValue'])) {
964 $opt[
'rv'] = $prop[
'richValue'];
967 if (isset($prop[
'submitName'])) {
968 $opt[
'tm'] = $prop[
'submitName'];
971 if (isset($prop[
'name'])) {
972 $opt[
't'] = $prop[
'name'];
975 if (isset($prop[
'userName'])) {
976 $opt[
'tu'] = $prop[
'userName'];
979 if (isset($prop[
'highlight'])) {
980 switch ($prop[
'highlight']) {
982 case 'highlight.n': {
987 case 'highlight.i': {
992 case 'highlight.p': {
997 case 'highlight.o': {
1020 return number_format((
float)$num, 0,
'',
'.');
1032 return number_format((
float)$num, 0,
'',
'.');
1044 if (empty($cssdata)) {
1048 $cssdata = preg_replace(
'/\/\*[^\*]*\*\//',
'', $cssdata);
1050 $cssdata = preg_replace(
'/[\s]+/',
' ', $cssdata);
1052 $cssdata = preg_replace(
'/[\s]*([;:\{\}]{1})[\s]*/',
'\\1', $cssdata);
1054 $cssdata = preg_replace(
'/([^\}\{]+)\{\}/',
'', $cssdata);
1056 $cssdata = preg_replace(
'/@media[\s]+([^\{]*)\{/i',
'@media \\1§', $cssdata);
1057 $cssdata = preg_replace(
'/\}\}/si',
'}§', $cssdata);
1059 $cssdata = trim($cssdata);
1061 $cssblocks =
array();
1063 if (preg_match_all(
'/@media[\s]+([^\ ]*)§([^§]*)§/i', $cssdata, $matches) > 0) {
foreach ($matches[1] as $key => $type) {
$cssblocks[$type] = $matches[2][$key];
}
// remove media blocks
$cssdata = preg_replace('/@media[\s]+([^\§]*)§([^§]*)§/i', '', $cssdata);
}
// keep 'all' and 'print' media, other media types are discarded
if (isset($cssblocks['all']) AND !empty($cssblocks['all'])) {
$cssdata .= $cssblocks['all'];
}
if (isset($cssblocks['print']) AND !empty($cssblocks['print'])) {
$cssdata .= $cssblocks['print'];
}
// reset css blocks array
$cssblocks = array();
$matches = array();
// explode css data string into array
if (substr($cssdata, -1) == '}') {
// remove last parethesis
$cssdata = substr($cssdata, 0, -1);
}
$matches = explode('}', $cssdata);
foreach ($matches as $key => $block) {
// index 0 contains the CSS selector, index 1 contains CSS properties
$cssblocks[$key] = explode('{', $block);
if (!isset($cssblocks[$key][1])) {
// remove empty definitions
unset($cssblocks[$key]);
}
}
// split groups of selectors (comma-separated list of selectors)
foreach ($cssblocks as $key => $block) {
if (strpos($block[0], ',') > 0) {
$selectors = explode(',', $block[0]);
foreach ($selectors as $sel) {
$cssblocks[] = array(0 => trim($sel), 1 => $block[1]);
}
unset($cssblocks[$key]);
}
}
// covert array to selector => properties
$cssdata = array();
foreach ($cssblocks as $block) {
$selector = $block[0];
// calculate selector's specificity
$matches = array();
$a = 0; // the declaration is not from is a 'style' attribute
$b = intval(preg_match_all('/[\#]/', $selector, $matches)); // number of ID attributes
$c = intval(preg_match_all('/[\[\.]/', $selector, $matches)); // number of other attributes
$c += intval(preg_match_all('/[\:]link|visited|hover|active|focus|target|lang|enabled|disabled|checked|indeterminate|root|nth|first|last|only|empty|contains|not/i', $selector, $matches)); // number of pseudo-classes
$d = intval(preg_match_all('/[>\+\~\s]{1}[a-zA-Z0-9]+/', ' '.$selector, $matches)); // number of element names
$d += intval(preg_match_all('/[\:][\:]/', $selector, $matches)); // number of pseudo-elements
$specificity = $a.$b.$c.$d;
// add specificity to the beginning of the selector
$cssdata[$specificity.' '.$selector] = $block[1];
}
// sort selectors alphabetically to account for specificity
ksort($cssdata, SORT_STRING);
// return array
return $cssdata;
}
/**
* Cleanup HTML code (requires HTML Tidy library).
* @param $html (string) htmlcode to fix
* @param $default_css (string) CSS commands to add
* @param $tagvs (array) parameters for setHtmlVSpace method
* @param $tidy_options (array) options for tidy_parse_string function
* @param $tagvspaces (array) Array of vertical spaces for tags.
* @return string XHTML code cleaned up
* @author Nicola Asuni
* @since 5.9.017 (2010-11-16)
* @see setHtmlVSpace()
* @public static
*/
public static function fixHTMLCode($html, $default_css='', $tagvs='', $tidy_options='', &$tagvspaces) {
// configure parameters for HTML Tidy
if ($tidy_options === '') {
$tidy_options = array (
'clean' => 1,
'drop-empty-paras' => 0,
'drop-proprietary-attributes' => 1,
'fix-backslash' => 1,
'hide-comments' => 1,
'join-styles' => 1,
'lower-literals' => 1,
'merge-divs' => 1,
'merge-spans' => 1,
'output-xhtml' => 1,
'word-2000' => 1,
'wrap' => 0,
'output-bom' => 0,
//'char-encoding' => 'utf8',
//'input-encoding' => 'utf8',
//'output-encoding' => 'utf8'
);
}
// clean up the HTML code
$tidy = tidy_parse_string($html, $tidy_options);
// fix the HTML
$tidy->cleanRepair();
// get the CSS part
$tidy_head = tidy_get_head($tidy);
$css = $tidy_head->value;
$css = preg_replace('/<style([^>]+)>/ims', '<style>', $css);
$css = preg_replace('/<\/style>(.*)<style>/ims', "\n", $css);
$css = str_replace('/*<![CDATA[*/', '', $css);
$css = str_replace('/*]]>*/', '', $css);
preg_match('/<style>(.*)<\/style>/ims', $css, $matches);
if (isset($matches[1])) {
$css = strtolower($matches[1]);
} else {
$css = '';
}
// include default css
$css = '<style>'.$default_css.$css.'</style>';
// get the body part
$tidy_body = tidy_get_body($tidy);
$html = $tidy_body->value;
// fix some self-closing tags
$html = str_replace('<br>', '<br />', $html);
// remove some empty tag blocks
$html = preg_replace('/<div([^>]*)><\/div>/', '', $html);
$html = preg_replace('/<p([^>]*)><\/p>/', '', $html);
if ($tagvs !== '') {
// set vertical space for some XHTML tags
$tagvspaces = $tagvs;
}
// return the cleaned XHTML code + CSS
return $css.$html;
}
/**
* Returns true if the CSS selector is valid for the selected HTML tag
* @param $dom (array) array of HTML tags and properties
* @param $key (int) key of the current HTML tag
* @param $selector (string) CSS selector string
* @return true if the selector is valid, false otherwise
* @since 5.1.000 (2010-05-25)
* @public static
*/
public static function isValidCSSSelectorForTag($dom, $key, $selector) {
$valid = false; // value to be returned
$tag = $dom[$key]['value'];
$class = array();
if (isset($dom[$key]['attribute']['class']) AND !empty($dom[$key]['attribute']['class'])) {
$class = explode(' ', strtolower($dom[$key]['attribute']['class']));
}
$id = '';
if (isset($dom[$key]['attribute']['id']) AND !empty($dom[$key]['attribute']['id'])) {
$id = strtolower($dom[$key]['attribute']['id']);
}
$selector = preg_replace('/([>\+\~\s]{1})([\.]{1})([^>\+\~\s]*)/si', '\\1*.\\3', $selector);
$matches = array();
if (preg_match_all('/([>\+\~\s]{1})([a-zA-Z0-9\*]+)([^>\+\~\s]*)/si', $selector, $matches, PREG_PATTERN_ORDER | PREG_OFFSET_CAPTURE) > 0) {
$parentop = array_pop($matches[1]);
$operator = $parentop[0];
$offset = $parentop[1];
$lasttag = array_pop($matches[2]);
$lasttag = strtolower(trim($lasttag[0]));
if (($lasttag == '*') OR ($lasttag == $tag)) {
// the last element on selector is our tag or 'any tag'
$attrib = array_pop($matches[3]);
$attrib = strtolower(trim($attrib[0]));
if (!empty($attrib)) {
// check if matches class, id, attribute, pseudo-class or pseudo-element
switch ($attrib[0]) {
case '.': { // class
if (in_array(substr($attrib, 1), $class)) {
$valid = true;
}
break;
}
case '#': { // ID
if (substr($attrib, 1) == $id) {
$valid = true;
}
break;
}
case '[': { // attribute
$attrmatch = array();
if (preg_match('/\[([a-zA-Z0-9]*)[\s]*([\~\^\$\*\|\=]*)[\s]*["]?([^"\]]*)["]?\]/i', $attrib, $attrmatch) > 0) {
$att = strtolower($attrmatch[1]);
$val = $attrmatch[3];
if (isset($dom[$key]['attribute'][$att])) {
switch ($attrmatch[2]) {
case '=': {
if ($dom[$key]['attribute'][$att] == $val) {
$valid = true;
}
break;
}
case '~=': {
if (in_array($val, explode(' ', $dom[$key]['attribute'][$att]))) {
$valid = true;
}
break;
}
case '^=': {
if ($val == substr($dom[$key]['attribute'][$att], 0, strlen($val))) {
$valid = true;
}
break;
}
case '$=': {
if ($val == substr($dom[$key]['attribute'][$att], -strlen($val))) {
$valid = true;
}
break;
}
case '*=': {
if (strpos($dom[$key]['attribute'][$att], $val) !== false) {
$valid = true;
}
break;
}
case '|=': {
if ($dom[$key]['attribute'][$att] == $val) {
$valid = true;
} elseif (preg_match('/'.$val.'[\-]{1}/i', $dom[$key]['attribute'][$att]) > 0) {
$valid = true;
}
break;
}
default: {
$valid = true;
}
}
}
}
break;
}
case ':': { // pseudo-class or pseudo-element
if ($attrib[1] == ':') { // pseudo-element
// pseudo-elements are not supported!
// (::first-line, ::first-letter, ::before, ::after)
} else { // pseudo-class
// pseudo-classes are not supported!
// (:root, :nth-child(n), :nth-last-child(n), :nth-of-type(n), :nth-last-of-type(n), :first-child, :last-child, :first-of-type, :last-of-type, :only-child, :only-of-type, :empty, :link, :visited, :active, :hover, :focus, :target, :lang(fr), :enabled, :disabled, :checked)
}
break;
}
} // end of switch
} else {
$valid = true;
}
if ($valid AND ($offset > 0)) {
$valid = false;
// check remaining selector part
$selector = substr($selector, 0, $offset);
switch ($operator) {
case ' ': { // descendant of an element
while ($dom[$key]['parent'] > 0) {
if (self::isValidCSSSelectorForTag($dom, $dom[$key]['parent'], $selector)) {
$valid = true;
break;
} else {
$key = $dom[$key]['parent'];
}
}
break;
}
case '>': { // child of an element
$valid = self::isValidCSSSelectorForTag($dom, $dom[$key]['parent'], $selector);
break;
}
case '+': { // immediately preceded by an element
for ($i = ($key - 1); $i > $dom[$key]['parent']; --$i) {
if ($dom[$i]['tag'] AND $dom[$i]['opening']) {
$valid = self::isValidCSSSelectorForTag($dom, $i, $selector);
break;
}
}
break;
}
case '~': { // preceded by an element
for ($i = ($key - 1); $i > $dom[$key]['parent']; --$i) {
if ($dom[$i]['tag'] AND $dom[$i]['opening']) {
if (self::isValidCSSSelectorForTag($dom, $i, $selector)) {
break;
}
}
}
break;
}
}
}
}
}
return $valid;
}
/**
* Returns the styles array that apply for the selected HTML tag.
* @param $dom (array) array of HTML tags and properties
* @param $key (int) key of the current HTML tag
* @param $css (array) array of CSS properties
* @return array containing CSS properties
* @since 5.1.000 (2010-05-25)
* @public static
*/
public static function getCSSdataArray($dom, $key, $css) {
$cssarray = array(); // style to be returned
// get parent CSS selectors
$selectors = array();
if (isset($dom[($dom[$key]['parent'])]['csssel'])) {
$selectors = $dom[($dom[$key]['parent'])]['csssel'];
}
// get all styles that apply
foreach($css as $selector => $style) {
$pos = strpos($selector, ' ');
// get specificity
$specificity = substr($selector, 0, $pos);
// remove specificity
$selector = substr($selector, $pos);
// check if this selector apply to current tag
if (self::isValidCSSSelectorForTag($dom, $key, $selector)) {
if (!in_array($selector, $selectors)) {
// add style if not already added on parent selector
$cssarray[] = array('k' => $selector, 's' => $specificity, 'c' => $style);
$selectors[] = $selector;
}
}
}
if (isset($dom[$key]['attribute']['style'])) {
// attach inline style (latest properties have high priority)
$cssarray[] = array('k' => '', 's' => '1000', 'c' => $dom[$key]['attribute']['style']);
}
// order the css array to account for specificity
$cssordered = array();
foreach ($cssarray as $key => $val) {
$skey = sprintf('%04d', $key);
$cssordered[$val['s'].'_'.$skey] = $val;
}
// sort selectors alphabetically to account for specificity
ksort($cssordered, SORT_STRING);
return array($selectors, $cssordered);
}
/**
* Compact CSS data array into single string.
* @param $css (array) array of CSS properties
* @return string containing merged CSS properties
* @since 5.9.070 (2011-04-19)
* @public static
*/
public static function getTagStyleFromCSSarray($css) {
$tagstyle = ''; // value to be returned
foreach ($css as $style) {
// split single css commands
$csscmds = explode(';', $style['c']);
foreach ($csscmds as $cmd) {
if (!empty($cmd)) {
$pos = strpos($cmd, ':');
if ($pos !== false) {
$cmd = substr($cmd, 0, ($pos + 1));
if (strpos($tagstyle, $cmd) !== false) {
// remove duplicate commands (last commands have high priority)
$tagstyle = preg_replace('/'.$cmd.'[^;]+/i', '', $tagstyle);
}
}
}
}
$tagstyle .= ';'.$style['c'];
}
// remove multiple semicolons
$tagstyle = preg_replace('/[;]+/', ';', $tagstyle);
return $tagstyle;
}
/**
* Returns the Roman representation of an integer number
* @param $number (int) number to convert
* @return string roman representation of the specified number
* @since 4.4.004 (2008-12-10)
* @public static
*/
public static function intToRoman($number) {
$roman = '';
while ($number >= 1000) {
$roman .= 'M';
$number -= 1000;
}
while ($number >= 900) {
$roman .= 'CM';
$number -= 900;
}
while ($number >= 500) {
$roman .= 'D';
$number -= 500;
}
while ($number >= 400) {
$roman .= 'CD';
$number -= 400;
}
while ($number >= 100) {
$roman .= 'C';
$number -= 100;
}
while ($number >= 90) {
$roman .= 'XC';
$number -= 90;
}
while ($number >= 50) {
$roman .= 'L';
$number -= 50;
}
while ($number >= 40) {
$roman .= 'XL';
$number -= 40;
}
while ($number >= 10) {
$roman .= 'X';
$number -= 10;
}
while ($number >= 9) {
$roman .= 'IX';
$number -= 9;
}
while ($number >= 5) {
$roman .= 'V';
$number -= 5;
}
while ($number >= 4) {
$roman .= 'IV';
$number -= 4;
}
while ($number >= 1) {
$roman .= 'I';
--$number;
}
return $roman;
}
/**
* Find position of last occurrence of a substring in a string
* @param $haystack (string) The string to search in.
* @param $needle (string) substring to search.
* @param $offset (int) May be specified to begin searching an arbitrary number of characters into the string.
* @return Returns the position where the needle exists. Returns FALSE if the needle was not found.
* @since 4.8.038 (2010-03-13)
* @public static
*/
public static function revstrpos($haystack, $needle, $offset = 0) {
$length = strlen($haystack);
$offset = ($offset > 0)?($length - $offset):abs($offset);
$pos = strpos(strrev($haystack), strrev($needle), $offset);
return ($pos === false)?false:($length - $pos - strlen($needle));
}
/**
* Returns an array of hyphenation patterns.
* @param $file (string) TEX file containing hypenation patterns. TEX pattrns can be downloaded from http://www.ctan.org/tex-archive/language/hyph-utf8/tex/generic/hyph-utf8/patterns/
* @return array of hyphenation patterns
* @author Nicola Asuni
* @since 4.9.012 (2010-04-12)
* @public static
*/
public static function getHyphenPatternsFromTEX($file) {
// TEX patterns are available at:
// http://www.ctan.org/tex-archive/language/hyph-utf8/tex/generic/hyph-utf8/patterns/
$data = file_get_contents($file);
$patterns = array();
// remove comments
$data = preg_replace('/\%[^\n]*/', '', $data);
// extract the patterns part
preg_match('/\\\\patterns\{([^\}]*)\}/i', $data, $matches);
$data = trim(substr($matches[0], 10, -1));
// extract each pattern
$patterns_array = preg_split('/[\s]+/', $data);
// create new language array of patterns
$patterns = array();
foreach($patterns_array as $val) {
if (!TCPDF_STATIC::empty_string($val)) {
$val = trim($val);
$val = str_replace('\'', '\\\'', $val);
$key = preg_replace('/[0-9]+/', '', $val);
$patterns[$key] = $val;
}
}
return $patterns;
}
/**
* Get the Path-Painting Operators.
* @param $style (string) Style of rendering. Possible values are:
* <ul>
* <li>S or D: Stroke the path.</li>
* <li>s or d: Close and stroke the path.</li>
* <li>f or F: Fill the path, using the nonzero winding number rule to determine the region to fill.</li>
* <li>f* or F*: Fill the path, using the even-odd rule to determine the region to fill.</li>
* <li>B or FD or DF: Fill and then stroke the path, using the nonzero winding number rule to determine the region to fill.</li>
* <li>B* or F*D or DF*: Fill and then stroke the path, using the even-odd rule to determine the region to fill.</li>
* <li>b or fd or df: Close, fill, and then stroke the path, using the nonzero winding number rule to determine the region to fill.</li>
* <li>b or f*d or df*: Close, fill, and then stroke the path, using the even-odd rule to determine the region to fill.</li>
* <li>CNZ: Clipping mode using the even-odd rule to determine which regions lie inside the clipping path.</li>
* <li>CEO: Clipping mode using the nonzero winding number rule to determine which regions lie inside the clipping path</li>
* <li>n: End the path object without filling or stroking it.</li>
* </ul>
* @param $default (string) default style
* @author Nicola Asuni
* @since 5.0.000 (2010-04-30)
* @public static
*/
public static function getPathPaintOperator($style, $default='S') {
$op = '';
switch($style) {
case 'S':
case 'D': {
$op = 'S';
break;
}
case 's':
case 'd': {
$op = 's';
break;
}
case 'f':
case 'F': {
$op = 'f';
break;
}
case 'f*':
case 'F*': {
$op = 'f*';
break;
}
case 'B':
case 'FD':
case 'DF': {
$op = 'B';
break;
}
case 'B*':
case 'F*D':
case 'DF*': {
$op = 'B*';
break;
}
case 'b':
case 'fd':
case 'df': {
$op = 'b';
break;
}
case 'b*':
case 'f*d':
case 'df*': {
$op = 'b*';
break;
}
case 'CNZ': {
$op = 'W n';
break;
}
case 'CEO': {
$op = 'W* n';
break;
}
case 'n': {
$op = 'n';
break;
}
default: {
if (!empty($default)) {
$op = self::getPathPaintOperator($default, '');
} else {
$op = '';
}
}
}
return $op;
}
/**
* Get the product of two SVG tranformation matrices
* @param $ta (array) first SVG tranformation matrix
* @param $tb (array) second SVG tranformation matrix
* @return transformation array
* @author Nicola Asuni
* @since 5.0.000 (2010-05-02)
* @public static
*/
public static function getTransformationMatrixProduct($ta, $tb) {
$tm = array();
$tm[0] = ($ta[0] * $tb[0]) + ($ta[2] * $tb[1]);
$tm[1] = ($ta[1] * $tb[0]) + ($ta[3] * $tb[1]);
$tm[2] = ($ta[0] * $tb[2]) + ($ta[2] * $tb[3]);
$tm[3] = ($ta[1] * $tb[2]) + ($ta[3] * $tb[3]);
$tm[4] = ($ta[0] * $tb[4]) + ($ta[2] * $tb[5]) + $ta[4];
$tm[5] = ($ta[1] * $tb[4]) + ($ta[3] * $tb[5]) + $ta[5];
return $tm;
}
/**
* Get the tranformation matrix from SVG transform attribute
* @param $attribute (string) transformation
* @return array of transformations
* @author Nicola Asuni
* @since 5.0.000 (2010-05-02)
* @public static
*/
public static function getSVGTransformMatrix($attribute) {
// identity matrix
$tm = array(1, 0, 0, 1, 0, 0);
$transform = array();
if (preg_match_all('/(matrix|translate|scale|rotate|skewX|skewY)[\s]*\(([^\)]+)\)/si', $attribute, $transform, PREG_SET_ORDER) > 0) {
foreach ($transform as $key => $data) {
if (!empty($data[2])) {
$a = 1;
$b = 0;
$c = 0;
$d = 1;
$e = 0;
$f = 0;
$regs = array();
switch ($data[1]) {
case 'matrix': {
if (preg_match('/([a-z0-9\-\.]+)[\,\s]+([a-z0-9\-\.]+)[\,\s]+([a-z0-9\-\.]+)[\,\s]+([a-z0-9\-\.]+)[\,\s]+([a-z0-9\-\.]+)[\,\s]+([a-z0-9\-\.]+)/si', $data[2], $regs)) {
$a = $regs[1];
$b = $regs[2];
$c = $regs[3];
$d = $regs[4];
$e = $regs[5];
$f = $regs[6];
}
break;
}
case 'translate': {
if (preg_match('/([a-z0-9\-\.]+)[\,\s]+([a-z0-9\-\.]+)/si', $data[2], $regs)) {
$e = $regs[1];
$f = $regs[2];
} elseif (preg_match('/([a-z0-9\-\.]+)/si', $data[2], $regs)) {
$e = $regs[1];
}
break;
}
case 'scale': {
if (preg_match('/([a-z0-9\-\.]+)[\,\s]+([a-z0-9\-\.]+)/si', $data[2], $regs)) {
$a = $regs[1];
$d = $regs[2];
} elseif (preg_match('/([a-z0-9\-\.]+)/si', $data[2], $regs)) {
$a = $regs[1];
$d = $a;
}
break;
}
case 'rotate': {
if (preg_match('/([0-9\-\.]+)[\,\s]+([a-z0-9\-\.]+)[\,\s]+([a-z0-9\-\.]+)/si', $data[2], $regs)) {
$ang = deg2rad($regs[1]);
$x = $regs[2];
$y = $regs[3];
$a = cos($ang);
$b = sin($ang);
$c = -$b;
$d = $a;
$e = ($x * (1 - $a)) - ($y * $c);
$f = ($y * (1 - $d)) - ($x * $b);
} elseif (preg_match('/([0-9\-\.]+)/si', $data[2], $regs)) {
$ang = deg2rad($regs[1]);
$a = cos($ang);
$b = sin($ang);
$c = -$b;
$d = $a;
$e = 0;
$f = 0;
}
break;
}
case 'skewX': {
if (preg_match('/([0-9\-\.]+)/si', $data[2], $regs)) {
$c = tan(deg2rad($regs[1]));
}
break;
}
case 'skewY': {
if (preg_match('/([0-9\-\.]+)/si', $data[2], $regs)) {
$b = tan(deg2rad($regs[1]));
}
break;
}
}
$tm = self::getTransformationMatrixProduct($tm, array($a, $b, $c, $d, $e, $f));
}
}
}
return $tm;
}
/**
* Returns the angle in radiants between two vectors
* @param $x1 (int) X coordinate of first vector point
* @param $y1 (int) Y coordinate of first vector point
* @param $x2 (int) X coordinate of second vector point
* @param $y2 (int) Y coordinate of second vector point
* @author Nicola Asuni
* @since 5.0.000 (2010-05-04)
* @public static
*/
public static function getVectorsAngle($x1, $y1, $x2, $y2) {
$dprod = ($x1 * $x2) + ($y1 * $y2);
$dist1 = sqrt(($x1 * $x1) + ($y1 * $y1));
$dist2 = sqrt(($x2 * $x2) + ($y2 * $y2));
$angle = acos($dprod / ($dist1 * $dist2));
if (is_nan($angle)) {
$angle = M_PI;
}
if ((($x1 * $y2) - ($x2 * $y1)) < 0) {
$angle *= -1;
}
return $angle;
}
// ====================================================================================================================
// REIMPLEMENTED
// ====================================================================================================================
/**
* Split string by a regular expression.
* This is a wrapper for the preg_split function to avoid the bug: https://bugs.php.net/bug.php?id=45850
* @param $pattern (string) The regular expression pattern to search for without the modifiers, as a string.
* @param $modifiers (string) The modifiers part of the pattern,
* @param $subject (string) The input string.
* @param $limit (int) 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.
* @param $flags (int) The flags as specified on the preg_split PHP function.
* @return Returns an array containing substrings of subject split along boundaries matched by pattern.modifier
* @author Nicola Asuni
* @since 6.0.023
* @public static
*/
public static function pregSplit($pattern, $modifiers, $subject, $limit=NULL, $flags=NULL) {
// the bug only happens on PHP 5.2 when using the u modifier
if ((strpos($modifiers, 'u') === FALSE) OR (count(preg_split('//u', "\n\t", -1, PREG_SPLIT_NO_EMPTY)) == 2)) {
return preg_split($pattern.$modifiers, $subject, $limit, $flags);
}
// preg_split is bugged - try alternative solution
$ret = array();
while (($nl = strpos($subject, "\n")) !== FALSE) {
$ret = array_merge($ret, preg_split($pattern.$modifiers, substr($subject, 0, $nl), $limit, $flags));
$ret[] = "\n";
$subject = substr($subject, ($nl + 1));
}
if (strlen($subject) > 0) {
$ret = array_merge($ret, preg_split($pattern.$modifiers, $subject, $limit, $flags));
}
return $ret;
}
/**
* Wrapper to use fopen only with local files
* @param filename (string) Name of the file to open
* @param $mode (string)
* @return Returns a file pointer resource on success, or FALSE on error.
* @public static
*/
public static function fopenLocal($filename, $mode) {
if (strpos($filename, '://') === false) {
$filename = 'file://'.$filename;
} elseif (stream_is_local($filename) !== true) {
return false;
}
return fopen($filename, $mode);
}
/**
* Reads entire file into a string.
* The file can be also an URL.
* @param $file (string) Name of the file or URL to read.
* @return The function returns the read data or FALSE on failure.
* @author Nicola Asuni
* @since 6.0.025
* @public static
*/
public static function fileGetContents($file) {
$alt = array($file);
//
if ((strlen($file) > 1)
&& ($file[0] === '/')
&& ($file[1] !== '/')
&& !empty($_SERVER['DOCUMENT_ROOT'])
&& ($_SERVER['DOCUMENT_ROOT'] !== '/')
) {
$findroot = strpos($file, $_SERVER['DOCUMENT_ROOT']);
if (($findroot === false) || ($findroot > 1)) {
$alt[] = htmlspecialchars_decode(urldecode($_SERVER['DOCUMENT_ROOT'].$file));
}
}
//
$protocol = 'http';
if (!empty($_SERVER['HTTPS']) && (strtolower($_SERVER['HTTPS']) != 'off')) {
$protocol .= 's';
}
//
$url = $file;
if (preg_match('%^//%', $url) && !empty($_SERVER['HTTP_HOST'])) {
$url = $protocol.':'.str_replace(' ', '%20', $url);
}
$url = htmlspecialchars_decode($url);
$alt[] = $url;
//
if (preg_match('%^(https?)://%', $url)
&& empty($_SERVER['HTTP_HOST'])
&& empty($_SERVER['DOCUMENT_ROOT'])
) {
$urldata = parse_url($url);
if (empty($urldata['query'])) {
$host = $protocol.'://'.$_SERVER['HTTP_HOST'];
if (strpos($url, $host) === 0) {
// convert URL to full server path
$tmp = str_replace($host, $_SERVER['DOCUMENT_ROOT'], $url);
$alt[] = htmlspecialchars_decode(urldecode($tmp));
}
}
}
//
if (isset($_SERVER['SCRIPT_URI'])
&& !preg_match('%^(https?|ftp)://%', $file)
&& !preg_match('%^//%', $file)
) {
$urldata = @parse_url($_SERVER['SCRIPT_URI']);
return $urldata['scheme'].'://'.$urldata['host'].(($file[0] == '/') ? '' : '/').$file;
}
//
$alt = array_unique($alt);
//var_dump($alt);exit;//DEBUG
foreach ($alt as $path) {
$ret = @file_get_contents($path);
if ($ret !== false) {
return $ret;
}
// try to use CURL for URLs
if (!ini_get('allow_url_fopen')
&& function_exists('curl_init')
&& preg_match('%^(https?|ftp)://%', $path)
) {
// try to get remote file data using cURL
$crs = curl_init();
curl_setopt($crs, CURLOPT_URL, $path);
curl_setopt($crs, CURLOPT_BINARYTRANSFER, true);
curl_setopt($crs, CURLOPT_FAILONERROR, true);
curl_setopt($crs, CURLOPT_RETURNTRANSFER, true);
if ((ini_get('open_basedir') == '') && (!ini_get('safe_mode'))) {
curl_setopt($crs, CURLOPT_FOLLOWLOCATION, true);
}
curl_setopt($crs, CURLOPT_CONNECTTIMEOUT, 5);
curl_setopt($crs, CURLOPT_TIMEOUT, 30);
curl_setopt($crs, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($crs, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($crs, CURLOPT_USERAGENT, 'tc-lib-file');
$ret = curl_exec($crs);
curl_close($crs);
if ($ret !== false) {
return $ret;
}
}
}
return false;
}
/**
* Get ULONG from string (Big Endian 32-bit unsigned integer).
* @param $str (string) string from where to extract value
* @param $offset (int) point from where to read the data
* @return int 32 bit value
* @author Nicola Asuni
* @since 5.2.000 (2010-06-02)
* @public static
*/
public static function _getULONG($str, $offset) {
$v = unpack('Ni', substr($str, $offset, 4));
return $v['i'];
}
/**
* Get USHORT from string (Big Endian 16-bit unsigned integer).
* @param $str (string) string from where to extract value
* @param $offset (int) point from where to read the data
* @return int 16 bit value
* @author Nicola Asuni
* @since 5.2.000 (2010-06-02)
* @public static
*/
public static function _getUSHORT($str, $offset) {
$v = unpack('ni', substr($str, $offset, 2));
return $v['i'];
}
/**
* Get SHORT from string (Big Endian 16-bit signed integer).
* @param $str (string) String from where to extract value.
* @param $offset (int) Point from where to read the data.
* @return int 16 bit value
* @author Nicola Asuni
* @since 5.2.000 (2010-06-02)
* @public static
*/
public static function _getSHORT($str, $offset) {
$v = unpack('si', substr($str, $offset, 2));
return $v['i'];
}
/**
* Get FWORD from string (Big Endian 16-bit signed integer).
* @param $str (string) String from where to extract value.
* @param $offset (int) Point from where to read the data.
* @return int 16 bit value
* @author Nicola Asuni
* @since 5.9.123 (2011-09-30)
* @public static
*/
public static function _getFWORD($str, $offset) {
$v = self::_getUSHORT($str, $offset);
if ($v > 0x7fff) {
$v -= 0x10000;
}
return $v;
}
/**
* Get UFWORD from string (Big Endian 16-bit unsigned integer).
* @param $str (string) string from where to extract value
* @param $offset (int) point from where to read the data
* @return int 16 bit value
* @author Nicola Asuni
* @since 5.9.123 (2011-09-30)
* @public static
*/
public static function _getUFWORD($str, $offset) {
$v = self::_getUSHORT($str, $offset);
return $v;
}
/**
* Get FIXED from string (32-bit signed fixed-point number (16.16).
* @param $str (string) string from where to extract value
* @param $offset (int) point from where to read the data
* @return int 16 bit value
* @author Nicola Asuni
* @since 5.9.123 (2011-09-30)
* @public static
*/
public static function _getFIXED($str, $offset) {
// mantissa
$m = self::_getFWORD($str, $offset);
// fraction
$f = self::_getUSHORT($str, ($offset + 2));
$v = floatval(''.$m.'.'.$f.'');
return $v;
}
/**
* Get BYTE from string (8-bit unsigned integer).
* @param $str (string) String from where to extract value.
* @param $offset (int) Point from where to read the data.
* @return int 8 bit value
* @author Nicola Asuni
* @since 5.2.000 (2010-06-02)
* @public static
*/
public static function _getBYTE($str, $offset) {
$v = unpack('Ci', substr($str, $offset, 1));
return $v['i'];
}
/**
* Binary-safe and URL-safe file read.
* 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.
* @param $handle (resource)
* @param $length (int)
* @return Returns the read string or FALSE in case of error.
* @author Nicola Asuni
* @since 4.5.027 (2009-03-16)
* @public static
*/
public static function rfread($handle, $length) {
$data = fread($handle, $length);
if ($data === false) {
return false;
}
$rest = ($length - strlen($data));
if (($rest > 0) && !feof($handle)) {
$data .= self::rfread($handle, $rest);
}
return $data;
}
/**
* Read a 4-byte (32 bit) integer from file.
* @param $f (string) file name.
* @return 4-byte integer
* @public static
*/
public static function _freadint($f) {
$a = unpack('Ni', fread($f, 4));
return $a['i'];
}
/**
* Array of page formats
* measures are calculated in this way: (inches * 72) or (millimeters * 72 / 25.4)
* @public static
*/
public static $page_formats = array(
// ISO 216 A Series + 2 SIS 014711 extensions
'A0' => array( 2383.937, 3370.394), // = ( 841 x 1189 ) mm = ( 33.11 x 46.81 ) in
'A1' => array( 1683.780, 2383.937), // = ( 594 x 841 ) mm = ( 23.39 x 33.11 ) in
'A2' => array( 1190.551, 1683.780), // = ( 420 x 594 ) mm = ( 16.54 x 23.39 ) in
'A3' => array( 841.890, 1190.551), // = ( 297 x 420 ) mm = ( 11.69 x 16.54 ) in
'A4' => array( 595.276, 841.890), // = ( 210 x 297 ) mm = ( 8.27 x 11.69 ) in
'A5' => array( 419.528, 595.276), // = ( 148 x 210 ) mm = ( 5.83 x 8.27 ) in
'A6' => array( 297.638, 419.528), // = ( 105 x 148 ) mm = ( 4.13 x 5.83 ) in
'A7' => array( 209.764, 297.638), // = ( 74 x 105 ) mm = ( 2.91 x 4.13 ) in
'A8' => array( 147.402, 209.764), // = ( 52 x 74 ) mm = ( 2.05 x 2.91 ) in
'A9' => array( 104.882, 147.402), // = ( 37 x 52 ) mm = ( 1.46 x 2.05 ) in
'A10' => array( 73.701, 104.882), // = ( 26 x 37 ) mm = ( 1.02 x 1.46 ) in
'A11' => array( 51.024, 73.701), // = ( 18 x 26 ) mm = ( 0.71 x 1.02 ) in
'A12' => array( 36.850, 51.024), // = ( 13 x 18 ) mm = ( 0.51 x 0.71 ) in
// ISO 216 B Series + 2 SIS 014711 extensions
'B0' => array( 2834.646, 4008.189), // = ( 1000 x 1414 ) mm = ( 39.37 x 55.67 ) in
'B1' => array( 2004.094, 2834.646), // = ( 707 x 1000 ) mm = ( 27.83 x 39.37 ) in
'B2' => array( 1417.323, 2004.094), // = ( 500 x 707 ) mm = ( 19.69 x 27.83 ) in
'B3' => array( 1000.630, 1417.323), // = ( 353 x 500 ) mm = ( 13.90 x 19.69 ) in
'B4' => array( 708.661, 1000.630), // = ( 250 x 353 ) mm = ( 9.84 x 13.90 ) in
'B5' => array( 498.898, 708.661), // = ( 176 x 250 ) mm = ( 6.93 x 9.84 ) in
'B6' => array( 354.331, 498.898), // = ( 125 x 176 ) mm = ( 4.92 x 6.93 ) in
'B7' => array( 249.449, 354.331), // = ( 88 x 125 ) mm = ( 3.46 x 4.92 ) in
'B8' => array( 175.748, 249.449), // = ( 62 x 88 ) mm = ( 2.44 x 3.46 ) in
'B9' => array( 124.724, 175.748), // = ( 44 x 62 ) mm = ( 1.73 x 2.44 ) in
'B10' => array( 87.874, 124.724), // = ( 31 x 44 ) mm = ( 1.22 x 1.73 ) in
'B11' => array( 62.362, 87.874), // = ( 22 x 31 ) mm = ( 0.87 x 1.22 ) in
'B12' => array( 42.520, 62.362), // = ( 15 x 22 ) mm = ( 0.59 x 0.87 ) in
// ISO 216 C Series + 2 SIS 014711 extensions + 5 EXTENSION
'C0' => array( 2599.370, 3676.535), // = ( 917 x 1297 ) mm = ( 36.10 x 51.06 ) in
'C1' => array( 1836.850, 2599.370), // = ( 648 x 917 ) mm = ( 25.51 x 36.10 ) in
'C2' => array( 1298.268, 1836.850), // = ( 458 x 648 ) mm = ( 18.03 x 25.51 ) in
'C3' => array( 918.425, 1298.268), // = ( 324 x 458 ) mm = ( 12.76 x 18.03 ) in
'C4' => array( 649.134, 918.425), // = ( 229 x 324 ) mm = ( 9.02 x 12.76 ) in
'C5' => array( 459.213, 649.134), // = ( 162 x 229 ) mm = ( 6.38 x 9.02 ) in
'C6' => array( 323.150, 459.213), // = ( 114 x 162 ) mm = ( 4.49 x 6.38 ) in
'C7' => array( 229.606, 323.150), // = ( 81 x 114 ) mm = ( 3.19 x 4.49 ) in
'C8' => array( 161.575, 229.606), // = ( 57 x 81 ) mm = ( 2.24 x 3.19 ) in
'C9' => array( 113.386, 161.575), // = ( 40 x 57 ) mm = ( 1.57 x 2.24 ) in
'C10' => array( 79.370, 113.386), // = ( 28 x 40 ) mm = ( 1.10 x 1.57 ) in
'C11' => array( 56.693, 79.370), // = ( 20 x 28 ) mm = ( 0.79 x 1.10 ) in
'C12' => array( 39.685, 56.693), // = ( 14 x 20 ) mm = ( 0.55 x 0.79 ) in
'C76' => array( 229.606, 459.213), // = ( 81 x 162 ) mm = ( 3.19 x 6.38 ) in
'DL' => array( 311.811, 623.622), // = ( 110 x 220 ) mm = ( 4.33 x 8.66 ) in
'DLE' => array( 323.150, 637.795), // = ( 114 x 225 ) mm = ( 4.49 x 8.86 ) in
'DLX' => array( 340.158, 666.142), // = ( 120 x 235 ) mm = ( 4.72 x 9.25 ) in
'DLP' => array( 280.630, 595.276), // = ( 99 x 210 ) mm = ( 3.90 x 8.27 ) in (1/3 A4)
// SIS 014711 E Series
'E0' => array( 2491.654, 3517.795), // = ( 879 x 1241 ) mm = ( 34.61 x 48.86 ) in
'E1' => array( 1757.480, 2491.654), // = ( 620 x 879 ) mm = ( 24.41 x 34.61 ) in
'E2' => array( 1247.244, 1757.480), // = ( 440 x 620 ) mm = ( 17.32 x 24.41 ) in
'E3' => array( 878.740, 1247.244), // = ( 310 x 440 ) mm = ( 12.20 x 17.32 ) in
'E4' => array( 623.622, 878.740), // = ( 220 x 310 ) mm = ( 8.66 x 12.20 ) in
'E5' => array( 439.370, 623.622), // = ( 155 x 220 ) mm = ( 6.10 x 8.66 ) in
'E6' => array( 311.811, 439.370), // = ( 110 x 155 ) mm = ( 4.33 x 6.10 ) in
'E7' => array( 221.102, 311.811), // = ( 78 x 110 ) mm = ( 3.07 x 4.33 ) in
'E8' => array( 155.906, 221.102), // = ( 55 x 78 ) mm = ( 2.17 x 3.07 ) in
'E9' => array( 110.551, 155.906), // = ( 39 x 55 ) mm = ( 1.54 x 2.17 ) in
'E10' => array( 76.535, 110.551), // = ( 27 x 39 ) mm = ( 1.06 x 1.54 ) in
'E11' => array( 53.858, 76.535), // = ( 19 x 27 ) mm = ( 0.75 x 1.06 ) in
'E12' => array( 36.850, 53.858), // = ( 13 x 19 ) mm = ( 0.51 x 0.75 ) in
// SIS 014711 G Series
'G0' => array( 2715.591, 3838.110), // = ( 958 x 1354 ) mm = ( 37.72 x 53.31 ) in
'G1' => array( 1919.055, 2715.591), // = ( 677 x 958 ) mm = ( 26.65 x 37.72 ) in
'G2' => array( 1357.795, 1919.055), // = ( 479 x 677 ) mm = ( 18.86 x 26.65 ) in
'G3' => array( 958.110, 1357.795), // = ( 338 x 479 ) mm = ( 13.31 x 18.86 ) in
'G4' => array( 677.480, 958.110), // = ( 239 x 338 ) mm = ( 9.41 x 13.31 ) in
'G5' => array( 479.055, 677.480), // = ( 169 x 239 ) mm = ( 6.65 x 9.41 ) in
'G6' => array( 337.323, 479.055), // = ( 119 x 169 ) mm = ( 4.69 x 6.65 ) in
'G7' => array( 238.110, 337.323), // = ( 84 x 119 ) mm = ( 3.31 x 4.69 ) in
'G8' => array( 167.244, 238.110), // = ( 59 x 84 ) mm = ( 2.32 x 3.31 ) in
'G9' => array( 119.055, 167.244), // = ( 42 x 59 ) mm = ( 1.65 x 2.32 ) in
'G10' => array( 82.205, 119.055), // = ( 29 x 42 ) mm = ( 1.14 x 1.65 ) in
'G11' => array( 59.528, 82.205), // = ( 21 x 29 ) mm = ( 0.83 x 1.14 ) in
'G12' => array( 39.685, 59.528), // = ( 14 x 21 ) mm = ( 0.55 x 0.83 ) in
// ISO Press
'RA0' => array( 2437.795, 3458.268), // = ( 860 x 1220 ) mm = ( 33.86 x 48.03 ) in
'RA1' => array( 1729.134, 2437.795), // = ( 610 x 860 ) mm = ( 24.02 x 33.86 ) in
'RA2' => array( 1218.898, 1729.134), // = ( 430 x 610 ) mm = ( 16.93 x 24.02 ) in
'RA3' => array( 864.567, 1218.898), // = ( 305 x 430 ) mm = ( 12.01 x 16.93 ) in
'RA4' => array( 609.449, 864.567), // = ( 215 x 305 ) mm = ( 8.46 x 12.01 ) in
'SRA0' => array( 2551.181, 3628.346), // = ( 900 x 1280 ) mm = ( 35.43 x 50.39 ) in
'SRA1' => array( 1814.173, 2551.181), // = ( 640 x 900 ) mm = ( 25.20 x 35.43 ) in
'SRA2' => array( 1275.591, 1814.173), // = ( 450 x 640 ) mm = ( 17.72 x 25.20 ) in
'SRA3' => array( 907.087, 1275.591), // = ( 320 x 450 ) mm = ( 12.60 x 17.72 ) in
'SRA4' => array( 637.795, 907.087), // = ( 225 x 320 ) mm = ( 8.86 x 12.60 ) in
// German DIN 476
'4A0' => array( 4767.874, 6740.787), // = ( 1682 x 2378 ) mm = ( 66.22 x 93.62 ) in
'2A0' => array( 3370.394, 4767.874), // = ( 1189 x 1682 ) mm = ( 46.81 x 66.22 ) in
// Variations on the ISO Standard
'A2_EXTRA' => array( 1261.417, 1754.646), // = ( 445 x 619 ) mm = ( 17.52 x 24.37 ) in
'A3+' => array( 932.598, 1369.134), // = ( 329 x 483 ) mm = ( 12.95 x 19.02 ) in
'A3_EXTRA' => array( 912.756, 1261.417), // = ( 322 x 445 ) mm = ( 12.68 x 17.52 ) in
'A3_SUPER' => array( 864.567, 1440.000), // = ( 305 x 508 ) mm = ( 12.01 x 20.00 ) in
'SUPER_A3' => array( 864.567, 1380.472), // = ( 305 x 487 ) mm = ( 12.01 x 19.17 ) in
'A4_EXTRA' => array( 666.142, 912.756), // = ( 235 x 322 ) mm = ( 9.25 x 12.68 ) in
'A4_SUPER' => array( 649.134, 912.756), // = ( 229 x 322 ) mm = ( 9.02 x 12.68 ) in
'SUPER_A4' => array( 643.465, 1009.134), // = ( 227 x 356 ) mm = ( 8.94 x 14.02 ) in
'A4_LONG' => array( 595.276, 986.457), // = ( 210 x 348 ) mm = ( 8.27 x 13.70 ) in
'F4' => array( 595.276, 935.433), // = ( 210 x 330 ) mm = ( 8.27 x 12.99 ) in
'SO_B5_EXTRA' => array( 572.598, 782.362), // = ( 202 x 276 ) mm = ( 7.95 x 10.87 ) in
'A5_EXTRA' => array( 490.394, 666.142), // = ( 173 x 235 ) mm = ( 6.81 x 9.25 ) in
// ANSI Series
'ANSI_E' => array( 2448.000, 3168.000), // = ( 864 x 1118 ) mm = ( 34.00 x 44.00 ) in
'ANSI_D' => array( 1584.000, 2448.000), // = ( 559 x 864 ) mm = ( 22.00 x 34.00 ) in
'ANSI_C' => array( 1224.000, 1584.000), // = ( 432 x 559 ) mm = ( 17.00 x 22.00 ) in
'ANSI_B' => array( 792.000, 1224.000), // = ( 279 x 432 ) mm = ( 11.00 x 17.00 ) in
'ANSI_A' => array( 612.000, 792.000), // = ( 216 x 279 ) mm = ( 8.50 x 11.00 ) in
// Traditional 'Loose' North American Paper Sizes
'USLEDGER' => array( 1224.000, 792.000), // = ( 432 x 279 ) mm = ( 17.00 x 11.00 ) in
'LEDGER' => array( 1224.000, 792.000), // = ( 432 x 279 ) mm = ( 17.00 x 11.00 ) in
'ORGANIZERK' => array( 792.000, 1224.000), // = ( 279 x 432 ) mm = ( 11.00 x 17.00 ) in
'BIBLE' => array( 792.000, 1224.000), // = ( 279 x 432 ) mm = ( 11.00 x 17.00 ) in
'USTABLOID' => array( 792.000, 1224.000), // = ( 279 x 432 ) mm = ( 11.00 x 17.00 ) in
'TABLOID' => array( 792.000, 1224.000), // = ( 279 x 432 ) mm = ( 11.00 x 17.00 ) in
'ORGANIZERM' => array( 612.000, 792.000), // = ( 216 x 279 ) mm = ( 8.50 x 11.00 ) in
'USLETTER' => array( 612.000, 792.000), // = ( 216 x 279 ) mm = ( 8.50 x 11.00 ) in
'LETTER' => array( 612.000, 792.000), // = ( 216 x 279 ) mm = ( 8.50 x 11.00 ) in
'USLEGAL' => array( 612.000, 1008.000), // = ( 216 x 356 ) mm = ( 8.50 x 14.00 ) in
'LEGAL' => array( 612.000, 1008.000), // = ( 216 x 356 ) mm = ( 8.50 x 14.00 ) in
'GOVERNMENTLETTER' => array( 576.000, 756.000), // = ( 203 x 267 ) mm = ( 8.00 x 10.50 ) in
'GLETTER' => array( 576.000, 756.000), // = ( 203 x 267 ) mm = ( 8.00 x 10.50 ) in
'JUNIORLEGAL' => array( 576.000, 360.000), // = ( 203 x 127 ) mm = ( 8.00 x 5.00 ) in
'JLEGAL' => array( 576.000, 360.000), // = ( 203 x 127 ) mm = ( 8.00 x 5.00 ) in
// Other North American Paper Sizes
'QUADDEMY' => array( 2520.000, 3240.000), // = ( 889 x 1143 ) mm = ( 35.00 x 45.00 ) in
'SUPER_B' => array( 936.000, 1368.000), // = ( 330 x 483 ) mm = ( 13.00 x 19.00 ) in
'QUARTO' => array( 648.000, 792.000), // = ( 229 x 279 ) mm = ( 9.00 x 11.00 ) in
'GOVERNMENTLEGAL' => array( 612.000, 936.000), // = ( 216 x 330 ) mm = ( 8.50 x 13.00 ) in
'FOLIO' => array( 612.000, 936.000), // = ( 216 x 330 ) mm = ( 8.50 x 13.00 ) in
'MONARCH' => array( 522.000, 756.000), // = ( 184 x 267 ) mm = ( 7.25 x 10.50 ) in
'EXECUTIVE' => array( 522.000, 756.000), // = ( 184 x 267 ) mm = ( 7.25 x 10.50 ) in
'ORGANIZERL' => array( 396.000, 612.000), // = ( 140 x 216 ) mm = ( 5.50 x 8.50 ) in
'STATEMENT' => array( 396.000, 612.000), // = ( 140 x 216 ) mm = ( 5.50 x 8.50 ) in
'MEMO' => array( 396.000, 612.000), // = ( 140 x 216 ) mm = ( 5.50 x 8.50 ) in
'FOOLSCAP' => array( 595.440, 936.000), // = ( 210 x 330 ) mm = ( 8.27 x 13.00 ) in
'COMPACT' => array( 306.000, 486.000), // = ( 108 x 171 ) mm = ( 4.25 x 6.75 ) in
'ORGANIZERJ' => array( 198.000, 360.000), // = ( 70 x 127 ) mm = ( 2.75 x 5.00 ) in
// Canadian standard CAN 2-9.60M
'P1' => array( 1587.402, 2437.795), // = ( 560 x 860 ) mm = ( 22.05 x 33.86 ) in
'P2' => array( 1218.898, 1587.402), // = ( 430 x 560 ) mm = ( 16.93 x 22.05 ) in
'P3' => array( 793.701, 1218.898), // = ( 280 x 430 ) mm = ( 11.02 x 16.93 ) in
'P4' => array( 609.449, 793.701), // = ( 215 x 280 ) mm = ( 8.46 x 11.02 ) in
'P5' => array( 396.850, 609.449), // = ( 140 x 215 ) mm = ( 5.51 x 8.46 ) in
'P6' => array( 303.307, 396.850), // = ( 107 x 140 ) mm = ( 4.21 x 5.51 ) in
// North American Architectural Sizes
'ARCH_E' => array( 2592.000, 3456.000), // = ( 914 x 1219 ) mm = ( 36.00 x 48.00 ) in
'ARCH_E1' => array( 2160.000, 3024.000), // = ( 762 x 1067 ) mm = ( 30.00 x 42.00 ) in
'ARCH_D' => array( 1728.000, 2592.000), // = ( 610 x 914 ) mm = ( 24.00 x 36.00 ) in
'BROADSHEET' => array( 1296.000, 1728.000), // = ( 457 x 610 ) mm = ( 18.00 x 24.00 ) in
'ARCH_C' => array( 1296.000, 1728.000), // = ( 457 x 610 ) mm = ( 18.00 x 24.00 ) in
'ARCH_B' => array( 864.000, 1296.000), // = ( 305 x 457 ) mm = ( 12.00 x 18.00 ) in
'ARCH_A' => array( 648.000, 864.000), // = ( 229 x 305 ) mm = ( 9.00 x 12.00 ) in
// -- North American Envelope Sizes
// - Announcement Envelopes
'ANNENV_A2' => array( 314.640, 414.000), // = ( 111 x 146 ) mm = ( 4.37 x 5.75 ) in
'ANNENV_A6' => array( 342.000, 468.000), // = ( 121 x 165 ) mm = ( 4.75 x 6.50 ) in
'ANNENV_A7' => array( 378.000, 522.000), // = ( 133 x 184 ) mm = ( 5.25 x 7.25 ) in
'ANNENV_A8' => array( 396.000, 584.640), // = ( 140 x 206 ) mm = ( 5.50 x 8.12 ) in
'ANNENV_A10' => array( 450.000, 692.640), // = ( 159 x 244 ) mm = ( 6.25 x 9.62 ) in
'ANNENV_SLIM' => array( 278.640, 638.640), // = ( 98 x 225 ) mm = ( 3.87 x 8.87 ) in
// - Commercial Envelopes
'COMMENV_N6_1/4' => array( 252.000, 432.000), // = ( 89 x 152 ) mm = ( 3.50 x 6.00 ) in
'COMMENV_N6_3/4' => array( 260.640, 468.000), // = ( 92 x 165 ) mm = ( 3.62 x 6.50 ) in
'COMMENV_N8' => array( 278.640, 540.000), // = ( 98 x 191 ) mm = ( 3.87 x 7.50 ) in
'COMMENV_N9' => array( 278.640, 638.640), // = ( 98 x 225 ) mm = ( 3.87 x 8.87 ) in
'COMMENV_N10' => array( 296.640, 684.000), // = ( 105 x 241 ) mm = ( 4.12 x 9.50 ) in
'COMMENV_N11' => array( 324.000, 746.640), // = ( 114 x 263 ) mm = ( 4.50 x 10.37 ) in
'COMMENV_N12' => array( 342.000, 792.000), // = ( 121 x 279 ) mm = ( 4.75 x 11.00 ) in
'COMMENV_N14' => array( 360.000, 828.000), // = ( 127 x 292 ) mm = ( 5.00 x 11.50 ) in
// - Catalogue Envelopes
'CATENV_N1' => array( 432.000, 648.000), // = ( 152 x 229 ) mm = ( 6.00 x 9.00 ) in
'CATENV_N1_3/4' => array( 468.000, 684.000), // = ( 165 x 241 ) mm = ( 6.50 x 9.50 ) in
'CATENV_N2' => array( 468.000, 720.000), // = ( 165 x 254 ) mm = ( 6.50 x 10.00 ) in
'CATENV_N3' => array( 504.000, 720.000), // = ( 178 x 254 ) mm = ( 7.00 x 10.00 ) in
'CATENV_N6' => array( 540.000, 756.000), // = ( 191 x 267 ) mm = ( 7.50 x 10.50 ) in
'CATENV_N7' => array( 576.000, 792.000), // = ( 203 x 279 ) mm = ( 8.00 x 11.00 ) in
'CATENV_N8' => array( 594.000, 810.000), // = ( 210 x 286 ) mm = ( 8.25 x 11.25 ) in
'CATENV_N9_1/2' => array( 612.000, 756.000), // = ( 216 x 267 ) mm = ( 8.50 x 10.50 ) in
'CATENV_N9_3/4' => array( 630.000, 810.000), // = ( 222 x 286 ) mm = ( 8.75 x 11.25 ) in
'CATENV_N10_1/2' => array( 648.000, 864.000), // = ( 229 x 305 ) mm = ( 9.00 x 12.00 ) in
'CATENV_N12_1/2' => array( 684.000, 900.000), // = ( 241 x 318 ) mm = ( 9.50 x 12.50 ) in
'CATENV_N13_1/2' => array( 720.000, 936.000), // = ( 254 x 330 ) mm = ( 10.00 x 13.00 ) in
'CATENV_N14_1/4' => array( 810.000, 882.000), // = ( 286 x 311 ) mm = ( 11.25 x 12.25 ) in
'CATENV_N14_1/2' => array( 828.000, 1044.000), // = ( 292 x 368 ) mm = ( 11.50 x 14.50 ) in
// Japanese (JIS P 0138-61) Standard B-Series
'JIS_B0' => array( 2919.685, 4127.244), // = ( 1030 x 1456 ) mm = ( 40.55 x 57.32 ) in
'JIS_B1' => array( 2063.622, 2919.685), // = ( 728 x 1030 ) mm = ( 28.66 x 40.55 ) in
'JIS_B2' => array( 1459.843, 2063.622), // = ( 515 x 728 ) mm = ( 20.28 x 28.66 ) in
'JIS_B3' => array( 1031.811, 1459.843), // = ( 364 x 515 ) mm = ( 14.33 x 20.28 ) in
'JIS_B4' => array( 728.504, 1031.811), // = ( 257 x 364 ) mm = ( 10.12 x 14.33 ) in
'JIS_B5' => array( 515.906, 728.504), // = ( 182 x 257 ) mm = ( 7.17 x 10.12 ) in
'JIS_B6' => array( 362.835, 515.906), // = ( 128 x 182 ) mm = ( 5.04 x 7.17 ) in
'JIS_B7' => array( 257.953, 362.835), // = ( 91 x 128 ) mm = ( 3.58 x 5.04 ) in
'JIS_B8' => array( 181.417, 257.953), // = ( 64 x 91 ) mm = ( 2.52 x 3.58 ) in
'JIS_B9' => array( 127.559, 181.417), // = ( 45 x 64 ) mm = ( 1.77 x 2.52 ) in
'JIS_B10' => array( 90.709, 127.559), // = ( 32 x 45 ) mm = ( 1.26 x 1.77 ) in
'JIS_B11' => array( 62.362, 90.709), // = ( 22 x 32 ) mm = ( 0.87 x 1.26 ) in
'JIS_B12' => array( 45.354, 62.362), // = ( 16 x 22 ) mm = ( 0.63 x 0.87 ) in
// PA Series
'PA0' => array( 2381.102, 3174.803), // = ( 840 x 1120 ) mm = ( 33.07 x 44.09 ) in
'PA1' => array( 1587.402, 2381.102), // = ( 560 x 840 ) mm = ( 22.05 x 33.07 ) in
'PA2' => array( 1190.551, 1587.402), // = ( 420 x 560 ) mm = ( 16.54 x 22.05 ) in
'PA3' => array( 793.701, 1190.551), // = ( 280 x 420 ) mm = ( 11.02 x 16.54 ) in
'PA4' => array( 595.276, 793.701), // = ( 210 x 280 ) mm = ( 8.27 x 11.02 ) in
'PA5' => array( 396.850, 595.276), // = ( 140 x 210 ) mm = ( 5.51 x 8.27 ) in
'PA6' => array( 297.638, 396.850), // = ( 105 x 140 ) mm = ( 4.13 x 5.51 ) in
'PA7' => array( 198.425, 297.638), // = ( 70 x 105 ) mm = ( 2.76 x 4.13 ) in
'PA8' => array( 147.402, 198.425), // = ( 52 x 70 ) mm = ( 2.05 x 2.76 ) in
'PA9' => array( 99.213, 147.402), // = ( 35 x 52 ) mm = ( 1.38 x 2.05 ) in
'PA10' => array( 73.701, 99.213), // = ( 26 x 35 ) mm = ( 1.02 x 1.38 ) in
// Standard Photographic Print Sizes
'PASSPORT_PHOTO' => array( 99.213, 127.559), // = ( 35 x 45 ) mm = ( 1.38 x 1.77 ) in
'E' => array( 233.858, 340.157), // = ( 82 x 120 ) mm = ( 3.25 x 4.72 ) in
'L' => array( 252.283, 360.000), // = ( 89 x 127 ) mm = ( 3.50 x 5.00 ) in
'3R' => array( 252.283, 360.000), // = ( 89 x 127 ) mm = ( 3.50 x 5.00 ) in
'KG' => array( 289.134, 430.866), // = ( 102 x 152 ) mm = ( 4.02 x 5.98 ) in
'4R' => array( 289.134, 430.866), // = ( 102 x 152 ) mm = ( 4.02 x 5.98 ) in
'4D' => array( 340.157, 430.866), // = ( 120 x 152 ) mm = ( 4.72 x 5.98 ) in
'2L' => array( 360.000, 504.567), // = ( 127 x 178 ) mm = ( 5.00 x 7.01 ) in
'5R' => array( 360.000, 504.567), // = ( 127 x 178 ) mm = ( 5.00 x 7.01 ) in
'8P' => array( 430.866, 575.433), // = ( 152 x 203 ) mm = ( 5.98 x 7.99 ) in
'6R' => array( 430.866, 575.433), // = ( 152 x 203 ) mm = ( 5.98 x 7.99 ) in
'6P' => array( 575.433, 720.000), // = ( 203 x 254 ) mm = ( 7.99 x 10.00 ) in
'8R' => array( 575.433, 720.000), // = ( 203 x 254 ) mm = ( 7.99 x 10.00 ) in
'6PW' => array( 575.433, 864.567), // = ( 203 x 305 ) mm = ( 7.99 x 12.01 ) in
'S8R' => array( 575.433, 864.567), // = ( 203 x 305 ) mm = ( 7.99 x 12.01 ) in
'4P' => array( 720.000, 864.567), // = ( 254 x 305 ) mm = ( 10.00 x 12.01 ) in
'10R' => array( 720.000, 864.567), // = ( 254 x 305 ) mm = ( 10.00 x 12.01 ) in
'4PW' => array( 720.000, 1080.000), // = ( 254 x 381 ) mm = ( 10.00 x 15.00 ) in
'S10R' => array( 720.000, 1080.000), // = ( 254 x 381 ) mm = ( 10.00 x 15.00 ) in
'11R' => array( 790.866, 1009.134), // = ( 279 x 356 ) mm = ( 10.98 x 14.02 ) in
'S11R' => array( 790.866, 1224.567), // = ( 279 x 432 ) mm = ( 10.98 x 17.01 ) in
'12R' => array( 864.567, 1080.000), // = ( 305 x 381 ) mm = ( 12.01 x 15.00 ) in
'S12R' => array( 864.567, 1292.598), // = ( 305 x 456 ) mm = ( 12.01 x 17.95 ) in
// Common Newspaper Sizes
'NEWSPAPER_BROADSHEET' => array( 2125.984, 1700.787), // = ( 750 x 600 ) mm = ( 29.53 x 23.62 ) in
'NEWSPAPER_BERLINER' => array( 1332.283, 892.913), // = ( 470 x 315 ) mm = ( 18.50 x 12.40 ) in
'NEWSPAPER_TABLOID' => array( 1218.898, 793.701), // = ( 430 x 280 ) mm = ( 16.93 x 11.02 ) in
'NEWSPAPER_COMPACT' => array( 1218.898, 793.701), // = ( 430 x 280 ) mm = ( 16.93 x 11.02 ) in
// Business Cards
'CREDIT_CARD' => array( 153.014, 242.646), // = ( 54 x 86 ) mm = ( 2.13 x 3.37 ) in
'BUSINESS_CARD' => array( 153.014, 242.646), // = ( 54 x 86 ) mm = ( 2.13 x 3.37 ) in
'BUSINESS_CARD_ISO7810' => array( 153.014, 242.646), // = ( 54 x 86 ) mm = ( 2.13 x 3.37 ) in
'BUSINESS_CARD_ISO216' => array( 147.402, 209.764), // = ( 52 x 74 ) mm = ( 2.05 x 2.91 ) in
'BUSINESS_CARD_IT' => array( 155.906, 240.945), // = ( 55 x 85 ) mm = ( 2.17 x 3.35 ) in
'BUSINESS_CARD_UK' => array( 155.906, 240.945), // = ( 55 x 85 ) mm = ( 2.17 x 3.35 ) in
'BUSINESS_CARD_FR' => array( 155.906, 240.945), // = ( 55 x 85 ) mm = ( 2.17 x 3.35 ) in
'BUSINESS_CARD_DE' => array( 155.906, 240.945), // = ( 55 x 85 ) mm = ( 2.17 x 3.35 ) in
'BUSINESS_CARD_ES' => array( 155.906, 240.945), // = ( 55 x 85 ) mm = ( 2.17 x 3.35 ) in
'BUSINESS_CARD_CA' => array( 144.567, 252.283), // = ( 51 x 89 ) mm = ( 2.01 x 3.50 ) in
'BUSINESS_CARD_US' => array( 144.567, 252.283), // = ( 51 x 89 ) mm = ( 2.01 x 3.50 ) in
'BUSINESS_CARD_JP' => array( 155.906, 257.953), // = ( 55 x 91 ) mm = ( 2.17 x 3.58 ) in
'BUSINESS_CARD_HK' => array( 153.071, 255.118), // = ( 54 x 90 ) mm = ( 2.13 x 3.54 ) in
'BUSINESS_CARD_AU' => array( 155.906, 255.118), // = ( 55 x 90 ) mm = ( 2.17 x 3.54 ) in
'BUSINESS_CARD_DK' => array( 155.906, 255.118), // = ( 55 x 90 ) mm = ( 2.17 x 3.54 ) in
'BUSINESS_CARD_SE' => array( 155.906, 255.118), // = ( 55 x 90 ) mm = ( 2.17 x 3.54 ) in
'BUSINESS_CARD_RU' => array( 141.732, 255.118), // = ( 50 x 90 ) mm = ( 1.97 x 3.54 ) in
'BUSINESS_CARD_CZ' => array( 141.732, 255.118), // = ( 50 x 90 ) mm = ( 1.97 x 3.54 ) in
'BUSINESS_CARD_FI' => array( 141.732, 255.118), // = ( 50 x 90 ) mm = ( 1.97 x 3.54 ) in
'BUSINESS_CARD_HU' => array( 141.732, 255.118), // = ( 50 x 90 ) mm = ( 1.97 x 3.54 ) in
'BUSINESS_CARD_IL' => array( 141.732, 255.118), // = ( 50 x 90 ) mm = ( 1.97 x 3.54 ) in
// Billboards
'4SHEET' => array( 2880.000, 4320.000), // = ( 1016 x 1524 ) mm = ( 40.00 x 60.00 ) in
'6SHEET' => array( 3401.575, 5102.362), // = ( 1200 x 1800 ) mm = ( 47.24 x 70.87 ) in
'12SHEET' => array( 8640.000, 4320.000), // = ( 3048 x 1524 ) mm = (120.00 x 60.00 ) in
'16SHEET' => array( 5760.000, 8640.000), // = ( 2032 x 3048 ) mm = ( 80.00 x 120.00) in
'32SHEET' => array(11520.000, 8640.000), // = ( 4064 x 3048 ) mm = (160.00 x 120.00) in
'48SHEET' => array(17280.000, 8640.000), // = ( 6096 x 3048 ) mm = (240.00 x 120.00) in
'64SHEET' => array(23040.000, 8640.000), // = ( 8128 x 3048 ) mm = (320.00 x 120.00) in
'96SHEET' => array(34560.000, 8640.000), // = (12192 x 3048 ) mm = (480.00 x 120.00) in
// -- Old European Sizes
// - Old Imperial English Sizes
'EN_EMPEROR' => array( 3456.000, 5184.000), // = ( 1219 x 1829 ) mm = ( 48.00 x 72.00 ) in
'EN_ANTIQUARIAN' => array( 2232.000, 3816.000), // = ( 787 x 1346 ) mm = ( 31.00 x 53.00 ) in
'EN_GRAND_EAGLE' => array( 2070.000, 3024.000), // = ( 730 x 1067 ) mm = ( 28.75 x 42.00 ) in
'EN_DOUBLE_ELEPHANT' => array( 1926.000, 2880.000), // = ( 679 x 1016 ) mm = ( 26.75 x 40.00 ) in
'EN_ATLAS' => array( 1872.000, 2448.000), // = ( 660 x 864 ) mm = ( 26.00 x 34.00 ) in
'EN_COLOMBIER' => array( 1692.000, 2484.000), // = ( 597 x 876 ) mm = ( 23.50 x 34.50 ) in
'EN_ELEPHANT' => array( 1656.000, 2016.000), // = ( 584 x 711 ) mm = ( 23.00 x 28.00 ) in
'EN_DOUBLE_DEMY' => array( 1620.000, 2556.000), // = ( 572 x 902 ) mm = ( 22.50 x 35.50 ) in
'EN_IMPERIAL' => array( 1584.000, 2160.000), // = ( 559 x 762 ) mm = ( 22.00 x 30.00 ) in
'EN_PRINCESS' => array( 1548.000, 2016.000), // = ( 546 x 711 ) mm = ( 21.50 x 28.00 ) in
'EN_CARTRIDGE' => array( 1512.000, 1872.000), // = ( 533 x 660 ) mm = ( 21.00 x 26.00 ) in
'EN_DOUBLE_LARGE_POST' => array( 1512.000, 2376.000), // = ( 533 x 838 ) mm = ( 21.00 x 33.00 ) in
'EN_ROYAL' => array( 1440.000, 1800.000), // = ( 508 x 635 ) mm = ( 20.00 x 25.00 ) in
'EN_SHEET' => array( 1404.000, 1692.000), // = ( 495 x 597 ) mm = ( 19.50 x 23.50 ) in
'EN_HALF_POST' => array( 1404.000, 1692.000), // = ( 495 x 597 ) mm = ( 19.50 x 23.50 ) in
'EN_SUPER_ROYAL' => array( 1368.000, 1944.000), // = ( 483 x 686 ) mm = ( 19.00 x 27.00 ) in
'EN_DOUBLE_POST' => array( 1368.000, 2196.000), // = ( 483 x 775 ) mm = ( 19.00 x 30.50 ) in
'EN_MEDIUM' => array( 1260.000, 1656.000), // = ( 445 x 584 ) mm = ( 17.50 x 23.00 ) in
'EN_DEMY' => array( 1260.000, 1620.000), // = ( 445 x 572 ) mm = ( 17.50 x 22.50 ) in
'EN_LARGE_POST' => array( 1188.000, 1512.000), // = ( 419 x 533 ) mm = ( 16.50 x 21.00 ) in
'EN_COPY_DRAUGHT' => array( 1152.000, 1440.000), // = ( 406 x 508 ) mm = ( 16.00 x 20.00 ) in
'EN_POST' => array( 1116.000, 1386.000), // = ( 394 x 489 ) mm = ( 15.50 x 19.25 ) in
'EN_CROWN' => array( 1080.000, 1440.000), // = ( 381 x 508 ) mm = ( 15.00 x 20.00 ) in
'EN_PINCHED_POST' => array( 1062.000, 1332.000), // = ( 375 x 470 ) mm = ( 14.75 x 18.50 ) in
'EN_BRIEF' => array( 972.000, 1152.000), // = ( 343 x 406 ) mm = ( 13.50 x 16.00 ) in
'EN_FOOLSCAP' => array( 972.000, 1224.000), // = ( 343 x 432 ) mm = ( 13.50 x 17.00 ) in
'EN_SMALL_FOOLSCAP' => array( 954.000, 1188.000), // = ( 337 x 419 ) mm = ( 13.25 x 16.50 ) in
'EN_POTT' => array( 900.000, 1080.000), // = ( 318 x 381 ) mm = ( 12.50 x 15.00 ) in
// - Old Imperial Belgian Sizes
'BE_GRAND_AIGLE' => array( 1984.252, 2948.031), // = ( 700 x 1040 ) mm = ( 27.56 x 40.94 ) in
'BE_COLOMBIER' => array( 1757.480, 2409.449), // = ( 620 x 850 ) mm = ( 24.41 x 33.46 ) in
'BE_DOUBLE_CARRE' => array( 1757.480, 2607.874), // = ( 620 x 920 ) mm = ( 24.41 x 36.22 ) in
'BE_ELEPHANT' => array( 1746.142, 2182.677), // = ( 616 x 770 ) mm = ( 24.25 x 30.31 ) in
'BE_PETIT_AIGLE' => array( 1700.787, 2381.102), // = ( 600 x 840 ) mm = ( 23.62 x 33.07 ) in
'BE_GRAND_JESUS' => array( 1559.055, 2069.291), // = ( 550 x 730 ) mm = ( 21.65 x 28.74 ) in
'BE_JESUS' => array( 1530.709, 2069.291), // = ( 540 x 730 ) mm = ( 21.26 x 28.74 ) in
'BE_RAISIN' => array( 1417.323, 1842.520), // = ( 500 x 650 ) mm = ( 19.69 x 25.59 ) in
'BE_GRAND_MEDIAN' => array( 1303.937, 1714.961), // = ( 460 x 605 ) mm = ( 18.11 x 23.82 ) in
'BE_DOUBLE_POSTE' => array( 1233.071, 1601.575), // = ( 435 x 565 ) mm = ( 17.13 x 22.24 ) in
'BE_COQUILLE' => array( 1218.898, 1587.402), // = ( 430 x 560 ) mm = ( 16.93 x 22.05 ) in
'BE_PETIT_MEDIAN' => array( 1176.378, 1502.362), // = ( 415 x 530 ) mm = ( 16.34 x 20.87 ) in
'BE_RUCHE' => array( 1020.472, 1303.937), // = ( 360 x 460 ) mm = ( 14.17 x 18.11 ) in
'BE_PROPATRIA' => array( 977.953, 1218.898), // = ( 345 x 430 ) mm = ( 13.58 x 16.93 ) in
'BE_LYS' => array( 898.583, 1125.354), // = ( 317 x 397 ) mm = ( 12.48 x 15.63 ) in
'BE_POT' => array( 870.236, 1088.504), // = ( 307 x 384 ) mm = ( 12.09 x 15.12 ) in
'BE_ROSETTE' => array( 765.354, 983.622), // = ( 270 x 347 ) mm = ( 10.63 x 13.66 ) in
// - Old Imperial French Sizes
'FR_UNIVERS' => array( 2834.646, 3685.039), // = ( 1000 x 1300 ) mm = ( 39.37 x 51.18 ) in
'FR_DOUBLE_COLOMBIER' => array( 2551.181, 3571.654), // = ( 900 x 1260 ) mm = ( 35.43 x 49.61 ) in
'FR_GRANDE_MONDE' => array( 2551.181, 3571.654), // = ( 900 x 1260 ) mm = ( 35.43 x 49.61 ) in
'FR_DOUBLE_SOLEIL' => array( 2267.717, 3401.575), // = ( 800 x 1200 ) mm = ( 31.50 x 47.24 ) in
'FR_DOUBLE_JESUS' => array( 2154.331, 3174.803), // = ( 760 x 1120 ) mm = ( 29.92 x 44.09 ) in
'FR_GRAND_AIGLE' => array( 2125.984, 3004.724), // = ( 750 x 1060 ) mm = ( 29.53 x 41.73 ) in
'FR_PETIT_AIGLE' => array( 1984.252, 2664.567), // = ( 700 x 940 ) mm = ( 27.56 x 37.01 ) in
'FR_DOUBLE_RAISIN' => array( 1842.520, 2834.646), // = ( 650 x 1000 ) mm = ( 25.59 x 39.37 ) in
'FR_JOURNAL' => array( 1842.520, 2664.567), // = ( 650 x 940 ) mm = ( 25.59 x 37.01 ) in
'FR_COLOMBIER_AFFICHE' => array( 1785.827, 2551.181), // = ( 630 x 900 ) mm = ( 24.80 x 35.43 ) in
'FR_DOUBLE_CAVALIER' => array( 1757.480, 2607.874), // = ( 620 x 920 ) mm = ( 24.41 x 36.22 ) in
'FR_CLOCHE' => array( 1700.787, 2267.717), // = ( 600 x 800 ) mm = ( 23.62 x 31.50 ) in
'FR_SOLEIL' => array( 1700.787, 2267.717), // = ( 600 x 800 ) mm = ( 23.62 x 31.50 ) in
'FR_DOUBLE_CARRE' => array( 1587.402, 2551.181), // = ( 560 x 900 ) mm = ( 22.05 x 35.43 ) in
'FR_DOUBLE_COQUILLE' => array( 1587.402, 2494.488), // = ( 560 x 880 ) mm = ( 22.05 x 34.65 ) in
'FR_JESUS' => array( 1587.402, 2154.331), // = ( 560 x 760 ) mm = ( 22.05 x 29.92 ) in
'FR_RAISIN' => array( 1417.323, 1842.520), // = ( 500 x 650 ) mm = ( 19.69 x 25.59 ) in
'FR_CAVALIER' => array( 1303.937, 1757.480), // = ( 460 x 620 ) mm = ( 18.11 x 24.41 ) in
'FR_DOUBLE_COURONNE' => array( 1303.937, 2040.945), // = ( 460 x 720 ) mm = ( 18.11 x 28.35 ) in
'FR_CARRE' => array( 1275.591, 1587.402), // = ( 450 x 560 ) mm = ( 17.72 x 22.05 ) in
'FR_COQUILLE' => array( 1247.244, 1587.402), // = ( 440 x 560 ) mm = ( 17.32 x 22.05 ) in
'FR_DOUBLE_TELLIERE' => array( 1247.244, 1927.559), // = ( 440 x 680 ) mm = ( 17.32 x 26.77 ) in
'FR_DOUBLE_CLOCHE' => array( 1133.858, 1700.787), // = ( 400 x 600 ) mm = ( 15.75 x 23.62 ) in
'FR_DOUBLE_POT' => array( 1133.858, 1757.480), // = ( 400 x 620 ) mm = ( 15.75 x 24.41 ) in
'FR_ECU' => array( 1133.858, 1474.016), // = ( 400 x 520 ) mm = ( 15.75 x 20.47 ) in
'FR_COURONNE' => array( 1020.472, 1303.937), // = ( 360 x 460 ) mm = ( 14.17 x 18.11 ) in
'FR_TELLIERE' => array( 963.780, 1247.244), // = ( 340 x 440 ) mm = ( 13.39 x 17.32 ) in
'FR_POT' => array( 878.740, 1133.858), // = ( 310 x 400 ) mm = ( 12.20 x 15.75 ) in
);
/**
* Get page dimensions from format name.
* @param $format (mixed) The format name @see self::$page_format<ul>
* @return array containing page width and height in points
* @since 5.0.010 (2010-05-17)
* @public static
*/
public static function getPageSizeFromFormat($format) {
if (isset(self::$page_formats[$format])) {
return self::$page_formats[$format];
}
return self::$page_formats['A4'];
}
/**
* Set page boundaries.
* @param $page (int) page number
* @param $type (string) valid values are: <ul><li>'MediaBox' : the boundaries of the physical medium on which the page shall be displayed or printed;</li><li>'CropBox' : the visible region of default user space;</li><li>'BleedBox' : the region to which the contents of the page shall be clipped when output in a production environment;</li><li>'TrimBox' : the intended dimensions of the finished page after trimming;</li><li>'ArtBox' : the page's meaningful content (including potential white space).</li></ul>
* @param $llx (float) lower-left x coordinate in user units.
* @param $lly (float) lower-left y coordinate in user units.
* @param $urx (float) upper-right x coordinate in user units.
* @param $ury (float) upper-right y coordinate in user units.
* @param $points (boolean) If true uses user units as unit of measure, otherwise uses PDF points.
* @param $k (float) Scale factor (number of points in user unit).
* @param $pagedim (array) Array of page dimensions.
* @return pagedim array of page dimensions.
* @since 5.0.010 (2010-05-17)
* @public static
*/
public static function setPageBoxes($page, $type, $llx, $lly, $urx, $ury, $points=false, $k, $pagedim=array()) {
if (!isset($pagedim[$page])) {
// initialize array
$pagedim[$page] = array();
}
if (!in_array($type, self::$pageboxes)) {
return;
}
if ($points) {
$k = 1;
}
$pagedim[$page][$type]['llx'] = ($llx * $k);
$pagedim[$page][$type]['lly'] = ($lly * $k);
$pagedim[$page][$type]['urx'] = ($urx * $k);
$pagedim[$page][$type]['ury'] = ($ury * $k);
return $pagedim;
}
/**
* Swap X and Y coordinates of page boxes (change page boxes orientation).
* @param $page (int) page number
* @param $pagedim (array) Array of page dimensions.
* @return pagedim array of page dimensions.
* @since 5.0.010 (2010-05-17)
* @public static
*/
public static function swapPageBoxCoordinates($page, $pagedim) {
foreach (self::$pageboxes as $type) {
// swap X and Y coordinates
if (isset($pagedim[$page][$type])) {
$tmp = $pagedim[$page][$type]['llx'];
$pagedim[$page][$type]['llx'] = $pagedim[$page][$type]['lly'];
$pagedim[$page][$type]['lly'] = $tmp;
$tmp = $pagedim[$page][$type]['urx'];
$pagedim[$page][$type]['urx'] = $pagedim[$page][$type]['ury'];
$pagedim[$page][$type]['ury'] = $tmp;
}
}
return $pagedim;
}
/**
* Get the canonical page layout mode.
* @param $layout (string) The page layout. Possible values are:<ul><li>SinglePage Display one page at a time</li><li>OneColumn Display the pages in one column</li><li>TwoColumnLeft Display the pages in two columns, with odd-numbered pages on the left</li><li>TwoColumnRight Display the pages in two columns, with odd-numbered pages on the right</li><li>TwoPageLeft (PDF 1.5) Display the pages two at a time, with odd-numbered pages on the left</li><li>TwoPageRight (PDF 1.5) Display the pages two at a time, with odd-numbered pages on the right</li></ul>
* @return (string) Canonical page layout name.
* @public static
*/
public static function getPageLayoutMode($layout='SinglePage') {
switch ($layout) {
case 'default':
case 'single':
case 'SinglePage': {
$layout_mode = 'SinglePage';
break;
}
case 'continuous':
case 'OneColumn': {
$layout_mode = 'OneColumn';
break;
}
case 'two':
case 'TwoColumnLeft': {
$layout_mode = 'TwoColumnLeft';
break;
}
case 'TwoColumnRight': {
$layout_mode = 'TwoColumnRight';
break;
}
case 'TwoPageLeft': {
$layout_mode = 'TwoPageLeft';
break;
}
case 'TwoPageRight': {
$layout_mode = 'TwoPageRight';
break;
}
default: {
$layout_mode = 'SinglePage';
}
}
return $layout_mode;
}
/**
* Get the canonical page layout mode.
* @param $mode (string) A name object specifying how the document should be displayed when opened:<ul><li>UseNone Neither document outline nor thumbnail images visible</li><li>UseOutlines Document outline visible</li><li>UseThumbs Thumbnail images visible</li><li>FullScreen Full-screen mode, with no menu bar, window controls, or any other window visible</li><li>UseOC (PDF 1.5) Optional content group panel visible</li><li>UseAttachments (PDF 1.6) Attachments panel visible</li></ul>
* @return (string) Canonical page mode name.
* @public static
*/
public static function getPageMode($mode='UseNone') {
switch ($mode) {
case 'UseNone': {
$page_mode = 'UseNone';
break;
}
case 'UseOutlines': {
$page_mode = 'UseOutlines';
break;
}
case 'UseThumbs': {
$page_mode = 'UseThumbs';
break;
}
case 'FullScreen': {
$page_mode = 'FullScreen';
break;
}
case 'UseOC': {
$page_mode = 'UseOC';
break;
}
case '': {
$page_mode = 'UseAttachments';
break;
}
default: {
$page_mode = 'UseNone';
}
}
return $page_mode;
}
} // END OF TCPDF_STATIC CLASS
//============================================================+
// END OF FILE
//============================================================+
§]*)§([^§]*)§/i', $cssdata, $matches) > 0) {
1064 foreach ($matches[1] as $key => $type) {
1065 $cssblocks[$type] = $matches[2][$key];
1068 $cssdata = preg_replace(
'/@media[\s]+([^\ ]*)§([^§]*)§/i', '', $cssdata);
}
// keep 'all' and 'print' media, other media types are discarded
if (isset($cssblocks['all']) AND !empty($cssblocks['all'])) {
$cssdata .= $cssblocks['all'];
}
if (isset($cssblocks['print']) AND !empty($cssblocks['print'])) {
$cssdata .= $cssblocks['print'];
}
// reset css blocks array
$cssblocks = array();
$matches = array();
// explode css data string into array
if (substr($cssdata, -1) == '}') {
// remove last parethesis
$cssdata = substr($cssdata, 0, -1);
}
$matches = explode('}', $cssdata);
foreach ($matches as $key => $block) {
// index 0 contains the CSS selector, index 1 contains CSS properties
$cssblocks[$key] = explode('{', $block);
if (!isset($cssblocks[$key][1])) {
// remove empty definitions
unset($cssblocks[$key]);
}
}
// split groups of selectors (comma-separated list of selectors)
foreach ($cssblocks as $key => $block) {
if (strpos($block[0], ',') > 0) {
$selectors = explode(',', $block[0]);
foreach ($selectors as $sel) {
$cssblocks[] = array(0 => trim($sel), 1 => $block[1]);
}
unset($cssblocks[$key]);
}
}
// covert array to selector => properties
$cssdata = array();
foreach ($cssblocks as $block) {
$selector = $block[0];
// calculate selector's specificity
$matches = array();
$a = 0; // the declaration is not from is a 'style' attribute
$b = intval(preg_match_all('/[\#]/', $selector, $matches)); // number of ID attributes
$c = intval(preg_match_all('/[\[\.]/', $selector, $matches)); // number of other attributes
$c += intval(preg_match_all('/[\:]link|visited|hover|active|focus|target|lang|enabled|disabled|checked|indeterminate|root|nth|first|last|only|empty|contains|not/i', $selector, $matches)); // number of pseudo-classes
$d = intval(preg_match_all('/[>\+\~\s]{1}[a-zA-Z0-9]+/', ' '.$selector, $matches)); // number of element names
$d += intval(preg_match_all('/[\:][\:]/', $selector, $matches)); // number of pseudo-elements
$specificity = $a.$b.$c.$d;
// add specificity to the beginning of the selector
$cssdata[$specificity.' '.$selector] = $block[1];
}
// sort selectors alphabetically to account for specificity
ksort($cssdata, SORT_STRING);
// return array
return $cssdata;
}
/**
* Cleanup HTML code (requires HTML Tidy library).
* @param $html (string) htmlcode to fix
* @param $default_css (string) CSS commands to add
* @param $tagvs (array) parameters for setHtmlVSpace method
* @param $tidy_options (array) options for tidy_parse_string function
* @param $tagvspaces (array) Array of vertical spaces for tags.
* @return string XHTML code cleaned up
* @author Nicola Asuni
* @since 5.9.017 (2010-11-16)
* @see setHtmlVSpace()
* @public static
*/
public static function fixHTMLCode($html, $default_css='', $tagvs='', $tidy_options='', &$tagvspaces) {
// configure parameters for HTML Tidy
if ($tidy_options === '') {
$tidy_options = array (
'clean' => 1,
'drop-empty-paras' => 0,
'drop-proprietary-attributes' => 1,
'fix-backslash' => 1,
'hide-comments' => 1,
'join-styles' => 1,
'lower-literals' => 1,
'merge-divs' => 1,
'merge-spans' => 1,
'output-xhtml' => 1,
'word-2000' => 1,
'wrap' => 0,
'output-bom' => 0,
//'char-encoding' => 'utf8',
//'input-encoding' => 'utf8',
//'output-encoding' => 'utf8'
);
}
// clean up the HTML code
$tidy = tidy_parse_string($html, $tidy_options);
// fix the HTML
$tidy->cleanRepair();
// get the CSS part
$tidy_head = tidy_get_head($tidy);
$css = $tidy_head->value;
$css = preg_replace('/<style([^>]+)>/ims', '<style>', $css);
$css = preg_replace('/<\/style>(.*)<style>/ims', "\n", $css);
$css = str_replace('/*<![CDATA[*/', '', $css);
$css = str_replace('/*]]>*/', '', $css);
preg_match('/<style>(.*)<\/style>/ims', $css, $matches);
if (isset($matches[1])) {
$css = strtolower($matches[1]);
} else {
$css = '';
}
// include default css
$css = '<style>'.$default_css.$css.'</style>';
// get the body part
$tidy_body = tidy_get_body($tidy);
$html = $tidy_body->value;
// fix some self-closing tags
$html = str_replace('<br>', '<br />', $html);
// remove some empty tag blocks
$html = preg_replace('/<div([^>]*)><\/div>/', '', $html);
$html = preg_replace('/<p([^>]*)><\/p>/', '', $html);
if ($tagvs !== '') {
// set vertical space for some XHTML tags
$tagvspaces = $tagvs;
}
// return the cleaned XHTML code + CSS
return $css.$html;
}
/**
* Returns true if the CSS selector is valid for the selected HTML tag
* @param $dom (array) array of HTML tags and properties
* @param $key (int) key of the current HTML tag
* @param $selector (string) CSS selector string
* @return true if the selector is valid, false otherwise
* @since 5.1.000 (2010-05-25)
* @public static
*/
public static function isValidCSSSelectorForTag($dom, $key, $selector) {
$valid = false; // value to be returned
$tag = $dom[$key]['value'];
$class = array();
if (isset($dom[$key]['attribute']['class']) AND !empty($dom[$key]['attribute']['class'])) {
$class = explode(' ', strtolower($dom[$key]['attribute']['class']));
}
$id = '';
if (isset($dom[$key]['attribute']['id']) AND !empty($dom[$key]['attribute']['id'])) {
$id = strtolower($dom[$key]['attribute']['id']);
}
$selector = preg_replace('/([>\+\~\s]{1})([\.]{1})([^>\+\~\s]*)/si', '\\1*.\\3', $selector);
$matches = array();
if (preg_match_all('/([>\+\~\s]{1})([a-zA-Z0-9\*]+)([^>\+\~\s]*)/si', $selector, $matches, PREG_PATTERN_ORDER | PREG_OFFSET_CAPTURE) > 0) {
$parentop = array_pop($matches[1]);
$operator = $parentop[0];
$offset = $parentop[1];
$lasttag = array_pop($matches[2]);
$lasttag = strtolower(trim($lasttag[0]));
if (($lasttag == '*') OR ($lasttag == $tag)) {
// the last element on selector is our tag or 'any tag'
$attrib = array_pop($matches[3]);
$attrib = strtolower(trim($attrib[0]));
if (!empty($attrib)) {
// check if matches class, id, attribute, pseudo-class or pseudo-element
switch ($attrib[0]) {
case '.': { // class
if (in_array(substr($attrib, 1), $class)) {
$valid = true;
}
break;
}
case '#': { // ID
if (substr($attrib, 1) == $id) {
$valid = true;
}
break;
}
case '[': { // attribute
$attrmatch = array();
if (preg_match('/\[([a-zA-Z0-9]*)[\s]*([\~\^\$\*\|\=]*)[\s]*["]?([^"\]]*)["]?\]/i', $attrib, $attrmatch) > 0) {
$att = strtolower($attrmatch[1]);
$val = $attrmatch[3];
if (isset($dom[$key]['attribute'][$att])) {
switch ($attrmatch[2]) {
case '=': {
if ($dom[$key]['attribute'][$att] == $val) {
$valid = true;
}
break;
}
case '~=': {
if (in_array($val, explode(' ', $dom[$key]['attribute'][$att]))) {
$valid = true;
}
break;
}
case '^=': {
if ($val == substr($dom[$key]['attribute'][$att], 0, strlen($val))) {
$valid = true;
}
break;
}
case '$=': {
if ($val == substr($dom[$key]['attribute'][$att], -strlen($val))) {
$valid = true;
}
break;
}
case '*=': {
if (strpos($dom[$key]['attribute'][$att], $val) !== false) {
$valid = true;
}
break;
}
case '|=': {
if ($dom[$key]['attribute'][$att] == $val) {
$valid = true;
} elseif (preg_match('/'.$val.'[\-]{1}/i', $dom[$key]['attribute'][$att]) > 0) {
$valid = true;
}
break;
}
default: {
$valid = true;
}
}
}
}
break;
}
case ':': { // pseudo-class or pseudo-element
if ($attrib[1] == ':') { // pseudo-element
// pseudo-elements are not supported!
// (::first-line, ::first-letter, ::before, ::after)
} else { // pseudo-class
// pseudo-classes are not supported!
// (:root, :nth-child(n), :nth-last-child(n), :nth-of-type(n), :nth-last-of-type(n), :first-child, :last-child, :first-of-type, :last-of-type, :only-child, :only-of-type, :empty, :link, :visited, :active, :hover, :focus, :target, :lang(fr), :enabled, :disabled, :checked)
}
break;
}
} // end of switch
} else {
$valid = true;
}
if ($valid AND ($offset > 0)) {
$valid = false;
// check remaining selector part
$selector = substr($selector, 0, $offset);
switch ($operator) {
case ' ': { // descendant of an element
while ($dom[$key]['parent'] > 0) {
if (self::isValidCSSSelectorForTag($dom, $dom[$key]['parent'], $selector)) {
$valid = true;
break;
} else {
$key = $dom[$key]['parent'];
}
}
break;
}
case '>': { // child of an element
$valid = self::isValidCSSSelectorForTag($dom, $dom[$key]['parent'], $selector);
break;
}
case '+': { // immediately preceded by an element
for ($i = ($key - 1); $i > $dom[$key]['parent']; --$i) {
if ($dom[$i]['tag'] AND $dom[$i]['opening']) {
$valid = self::isValidCSSSelectorForTag($dom, $i, $selector);
break;
}
}
break;
}
case '~': { // preceded by an element
for ($i = ($key - 1); $i > $dom[$key]['parent']; --$i) {
if ($dom[$i]['tag'] AND $dom[$i]['opening']) {
if (self::isValidCSSSelectorForTag($dom, $i, $selector)) {
break;
}
}
}
break;
}
}
}
}
}
return $valid;
}
/**
* Returns the styles array that apply for the selected HTML tag.
* @param $dom (array) array of HTML tags and properties
* @param $key (int) key of the current HTML tag
* @param $css (array) array of CSS properties
* @return array containing CSS properties
* @since 5.1.000 (2010-05-25)
* @public static
*/
public static function getCSSdataArray($dom, $key, $css) {
$cssarray = array(); // style to be returned
// get parent CSS selectors
$selectors = array();
if (isset($dom[($dom[$key]['parent'])]['csssel'])) {
$selectors = $dom[($dom[$key]['parent'])]['csssel'];
}
// get all styles that apply
foreach($css as $selector => $style) {
$pos = strpos($selector, ' ');
// get specificity
$specificity = substr($selector, 0, $pos);
// remove specificity
$selector = substr($selector, $pos);
// check if this selector apply to current tag
if (self::isValidCSSSelectorForTag($dom, $key, $selector)) {
if (!in_array($selector, $selectors)) {
// add style if not already added on parent selector
$cssarray[] = array('k' => $selector, 's' => $specificity, 'c' => $style);
$selectors[] = $selector;
}
}
}
if (isset($dom[$key]['attribute']['style'])) {
// attach inline style (latest properties have high priority)
$cssarray[] = array('k' => '', 's' => '1000', 'c' => $dom[$key]['attribute']['style']);
}
// order the css array to account for specificity
$cssordered = array();
foreach ($cssarray as $key => $val) {
$skey = sprintf('%04d', $key);
$cssordered[$val['s'].'_'.$skey] = $val;
}
// sort selectors alphabetically to account for specificity
ksort($cssordered, SORT_STRING);
return array($selectors, $cssordered);
}
/**
* Compact CSS data array into single string.
* @param $css (array) array of CSS properties
* @return string containing merged CSS properties
* @since 5.9.070 (2011-04-19)
* @public static
*/
public static function getTagStyleFromCSSarray($css) {
$tagstyle = ''; // value to be returned
foreach ($css as $style) {
// split single css commands
$csscmds = explode(';', $style['c']);
foreach ($csscmds as $cmd) {
if (!empty($cmd)) {
$pos = strpos($cmd, ':');
if ($pos !== false) {
$cmd = substr($cmd, 0, ($pos + 1));
if (strpos($tagstyle, $cmd) !== false) {
// remove duplicate commands (last commands have high priority)
$tagstyle = preg_replace('/'.$cmd.'[^;]+/i', '', $tagstyle);
}
}
}
}
$tagstyle .= ';'.$style['c'];
}
// remove multiple semicolons
$tagstyle = preg_replace('/[;]+/', ';', $tagstyle);
return $tagstyle;
}
/**
* Returns the Roman representation of an integer number
* @param $number (int) number to convert
* @return string roman representation of the specified number
* @since 4.4.004 (2008-12-10)
* @public static
*/
public static function intToRoman($number) {
$roman = '';
while ($number >= 1000) {
$roman .= 'M';
$number -= 1000;
}
while ($number >= 900) {
$roman .= 'CM';
$number -= 900;
}
while ($number >= 500) {
$roman .= 'D';
$number -= 500;
}
while ($number >= 400) {
$roman .= 'CD';
$number -= 400;
}
while ($number >= 100) {
$roman .= 'C';
$number -= 100;
}
while ($number >= 90) {
$roman .= 'XC';
$number -= 90;
}
while ($number >= 50) {
$roman .= 'L';
$number -= 50;
}
while ($number >= 40) {
$roman .= 'XL';
$number -= 40;
}
while ($number >= 10) {
$roman .= 'X';
$number -= 10;
}
while ($number >= 9) {
$roman .= 'IX';
$number -= 9;
}
while ($number >= 5) {
$roman .= 'V';
$number -= 5;
}
while ($number >= 4) {
$roman .= 'IV';
$number -= 4;
}
while ($number >= 1) {
$roman .= 'I';
--$number;
}
return $roman;
}
/**
* Find position of last occurrence of a substring in a string
* @param $haystack (string) The string to search in.
* @param $needle (string) substring to search.
* @param $offset (int) May be specified to begin searching an arbitrary number of characters into the string.
* @return Returns the position where the needle exists. Returns FALSE if the needle was not found.
* @since 4.8.038 (2010-03-13)
* @public static
*/
public static function revstrpos($haystack, $needle, $offset = 0) {
$length = strlen($haystack);
$offset = ($offset > 0)?($length - $offset):abs($offset);
$pos = strpos(strrev($haystack), strrev($needle), $offset);
return ($pos === false)?false:($length - $pos - strlen($needle));
}
/**
* Returns an array of hyphenation patterns.
* @param $file (string) TEX file containing hypenation patterns. TEX pattrns can be downloaded from http://www.ctan.org/tex-archive/language/hyph-utf8/tex/generic/hyph-utf8/patterns/
* @return array of hyphenation patterns
* @author Nicola Asuni
* @since 4.9.012 (2010-04-12)
* @public static
*/
public static function getHyphenPatternsFromTEX($file) {
// TEX patterns are available at:
// http://www.ctan.org/tex-archive/language/hyph-utf8/tex/generic/hyph-utf8/patterns/
$data = file_get_contents($file);
$patterns = array();
// remove comments
$data = preg_replace('/\%[^\n]*/', '', $data);
// extract the patterns part
preg_match('/\\\\patterns\{([^\}]*)\}/i', $data, $matches);
$data = trim(substr($matches[0], 10, -1));
// extract each pattern
$patterns_array = preg_split('/[\s]+/', $data);
// create new language array of patterns
$patterns = array();
foreach($patterns_array as $val) {
if (!TCPDF_STATIC::empty_string($val)) {
$val = trim($val);
$val = str_replace('\'', '\\\'', $val);
$key = preg_replace('/[0-9]+/', '', $val);
$patterns[$key] = $val;
}
}
return $patterns;
}
/**
* Get the Path-Painting Operators.
* @param $style (string) Style of rendering. Possible values are:
* <ul>
* <li>S or D: Stroke the path.</li>
* <li>s or d: Close and stroke the path.</li>
* <li>f or F: Fill the path, using the nonzero winding number rule to determine the region to fill.</li>
* <li>f* or F*: Fill the path, using the even-odd rule to determine the region to fill.</li>
* <li>B or FD or DF: Fill and then stroke the path, using the nonzero winding number rule to determine the region to fill.</li>
* <li>B* or F*D or DF*: Fill and then stroke the path, using the even-odd rule to determine the region to fill.</li>
* <li>b or fd or df: Close, fill, and then stroke the path, using the nonzero winding number rule to determine the region to fill.</li>
* <li>b or f*d or df*: Close, fill, and then stroke the path, using the even-odd rule to determine the region to fill.</li>
* <li>CNZ: Clipping mode using the even-odd rule to determine which regions lie inside the clipping path.</li>
* <li>CEO: Clipping mode using the nonzero winding number rule to determine which regions lie inside the clipping path</li>
* <li>n: End the path object without filling or stroking it.</li>
* </ul>
* @param $default (string) default style
* @author Nicola Asuni
* @since 5.0.000 (2010-04-30)
* @public static
*/
public static function getPathPaintOperator($style, $default='S') {
$op = '';
switch($style) {
case 'S':
case 'D': {
$op = 'S';
break;
}
case 's':
case 'd': {
$op = 's';
break;
}
case 'f':
case 'F': {
$op = 'f';
break;
}
case 'f*':
case 'F*': {
$op = 'f*';
break;
}
case 'B':
case 'FD':
case 'DF': {
$op = 'B';
break;
}
case 'B*':
case 'F*D':
case 'DF*': {
$op = 'B*';
break;
}
case 'b':
case 'fd':
case 'df': {
$op = 'b';
break;
}
case 'b*':
case 'f*d':
case 'df*': {
$op = 'b*';
break;
}
case 'CNZ': {
$op = 'W n';
break;
}
case 'CEO': {
$op = 'W* n';
break;
}
case 'n': {
$op = 'n';
break;
}
default: {
if (!empty($default)) {
$op = self::getPathPaintOperator($default, '');
} else {
$op = '';
}
}
}
return $op;
}
/**
* Get the product of two SVG tranformation matrices
* @param $ta (array) first SVG tranformation matrix
* @param $tb (array) second SVG tranformation matrix
* @return transformation array
* @author Nicola Asuni
* @since 5.0.000 (2010-05-02)
* @public static
*/
public static function getTransformationMatrixProduct($ta, $tb) {
$tm = array();
$tm[0] = ($ta[0] * $tb[0]) + ($ta[2] * $tb[1]);
$tm[1] = ($ta[1] * $tb[0]) + ($ta[3] * $tb[1]);
$tm[2] = ($ta[0] * $tb[2]) + ($ta[2] * $tb[3]);
$tm[3] = ($ta[1] * $tb[2]) + ($ta[3] * $tb[3]);
$tm[4] = ($ta[0] * $tb[4]) + ($ta[2] * $tb[5]) + $ta[4];
$tm[5] = ($ta[1] * $tb[4]) + ($ta[3] * $tb[5]) + $ta[5];
return $tm;
}
/**
* Get the tranformation matrix from SVG transform attribute
* @param $attribute (string) transformation
* @return array of transformations
* @author Nicola Asuni
* @since 5.0.000 (2010-05-02)
* @public static
*/
public static function getSVGTransformMatrix($attribute) {
// identity matrix
$tm = array(1, 0, 0, 1, 0, 0);
$transform = array();
if (preg_match_all('/(matrix|translate|scale|rotate|skewX|skewY)[\s]*\(([^\)]+)\)/si', $attribute, $transform, PREG_SET_ORDER) > 0) {
foreach ($transform as $key => $data) {
if (!empty($data[2])) {
$a = 1;
$b = 0;
$c = 0;
$d = 1;
$e = 0;
$f = 0;
$regs = array();
switch ($data[1]) {
case 'matrix': {
if (preg_match('/([a-z0-9\-\.]+)[\,\s]+([a-z0-9\-\.]+)[\,\s]+([a-z0-9\-\.]+)[\,\s]+([a-z0-9\-\.]+)[\,\s]+([a-z0-9\-\.]+)[\,\s]+([a-z0-9\-\.]+)/si', $data[2], $regs)) {
$a = $regs[1];
$b = $regs[2];
$c = $regs[3];
$d = $regs[4];
$e = $regs[5];
$f = $regs[6];
}
break;
}
case 'translate': {
if (preg_match('/([a-z0-9\-\.]+)[\,\s]+([a-z0-9\-\.]+)/si', $data[2], $regs)) {
$e = $regs[1];
$f = $regs[2];
} elseif (preg_match('/([a-z0-9\-\.]+)/si', $data[2], $regs)) {
$e = $regs[1];
}
break;
}
case 'scale': {
if (preg_match('/([a-z0-9\-\.]+)[\,\s]+([a-z0-9\-\.]+)/si', $data[2], $regs)) {
$a = $regs[1];
$d = $regs[2];
} elseif (preg_match('/([a-z0-9\-\.]+)/si', $data[2], $regs)) {
$a = $regs[1];
$d = $a;
}
break;
}
case 'rotate': {
if (preg_match('/([0-9\-\.]+)[\,\s]+([a-z0-9\-\.]+)[\,\s]+([a-z0-9\-\.]+)/si', $data[2], $regs)) {
$ang = deg2rad($regs[1]);
$x = $regs[2];
$y = $regs[3];
$a = cos($ang);
$b = sin($ang);
$c = -$b;
$d = $a;
$e = ($x * (1 - $a)) - ($y * $c);
$f = ($y * (1 - $d)) - ($x * $b);
} elseif (preg_match('/([0-9\-\.]+)/si', $data[2], $regs)) {
$ang = deg2rad($regs[1]);
$a = cos($ang);
$b = sin($ang);
$c = -$b;
$d = $a;
$e = 0;
$f = 0;
}
break;
}
case 'skewX': {
if (preg_match('/([0-9\-\.]+)/si', $data[2], $regs)) {
$c = tan(deg2rad($regs[1]));
}
break;
}
case 'skewY': {
if (preg_match('/([0-9\-\.]+)/si', $data[2], $regs)) {
$b = tan(deg2rad($regs[1]));
}
break;
}
}
$tm = self::getTransformationMatrixProduct($tm, array($a, $b, $c, $d, $e, $f));
}
}
}
return $tm;
}
/**
* Returns the angle in radiants between two vectors
* @param $x1 (int) X coordinate of first vector point
* @param $y1 (int) Y coordinate of first vector point
* @param $x2 (int) X coordinate of second vector point
* @param $y2 (int) Y coordinate of second vector point
* @author Nicola Asuni
* @since 5.0.000 (2010-05-04)
* @public static
*/
public static function getVectorsAngle($x1, $y1, $x2, $y2) {
$dprod = ($x1 * $x2) + ($y1 * $y2);
$dist1 = sqrt(($x1 * $x1) + ($y1 * $y1));
$dist2 = sqrt(($x2 * $x2) + ($y2 * $y2));
$angle = acos($dprod / ($dist1 * $dist2));
if (is_nan($angle)) {
$angle = M_PI;
}
if ((($x1 * $y2) - ($x2 * $y1)) < 0) {
$angle *= -1;
}
return $angle;
}
// ====================================================================================================================
// REIMPLEMENTED
// ====================================================================================================================
/**
* Split string by a regular expression.
* This is a wrapper for the preg_split function to avoid the bug: https://bugs.php.net/bug.php?id=45850
* @param $pattern (string) The regular expression pattern to search for without the modifiers, as a string.
* @param $modifiers (string) The modifiers part of the pattern,
* @param $subject (string) The input string.
* @param $limit (int) 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.
* @param $flags (int) The flags as specified on the preg_split PHP function.
* @return Returns an array containing substrings of subject split along boundaries matched by pattern.modifier
* @author Nicola Asuni
* @since 6.0.023
* @public static
*/
public static function pregSplit($pattern, $modifiers, $subject, $limit=NULL, $flags=NULL) {
// the bug only happens on PHP 5.2 when using the u modifier
if ((strpos($modifiers, 'u') === FALSE) OR (count(preg_split('//u', "\n\t", -1, PREG_SPLIT_NO_EMPTY)) == 2)) {
return preg_split($pattern.$modifiers, $subject, $limit, $flags);
}
// preg_split is bugged - try alternative solution
$ret = array();
while (($nl = strpos($subject, "\n")) !== FALSE) {
$ret = array_merge($ret, preg_split($pattern.$modifiers, substr($subject, 0, $nl), $limit, $flags));
$ret[] = "\n";
$subject = substr($subject, ($nl + 1));
}
if (strlen($subject) > 0) {
$ret = array_merge($ret, preg_split($pattern.$modifiers, $subject, $limit, $flags));
}
return $ret;
}
/**
* Wrapper to use fopen only with local files
* @param filename (string) Name of the file to open
* @param $mode (string)
* @return Returns a file pointer resource on success, or FALSE on error.
* @public static
*/
public static function fopenLocal($filename, $mode) {
if (strpos($filename, '://') === false) {
$filename = 'file://'.$filename;
} elseif (stream_is_local($filename) !== true) {
return false;
}
return fopen($filename, $mode);
}
/**
* Reads entire file into a string.
* The file can be also an URL.
* @param $file (string) Name of the file or URL to read.
* @return The function returns the read data or FALSE on failure.
* @author Nicola Asuni
* @since 6.0.025
* @public static
*/
public static function fileGetContents($file) {
$alt = array($file);
//
if ((strlen($file) > 1)
&& ($file[0] === '/')
&& ($file[1] !== '/')
&& !empty($_SERVER['DOCUMENT_ROOT'])
&& ($_SERVER['DOCUMENT_ROOT'] !== '/')
) {
$findroot = strpos($file, $_SERVER['DOCUMENT_ROOT']);
if (($findroot === false) || ($findroot > 1)) {
$alt[] = htmlspecialchars_decode(urldecode($_SERVER['DOCUMENT_ROOT'].$file));
}
}
//
$protocol = 'http';
if (!empty($_SERVER['HTTPS']) && (strtolower($_SERVER['HTTPS']) != 'off')) {
$protocol .= 's';
}
//
$url = $file;
if (preg_match('%^//%', $url) && !empty($_SERVER['HTTP_HOST'])) {
$url = $protocol.':'.str_replace(' ', '%20', $url);
}
$url = htmlspecialchars_decode($url);
$alt[] = $url;
//
if (preg_match('%^(https?)://%', $url)
&& empty($_SERVER['HTTP_HOST'])
&& empty($_SERVER['DOCUMENT_ROOT'])
) {
$urldata = parse_url($url);
if (empty($urldata['query'])) {
$host = $protocol.'://'.$_SERVER['HTTP_HOST'];
if (strpos($url, $host) === 0) {
// convert URL to full server path
$tmp = str_replace($host, $_SERVER['DOCUMENT_ROOT'], $url);
$alt[] = htmlspecialchars_decode(urldecode($tmp));
}
}
}
//
if (isset($_SERVER['SCRIPT_URI'])
&& !preg_match('%^(https?|ftp)://%', $file)
&& !preg_match('%^//%', $file)
) {
$urldata = @parse_url($_SERVER['SCRIPT_URI']);
return $urldata['scheme'].'://'.$urldata['host'].(($file[0] == '/') ? '' : '/').$file;
}
//
$alt = array_unique($alt);
//var_dump($alt);exit;//DEBUG
foreach ($alt as $path) {
$ret = @file_get_contents($path);
if ($ret !== false) {
return $ret;
}
// try to use CURL for URLs
if (!ini_get('allow_url_fopen')
&& function_exists('curl_init')
&& preg_match('%^(https?|ftp)://%', $path)
) {
// try to get remote file data using cURL
$crs = curl_init();
curl_setopt($crs, CURLOPT_URL, $path);
curl_setopt($crs, CURLOPT_BINARYTRANSFER, true);
curl_setopt($crs, CURLOPT_FAILONERROR, true);
curl_setopt($crs, CURLOPT_RETURNTRANSFER, true);
if ((ini_get('open_basedir') == '') && (!ini_get('safe_mode'))) {
curl_setopt($crs, CURLOPT_FOLLOWLOCATION, true);
}
curl_setopt($crs, CURLOPT_CONNECTTIMEOUT, 5);
curl_setopt($crs, CURLOPT_TIMEOUT, 30);
curl_setopt($crs, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($crs, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($crs, CURLOPT_USERAGENT, 'tc-lib-file');
$ret = curl_exec($crs);
curl_close($crs);
if ($ret !== false) {
return $ret;
}
}
}
return false;
}
/**
* Get ULONG from string (Big Endian 32-bit unsigned integer).
* @param $str (string) string from where to extract value
* @param $offset (int) point from where to read the data
* @return int 32 bit value
* @author Nicola Asuni
* @since 5.2.000 (2010-06-02)
* @public static
*/
public static function _getULONG($str, $offset) {
$v = unpack('Ni', substr($str, $offset, 4));
return $v['i'];
}
/**
* Get USHORT from string (Big Endian 16-bit unsigned integer).
* @param $str (string) string from where to extract value
* @param $offset (int) point from where to read the data
* @return int 16 bit value
* @author Nicola Asuni
* @since 5.2.000 (2010-06-02)
* @public static
*/
public static function _getUSHORT($str, $offset) {
$v = unpack('ni', substr($str, $offset, 2));
return $v['i'];
}
/**
* Get SHORT from string (Big Endian 16-bit signed integer).
* @param $str (string) String from where to extract value.
* @param $offset (int) Point from where to read the data.
* @return int 16 bit value
* @author Nicola Asuni
* @since 5.2.000 (2010-06-02)
* @public static
*/
public static function _getSHORT($str, $offset) {
$v = unpack('si', substr($str, $offset, 2));
return $v['i'];
}
/**
* Get FWORD from string (Big Endian 16-bit signed integer).
* @param $str (string) String from where to extract value.
* @param $offset (int) Point from where to read the data.
* @return int 16 bit value
* @author Nicola Asuni
* @since 5.9.123 (2011-09-30)
* @public static
*/
public static function _getFWORD($str, $offset) {
$v = self::_getUSHORT($str, $offset);
if ($v > 0x7fff) {
$v -= 0x10000;
}
return $v;
}
/**
* Get UFWORD from string (Big Endian 16-bit unsigned integer).
* @param $str (string) string from where to extract value
* @param $offset (int) point from where to read the data
* @return int 16 bit value
* @author Nicola Asuni
* @since 5.9.123 (2011-09-30)
* @public static
*/
public static function _getUFWORD($str, $offset) {
$v = self::_getUSHORT($str, $offset);
return $v;
}
/**
* Get FIXED from string (32-bit signed fixed-point number (16.16).
* @param $str (string) string from where to extract value
* @param $offset (int) point from where to read the data
* @return int 16 bit value
* @author Nicola Asuni
* @since 5.9.123 (2011-09-30)
* @public static
*/
public static function _getFIXED($str, $offset) {
// mantissa
$m = self::_getFWORD($str, $offset);
// fraction
$f = self::_getUSHORT($str, ($offset + 2));
$v = floatval(''.$m.'.'.$f.'');
return $v;
}
/**
* Get BYTE from string (8-bit unsigned integer).
* @param $str (string) String from where to extract value.
* @param $offset (int) Point from where to read the data.
* @return int 8 bit value
* @author Nicola Asuni
* @since 5.2.000 (2010-06-02)
* @public static
*/
public static function _getBYTE($str, $offset) {
$v = unpack('Ci', substr($str, $offset, 1));
return $v['i'];
}
/**
* Binary-safe and URL-safe file read.
* 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.
* @param $handle (resource)
* @param $length (int)
* @return Returns the read string or FALSE in case of error.
* @author Nicola Asuni
* @since 4.5.027 (2009-03-16)
* @public static
*/
public static function rfread($handle, $length) {
$data = fread($handle, $length);
if ($data === false) {
return false;
}
$rest = ($length - strlen($data));
if (($rest > 0) && !feof($handle)) {
$data .= self::rfread($handle, $rest);
}
return $data;
}
/**
* Read a 4-byte (32 bit) integer from file.
* @param $f (string) file name.
* @return 4-byte integer
* @public static
*/
public static function _freadint($f) {
$a = unpack('Ni', fread($f, 4));
return $a['i'];
}
/**
* Array of page formats
* measures are calculated in this way: (inches * 72) or (millimeters * 72 / 25.4)
* @public static
*/
public static $page_formats = array(
// ISO 216 A Series + 2 SIS 014711 extensions
'A0' => array( 2383.937, 3370.394), // = ( 841 x 1189 ) mm = ( 33.11 x 46.81 ) in
'A1' => array( 1683.780, 2383.937), // = ( 594 x 841 ) mm = ( 23.39 x 33.11 ) in
'A2' => array( 1190.551, 1683.780), // = ( 420 x 594 ) mm = ( 16.54 x 23.39 ) in
'A3' => array( 841.890, 1190.551), // = ( 297 x 420 ) mm = ( 11.69 x 16.54 ) in
'A4' => array( 595.276, 841.890), // = ( 210 x 297 ) mm = ( 8.27 x 11.69 ) in
'A5' => array( 419.528, 595.276), // = ( 148 x 210 ) mm = ( 5.83 x 8.27 ) in
'A6' => array( 297.638, 419.528), // = ( 105 x 148 ) mm = ( 4.13 x 5.83 ) in
'A7' => array( 209.764, 297.638), // = ( 74 x 105 ) mm = ( 2.91 x 4.13 ) in
'A8' => array( 147.402, 209.764), // = ( 52 x 74 ) mm = ( 2.05 x 2.91 ) in
'A9' => array( 104.882, 147.402), // = ( 37 x 52 ) mm = ( 1.46 x 2.05 ) in
'A10' => array( 73.701, 104.882), // = ( 26 x 37 ) mm = ( 1.02 x 1.46 ) in
'A11' => array( 51.024, 73.701), // = ( 18 x 26 ) mm = ( 0.71 x 1.02 ) in
'A12' => array( 36.850, 51.024), // = ( 13 x 18 ) mm = ( 0.51 x 0.71 ) in
// ISO 216 B Series + 2 SIS 014711 extensions
'B0' => array( 2834.646, 4008.189), // = ( 1000 x 1414 ) mm = ( 39.37 x 55.67 ) in
'B1' => array( 2004.094, 2834.646), // = ( 707 x 1000 ) mm = ( 27.83 x 39.37 ) in
'B2' => array( 1417.323, 2004.094), // = ( 500 x 707 ) mm = ( 19.69 x 27.83 ) in
'B3' => array( 1000.630, 1417.323), // = ( 353 x 500 ) mm = ( 13.90 x 19.69 ) in
'B4' => array( 708.661, 1000.630), // = ( 250 x 353 ) mm = ( 9.84 x 13.90 ) in
'B5' => array( 498.898, 708.661), // = ( 176 x 250 ) mm = ( 6.93 x 9.84 ) in
'B6' => array( 354.331, 498.898), // = ( 125 x 176 ) mm = ( 4.92 x 6.93 ) in
'B7' => array( 249.449, 354.331), // = ( 88 x 125 ) mm = ( 3.46 x 4.92 ) in
'B8' => array( 175.748, 249.449), // = ( 62 x 88 ) mm = ( 2.44 x 3.46 ) in
'B9' => array( 124.724, 175.748), // = ( 44 x 62 ) mm = ( 1.73 x 2.44 ) in
'B10' => array( 87.874, 124.724), // = ( 31 x 44 ) mm = ( 1.22 x 1.73 ) in
'B11' => array( 62.362, 87.874), // = ( 22 x 31 ) mm = ( 0.87 x 1.22 ) in
'B12' => array( 42.520, 62.362), // = ( 15 x 22 ) mm = ( 0.59 x 0.87 ) in
// ISO 216 C Series + 2 SIS 014711 extensions + 5 EXTENSION
'C0' => array( 2599.370, 3676.535), // = ( 917 x 1297 ) mm = ( 36.10 x 51.06 ) in
'C1' => array( 1836.850, 2599.370), // = ( 648 x 917 ) mm = ( 25.51 x 36.10 ) in
'C2' => array( 1298.268, 1836.850), // = ( 458 x 648 ) mm = ( 18.03 x 25.51 ) in
'C3' => array( 918.425, 1298.268), // = ( 324 x 458 ) mm = ( 12.76 x 18.03 ) in
'C4' => array( 649.134, 918.425), // = ( 229 x 324 ) mm = ( 9.02 x 12.76 ) in
'C5' => array( 459.213, 649.134), // = ( 162 x 229 ) mm = ( 6.38 x 9.02 ) in
'C6' => array( 323.150, 459.213), // = ( 114 x 162 ) mm = ( 4.49 x 6.38 ) in
'C7' => array( 229.606, 323.150), // = ( 81 x 114 ) mm = ( 3.19 x 4.49 ) in
'C8' => array( 161.575, 229.606), // = ( 57 x 81 ) mm = ( 2.24 x 3.19 ) in
'C9' => array( 113.386, 161.575), // = ( 40 x 57 ) mm = ( 1.57 x 2.24 ) in
'C10' => array( 79.370, 113.386), // = ( 28 x 40 ) mm = ( 1.10 x 1.57 ) in
'C11' => array( 56.693, 79.370), // = ( 20 x 28 ) mm = ( 0.79 x 1.10 ) in
'C12' => array( 39.685, 56.693), // = ( 14 x 20 ) mm = ( 0.55 x 0.79 ) in
'C76' => array( 229.606, 459.213), // = ( 81 x 162 ) mm = ( 3.19 x 6.38 ) in
'DL' => array( 311.811, 623.622), // = ( 110 x 220 ) mm = ( 4.33 x 8.66 ) in
'DLE' => array( 323.150, 637.795), // = ( 114 x 225 ) mm = ( 4.49 x 8.86 ) in
'DLX' => array( 340.158, 666.142), // = ( 120 x 235 ) mm = ( 4.72 x 9.25 ) in
'DLP' => array( 280.630, 595.276), // = ( 99 x 210 ) mm = ( 3.90 x 8.27 ) in (1/3 A4)
// SIS 014711 E Series
'E0' => array( 2491.654, 3517.795), // = ( 879 x 1241 ) mm = ( 34.61 x 48.86 ) in
'E1' => array( 1757.480, 2491.654), // = ( 620 x 879 ) mm = ( 24.41 x 34.61 ) in
'E2' => array( 1247.244, 1757.480), // = ( 440 x 620 ) mm = ( 17.32 x 24.41 ) in
'E3' => array( 878.740, 1247.244), // = ( 310 x 440 ) mm = ( 12.20 x 17.32 ) in
'E4' => array( 623.622, 878.740), // = ( 220 x 310 ) mm = ( 8.66 x 12.20 ) in
'E5' => array( 439.370, 623.622), // = ( 155 x 220 ) mm = ( 6.10 x 8.66 ) in
'E6' => array( 311.811, 439.370), // = ( 110 x 155 ) mm = ( 4.33 x 6.10 ) in
'E7' => array( 221.102, 311.811), // = ( 78 x 110 ) mm = ( 3.07 x 4.33 ) in
'E8' => array( 155.906, 221.102), // = ( 55 x 78 ) mm = ( 2.17 x 3.07 ) in
'E9' => array( 110.551, 155.906), // = ( 39 x 55 ) mm = ( 1.54 x 2.17 ) in
'E10' => array( 76.535, 110.551), // = ( 27 x 39 ) mm = ( 1.06 x 1.54 ) in
'E11' => array( 53.858, 76.535), // = ( 19 x 27 ) mm = ( 0.75 x 1.06 ) in
'E12' => array( 36.850, 53.858), // = ( 13 x 19 ) mm = ( 0.51 x 0.75 ) in
// SIS 014711 G Series
'G0' => array( 2715.591, 3838.110), // = ( 958 x 1354 ) mm = ( 37.72 x 53.31 ) in
'G1' => array( 1919.055, 2715.591), // = ( 677 x 958 ) mm = ( 26.65 x 37.72 ) in
'G2' => array( 1357.795, 1919.055), // = ( 479 x 677 ) mm = ( 18.86 x 26.65 ) in
'G3' => array( 958.110, 1357.795), // = ( 338 x 479 ) mm = ( 13.31 x 18.86 ) in
'G4' => array( 677.480, 958.110), // = ( 239 x 338 ) mm = ( 9.41 x 13.31 ) in
'G5' => array( 479.055, 677.480), // = ( 169 x 239 ) mm = ( 6.65 x 9.41 ) in
'G6' => array( 337.323, 479.055), // = ( 119 x 169 ) mm = ( 4.69 x 6.65 ) in
'G7' => array( 238.110, 337.323), // = ( 84 x 119 ) mm = ( 3.31 x 4.69 ) in
'G8' => array( 167.244, 238.110), // = ( 59 x 84 ) mm = ( 2.32 x 3.31 ) in
'G9' => array( 119.055, 167.244), // = ( 42 x 59 ) mm = ( 1.65 x 2.32 ) in
'G10' => array( 82.205, 119.055), // = ( 29 x 42 ) mm = ( 1.14 x 1.65 ) in
'G11' => array( 59.528, 82.205), // = ( 21 x 29 ) mm = ( 0.83 x 1.14 ) in
'G12' => array( 39.685, 59.528), // = ( 14 x 21 ) mm = ( 0.55 x 0.83 ) in
// ISO Press
'RA0' => array( 2437.795, 3458.268), // = ( 860 x 1220 ) mm = ( 33.86 x 48.03 ) in
'RA1' => array( 1729.134, 2437.795), // = ( 610 x 860 ) mm = ( 24.02 x 33.86 ) in
'RA2' => array( 1218.898, 1729.134), // = ( 430 x 610 ) mm = ( 16.93 x 24.02 ) in
'RA3' => array( 864.567, 1218.898), // = ( 305 x 430 ) mm = ( 12.01 x 16.93 ) in
'RA4' => array( 609.449, 864.567), // = ( 215 x 305 ) mm = ( 8.46 x 12.01 ) in
'SRA0' => array( 2551.181, 3628.346), // = ( 900 x 1280 ) mm = ( 35.43 x 50.39 ) in
'SRA1' => array( 1814.173, 2551.181), // = ( 640 x 900 ) mm = ( 25.20 x 35.43 ) in
'SRA2' => array( 1275.591, 1814.173), // = ( 450 x 640 ) mm = ( 17.72 x 25.20 ) in
'SRA3' => array( 907.087, 1275.591), // = ( 320 x 450 ) mm = ( 12.60 x 17.72 ) in
'SRA4' => array( 637.795, 907.087), // = ( 225 x 320 ) mm = ( 8.86 x 12.60 ) in
// German DIN 476
'4A0' => array( 4767.874, 6740.787), // = ( 1682 x 2378 ) mm = ( 66.22 x 93.62 ) in
'2A0' => array( 3370.394, 4767.874), // = ( 1189 x 1682 ) mm = ( 46.81 x 66.22 ) in
// Variations on the ISO Standard
'A2_EXTRA' => array( 1261.417, 1754.646), // = ( 445 x 619 ) mm = ( 17.52 x 24.37 ) in
'A3+' => array( 932.598, 1369.134), // = ( 329 x 483 ) mm = ( 12.95 x 19.02 ) in
'A3_EXTRA' => array( 912.756, 1261.417), // = ( 322 x 445 ) mm = ( 12.68 x 17.52 ) in
'A3_SUPER' => array( 864.567, 1440.000), // = ( 305 x 508 ) mm = ( 12.01 x 20.00 ) in
'SUPER_A3' => array( 864.567, 1380.472), // = ( 305 x 487 ) mm = ( 12.01 x 19.17 ) in
'A4_EXTRA' => array( 666.142, 912.756), // = ( 235 x 322 ) mm = ( 9.25 x 12.68 ) in
'A4_SUPER' => array( 649.134, 912.756), // = ( 229 x 322 ) mm = ( 9.02 x 12.68 ) in
'SUPER_A4' => array( 643.465, 1009.134), // = ( 227 x 356 ) mm = ( 8.94 x 14.02 ) in
'A4_LONG' => array( 595.276, 986.457), // = ( 210 x 348 ) mm = ( 8.27 x 13.70 ) in
'F4' => array( 595.276, 935.433), // = ( 210 x 330 ) mm = ( 8.27 x 12.99 ) in
'SO_B5_EXTRA' => array( 572.598, 782.362), // = ( 202 x 276 ) mm = ( 7.95 x 10.87 ) in
'A5_EXTRA' => array( 490.394, 666.142), // = ( 173 x 235 ) mm = ( 6.81 x 9.25 ) in
// ANSI Series
'ANSI_E' => array( 2448.000, 3168.000), // = ( 864 x 1118 ) mm = ( 34.00 x 44.00 ) in
'ANSI_D' => array( 1584.000, 2448.000), // = ( 559 x 864 ) mm = ( 22.00 x 34.00 ) in
'ANSI_C' => array( 1224.000, 1584.000), // = ( 432 x 559 ) mm = ( 17.00 x 22.00 ) in
'ANSI_B' => array( 792.000, 1224.000), // = ( 279 x 432 ) mm = ( 11.00 x 17.00 ) in
'ANSI_A' => array( 612.000, 792.000), // = ( 216 x 279 ) mm = ( 8.50 x 11.00 ) in
// Traditional 'Loose' North American Paper Sizes
'USLEDGER' => array( 1224.000, 792.000), // = ( 432 x 279 ) mm = ( 17.00 x 11.00 ) in
'LEDGER' => array( 1224.000, 792.000), // = ( 432 x 279 ) mm = ( 17.00 x 11.00 ) in
'ORGANIZERK' => array( 792.000, 1224.000), // = ( 279 x 432 ) mm = ( 11.00 x 17.00 ) in
'BIBLE' => array( 792.000, 1224.000), // = ( 279 x 432 ) mm = ( 11.00 x 17.00 ) in
'USTABLOID' => array( 792.000, 1224.000), // = ( 279 x 432 ) mm = ( 11.00 x 17.00 ) in
'TABLOID' => array( 792.000, 1224.000), // = ( 279 x 432 ) mm = ( 11.00 x 17.00 ) in
'ORGANIZERM' => array( 612.000, 792.000), // = ( 216 x 279 ) mm = ( 8.50 x 11.00 ) in
'USLETTER' => array( 612.000, 792.000), // = ( 216 x 279 ) mm = ( 8.50 x 11.00 ) in
'LETTER' => array( 612.000, 792.000), // = ( 216 x 279 ) mm = ( 8.50 x 11.00 ) in
'USLEGAL' => array( 612.000, 1008.000), // = ( 216 x 356 ) mm = ( 8.50 x 14.00 ) in
'LEGAL' => array( 612.000, 1008.000), // = ( 216 x 356 ) mm = ( 8.50 x 14.00 ) in
'GOVERNMENTLETTER' => array( 576.000, 756.000), // = ( 203 x 267 ) mm = ( 8.00 x 10.50 ) in
'GLETTER' => array( 576.000, 756.000), // = ( 203 x 267 ) mm = ( 8.00 x 10.50 ) in
'JUNIORLEGAL' => array( 576.000, 360.000), // = ( 203 x 127 ) mm = ( 8.00 x 5.00 ) in
'JLEGAL' => array( 576.000, 360.000), // = ( 203 x 127 ) mm = ( 8.00 x 5.00 ) in
// Other North American Paper Sizes
'QUADDEMY' => array( 2520.000, 3240.000), // = ( 889 x 1143 ) mm = ( 35.00 x 45.00 ) in
'SUPER_B' => array( 936.000, 1368.000), // = ( 330 x 483 ) mm = ( 13.00 x 19.00 ) in
'QUARTO' => array( 648.000, 792.000), // = ( 229 x 279 ) mm = ( 9.00 x 11.00 ) in
'GOVERNMENTLEGAL' => array( 612.000, 936.000), // = ( 216 x 330 ) mm = ( 8.50 x 13.00 ) in
'FOLIO' => array( 612.000, 936.000), // = ( 216 x 330 ) mm = ( 8.50 x 13.00 ) in
'MONARCH' => array( 522.000, 756.000), // = ( 184 x 267 ) mm = ( 7.25 x 10.50 ) in
'EXECUTIVE' => array( 522.000, 756.000), // = ( 184 x 267 ) mm = ( 7.25 x 10.50 ) in
'ORGANIZERL' => array( 396.000, 612.000), // = ( 140 x 216 ) mm = ( 5.50 x 8.50 ) in
'STATEMENT' => array( 396.000, 612.000), // = ( 140 x 216 ) mm = ( 5.50 x 8.50 ) in
'MEMO' => array( 396.000, 612.000), // = ( 140 x 216 ) mm = ( 5.50 x 8.50 ) in
'FOOLSCAP' => array( 595.440, 936.000), // = ( 210 x 330 ) mm = ( 8.27 x 13.00 ) in
'COMPACT' => array( 306.000, 486.000), // = ( 108 x 171 ) mm = ( 4.25 x 6.75 ) in
'ORGANIZERJ' => array( 198.000, 360.000), // = ( 70 x 127 ) mm = ( 2.75 x 5.00 ) in
// Canadian standard CAN 2-9.60M
'P1' => array( 1587.402, 2437.795), // = ( 560 x 860 ) mm = ( 22.05 x 33.86 ) in
'P2' => array( 1218.898, 1587.402), // = ( 430 x 560 ) mm = ( 16.93 x 22.05 ) in
'P3' => array( 793.701, 1218.898), // = ( 280 x 430 ) mm = ( 11.02 x 16.93 ) in
'P4' => array( 609.449, 793.701), // = ( 215 x 280 ) mm = ( 8.46 x 11.02 ) in
'P5' => array( 396.850, 609.449), // = ( 140 x 215 ) mm = ( 5.51 x 8.46 ) in
'P6' => array( 303.307, 396.850), // = ( 107 x 140 ) mm = ( 4.21 x 5.51 ) in
// North American Architectural Sizes
'ARCH_E' => array( 2592.000, 3456.000), // = ( 914 x 1219 ) mm = ( 36.00 x 48.00 ) in
'ARCH_E1' => array( 2160.000, 3024.000), // = ( 762 x 1067 ) mm = ( 30.00 x 42.00 ) in
'ARCH_D' => array( 1728.000, 2592.000), // = ( 610 x 914 ) mm = ( 24.00 x 36.00 ) in
'BROADSHEET' => array( 1296.000, 1728.000), // = ( 457 x 610 ) mm = ( 18.00 x 24.00 ) in
'ARCH_C' => array( 1296.000, 1728.000), // = ( 457 x 610 ) mm = ( 18.00 x 24.00 ) in
'ARCH_B' => array( 864.000, 1296.000), // = ( 305 x 457 ) mm = ( 12.00 x 18.00 ) in
'ARCH_A' => array( 648.000, 864.000), // = ( 229 x 305 ) mm = ( 9.00 x 12.00 ) in
// -- North American Envelope Sizes
// - Announcement Envelopes
'ANNENV_A2' => array( 314.640, 414.000), // = ( 111 x 146 ) mm = ( 4.37 x 5.75 ) in
'ANNENV_A6' => array( 342.000, 468.000), // = ( 121 x 165 ) mm = ( 4.75 x 6.50 ) in
'ANNENV_A7' => array( 378.000, 522.000), // = ( 133 x 184 ) mm = ( 5.25 x 7.25 ) in
'ANNENV_A8' => array( 396.000, 584.640), // = ( 140 x 206 ) mm = ( 5.50 x 8.12 ) in
'ANNENV_A10' => array( 450.000, 692.640), // = ( 159 x 244 ) mm = ( 6.25 x 9.62 ) in
'ANNENV_SLIM' => array( 278.640, 638.640), // = ( 98 x 225 ) mm = ( 3.87 x 8.87 ) in
// - Commercial Envelopes
'COMMENV_N6_1/4' => array( 252.000, 432.000), // = ( 89 x 152 ) mm = ( 3.50 x 6.00 ) in
'COMMENV_N6_3/4' => array( 260.640, 468.000), // = ( 92 x 165 ) mm = ( 3.62 x 6.50 ) in
'COMMENV_N8' => array( 278.640, 540.000), // = ( 98 x 191 ) mm = ( 3.87 x 7.50 ) in
'COMMENV_N9' => array( 278.640, 638.640), // = ( 98 x 225 ) mm = ( 3.87 x 8.87 ) in
'COMMENV_N10' => array( 296.640, 684.000), // = ( 105 x 241 ) mm = ( 4.12 x 9.50 ) in
'COMMENV_N11' => array( 324.000, 746.640), // = ( 114 x 263 ) mm = ( 4.50 x 10.37 ) in
'COMMENV_N12' => array( 342.000, 792.000), // = ( 121 x 279 ) mm = ( 4.75 x 11.00 ) in
'COMMENV_N14' => array( 360.000, 828.000), // = ( 127 x 292 ) mm = ( 5.00 x 11.50 ) in
// - Catalogue Envelopes
'CATENV_N1' => array( 432.000, 648.000), // = ( 152 x 229 ) mm = ( 6.00 x 9.00 ) in
'CATENV_N1_3/4' => array( 468.000, 684.000), // = ( 165 x 241 ) mm = ( 6.50 x 9.50 ) in
'CATENV_N2' => array( 468.000, 720.000), // = ( 165 x 254 ) mm = ( 6.50 x 10.00 ) in
'CATENV_N3' => array( 504.000, 720.000), // = ( 178 x 254 ) mm = ( 7.00 x 10.00 ) in
'CATENV_N6' => array( 540.000, 756.000), // = ( 191 x 267 ) mm = ( 7.50 x 10.50 ) in
'CATENV_N7' => array( 576.000, 792.000), // = ( 203 x 279 ) mm = ( 8.00 x 11.00 ) in
'CATENV_N8' => array( 594.000, 810.000), // = ( 210 x 286 ) mm = ( 8.25 x 11.25 ) in
'CATENV_N9_1/2' => array( 612.000, 756.000), // = ( 216 x 267 ) mm = ( 8.50 x 10.50 ) in
'CATENV_N9_3/4' => array( 630.000, 810.000), // = ( 222 x 286 ) mm = ( 8.75 x 11.25 ) in
'CATENV_N10_1/2' => array( 648.000, 864.000), // = ( 229 x 305 ) mm = ( 9.00 x 12.00 ) in
'CATENV_N12_1/2' => array( 684.000, 900.000), // = ( 241 x 318 ) mm = ( 9.50 x 12.50 ) in
'CATENV_N13_1/2' => array( 720.000, 936.000), // = ( 254 x 330 ) mm = ( 10.00 x 13.00 ) in
'CATENV_N14_1/4' => array( 810.000, 882.000), // = ( 286 x 311 ) mm = ( 11.25 x 12.25 ) in
'CATENV_N14_1/2' => array( 828.000, 1044.000), // = ( 292 x 368 ) mm = ( 11.50 x 14.50 ) in
// Japanese (JIS P 0138-61) Standard B-Series
'JIS_B0' => array( 2919.685, 4127.244), // = ( 1030 x 1456 ) mm = ( 40.55 x 57.32 ) in
'JIS_B1' => array( 2063.622, 2919.685), // = ( 728 x 1030 ) mm = ( 28.66 x 40.55 ) in
'JIS_B2' => array( 1459.843, 2063.622), // = ( 515 x 728 ) mm = ( 20.28 x 28.66 ) in
'JIS_B3' => array( 1031.811, 1459.843), // = ( 364 x 515 ) mm = ( 14.33 x 20.28 ) in
'JIS_B4' => array( 728.504, 1031.811), // = ( 257 x 364 ) mm = ( 10.12 x 14.33 ) in
'JIS_B5' => array( 515.906, 728.504), // = ( 182 x 257 ) mm = ( 7.17 x 10.12 ) in
'JIS_B6' => array( 362.835, 515.906), // = ( 128 x 182 ) mm = ( 5.04 x 7.17 ) in
'JIS_B7' => array( 257.953, 362.835), // = ( 91 x 128 ) mm = ( 3.58 x 5.04 ) in
'JIS_B8' => array( 181.417, 257.953), // = ( 64 x 91 ) mm = ( 2.52 x 3.58 ) in
'JIS_B9' => array( 127.559, 181.417), // = ( 45 x 64 ) mm = ( 1.77 x 2.52 ) in
'JIS_B10' => array( 90.709, 127.559), // = ( 32 x 45 ) mm = ( 1.26 x 1.77 ) in
'JIS_B11' => array( 62.362, 90.709), // = ( 22 x 32 ) mm = ( 0.87 x 1.26 ) in
'JIS_B12' => array( 45.354, 62.362), // = ( 16 x 22 ) mm = ( 0.63 x 0.87 ) in
// PA Series
'PA0' => array( 2381.102, 3174.803), // = ( 840 x 1120 ) mm = ( 33.07 x 44.09 ) in
'PA1' => array( 1587.402, 2381.102), // = ( 560 x 840 ) mm = ( 22.05 x 33.07 ) in
'PA2' => array( 1190.551, 1587.402), // = ( 420 x 560 ) mm = ( 16.54 x 22.05 ) in
'PA3' => array( 793.701, 1190.551), // = ( 280 x 420 ) mm = ( 11.02 x 16.54 ) in
'PA4' => array( 595.276, 793.701), // = ( 210 x 280 ) mm = ( 8.27 x 11.02 ) in
'PA5' => array( 396.850, 595.276), // = ( 140 x 210 ) mm = ( 5.51 x 8.27 ) in
'PA6' => array( 297.638, 396.850), // = ( 105 x 140 ) mm = ( 4.13 x 5.51 ) in
'PA7' => array( 198.425, 297.638), // = ( 70 x 105 ) mm = ( 2.76 x 4.13 ) in
'PA8' => array( 147.402, 198.425), // = ( 52 x 70 ) mm = ( 2.05 x 2.76 ) in
'PA9' => array( 99.213, 147.402), // = ( 35 x 52 ) mm = ( 1.38 x 2.05 ) in
'PA10' => array( 73.701, 99.213), // = ( 26 x 35 ) mm = ( 1.02 x 1.38 ) in
// Standard Photographic Print Sizes
'PASSPORT_PHOTO' => array( 99.213, 127.559), // = ( 35 x 45 ) mm = ( 1.38 x 1.77 ) in
'E' => array( 233.858, 340.157), // = ( 82 x 120 ) mm = ( 3.25 x 4.72 ) in
'L' => array( 252.283, 360.000), // = ( 89 x 127 ) mm = ( 3.50 x 5.00 ) in
'3R' => array( 252.283, 360.000), // = ( 89 x 127 ) mm = ( 3.50 x 5.00 ) in
'KG' => array( 289.134, 430.866), // = ( 102 x 152 ) mm = ( 4.02 x 5.98 ) in
'4R' => array( 289.134, 430.866), // = ( 102 x 152 ) mm = ( 4.02 x 5.98 ) in
'4D' => array( 340.157, 430.866), // = ( 120 x 152 ) mm = ( 4.72 x 5.98 ) in
'2L' => array( 360.000, 504.567), // = ( 127 x 178 ) mm = ( 5.00 x 7.01 ) in
'5R' => array( 360.000, 504.567), // = ( 127 x 178 ) mm = ( 5.00 x 7.01 ) in
'8P' => array( 430.866, 575.433), // = ( 152 x 203 ) mm = ( 5.98 x 7.99 ) in
'6R' => array( 430.866, 575.433), // = ( 152 x 203 ) mm = ( 5.98 x 7.99 ) in
'6P' => array( 575.433, 720.000), // = ( 203 x 254 ) mm = ( 7.99 x 10.00 ) in
'8R' => array( 575.433, 720.000), // = ( 203 x 254 ) mm = ( 7.99 x 10.00 ) in
'6PW' => array( 575.433, 864.567), // = ( 203 x 305 ) mm = ( 7.99 x 12.01 ) in
'S8R' => array( 575.433, 864.567), // = ( 203 x 305 ) mm = ( 7.99 x 12.01 ) in
'4P' => array( 720.000, 864.567), // = ( 254 x 305 ) mm = ( 10.00 x 12.01 ) in
'10R' => array( 720.000, 864.567), // = ( 254 x 305 ) mm = ( 10.00 x 12.01 ) in
'4PW' => array( 720.000, 1080.000), // = ( 254 x 381 ) mm = ( 10.00 x 15.00 ) in
'S10R' => array( 720.000, 1080.000), // = ( 254 x 381 ) mm = ( 10.00 x 15.00 ) in
'11R' => array( 790.866, 1009.134), // = ( 279 x 356 ) mm = ( 10.98 x 14.02 ) in
'S11R' => array( 790.866, 1224.567), // = ( 279 x 432 ) mm = ( 10.98 x 17.01 ) in
'12R' => array( 864.567, 1080.000), // = ( 305 x 381 ) mm = ( 12.01 x 15.00 ) in
'S12R' => array( 864.567, 1292.598), // = ( 305 x 456 ) mm = ( 12.01 x 17.95 ) in
// Common Newspaper Sizes
'NEWSPAPER_BROADSHEET' => array( 2125.984, 1700.787), // = ( 750 x 600 ) mm = ( 29.53 x 23.62 ) in
'NEWSPAPER_BERLINER' => array( 1332.283, 892.913), // = ( 470 x 315 ) mm = ( 18.50 x 12.40 ) in
'NEWSPAPER_TABLOID' => array( 1218.898, 793.701), // = ( 430 x 280 ) mm = ( 16.93 x 11.02 ) in
'NEWSPAPER_COMPACT' => array( 1218.898, 793.701), // = ( 430 x 280 ) mm = ( 16.93 x 11.02 ) in
// Business Cards
'CREDIT_CARD' => array( 153.014, 242.646), // = ( 54 x 86 ) mm = ( 2.13 x 3.37 ) in
'BUSINESS_CARD' => array( 153.014, 242.646), // = ( 54 x 86 ) mm = ( 2.13 x 3.37 ) in
'BUSINESS_CARD_ISO7810' => array( 153.014, 242.646), // = ( 54 x 86 ) mm = ( 2.13 x 3.37 ) in
'BUSINESS_CARD_ISO216' => array( 147.402, 209.764), // = ( 52 x 74 ) mm = ( 2.05 x 2.91 ) in
'BUSINESS_CARD_IT' => array( 155.906, 240.945), // = ( 55 x 85 ) mm = ( 2.17 x 3.35 ) in
'BUSINESS_CARD_UK' => array( 155.906, 240.945), // = ( 55 x 85 ) mm = ( 2.17 x 3.35 ) in
'BUSINESS_CARD_FR' => array( 155.906, 240.945), // = ( 55 x 85 ) mm = ( 2.17 x 3.35 ) in
'BUSINESS_CARD_DE' => array( 155.906, 240.945), // = ( 55 x 85 ) mm = ( 2.17 x 3.35 ) in
'BUSINESS_CARD_ES' => array( 155.906, 240.945), // = ( 55 x 85 ) mm = ( 2.17 x 3.35 ) in
'BUSINESS_CARD_CA' => array( 144.567, 252.283), // = ( 51 x 89 ) mm = ( 2.01 x 3.50 ) in
'BUSINESS_CARD_US' => array( 144.567, 252.283), // = ( 51 x 89 ) mm = ( 2.01 x 3.50 ) in
'BUSINESS_CARD_JP' => array( 155.906, 257.953), // = ( 55 x 91 ) mm = ( 2.17 x 3.58 ) in
'BUSINESS_CARD_HK' => array( 153.071, 255.118), // = ( 54 x 90 ) mm = ( 2.13 x 3.54 ) in
'BUSINESS_CARD_AU' => array( 155.906, 255.118), // = ( 55 x 90 ) mm = ( 2.17 x 3.54 ) in
'BUSINESS_CARD_DK' => array( 155.906, 255.118), // = ( 55 x 90 ) mm = ( 2.17 x 3.54 ) in
'BUSINESS_CARD_SE' => array( 155.906, 255.118), // = ( 55 x 90 ) mm = ( 2.17 x 3.54 ) in
'BUSINESS_CARD_RU' => array( 141.732, 255.118), // = ( 50 x 90 ) mm = ( 1.97 x 3.54 ) in
'BUSINESS_CARD_CZ' => array( 141.732, 255.118), // = ( 50 x 90 ) mm = ( 1.97 x 3.54 ) in
'BUSINESS_CARD_FI' => array( 141.732, 255.118), // = ( 50 x 90 ) mm = ( 1.97 x 3.54 ) in
'BUSINESS_CARD_HU' => array( 141.732, 255.118), // = ( 50 x 90 ) mm = ( 1.97 x 3.54 ) in
'BUSINESS_CARD_IL' => array( 141.732, 255.118), // = ( 50 x 90 ) mm = ( 1.97 x 3.54 ) in
// Billboards
'4SHEET' => array( 2880.000, 4320.000), // = ( 1016 x 1524 ) mm = ( 40.00 x 60.00 ) in
'6SHEET' => array( 3401.575, 5102.362), // = ( 1200 x 1800 ) mm = ( 47.24 x 70.87 ) in
'12SHEET' => array( 8640.000, 4320.000), // = ( 3048 x 1524 ) mm = (120.00 x 60.00 ) in
'16SHEET' => array( 5760.000, 8640.000), // = ( 2032 x 3048 ) mm = ( 80.00 x 120.00) in
'32SHEET' => array(11520.000, 8640.000), // = ( 4064 x 3048 ) mm = (160.00 x 120.00) in
'48SHEET' => array(17280.000, 8640.000), // = ( 6096 x 3048 ) mm = (240.00 x 120.00) in
'64SHEET' => array(23040.000, 8640.000), // = ( 8128 x 3048 ) mm = (320.00 x 120.00) in
'96SHEET' => array(34560.000, 8640.000), // = (12192 x 3048 ) mm = (480.00 x 120.00) in
// -- Old European Sizes
// - Old Imperial English Sizes
'EN_EMPEROR' => array( 3456.000, 5184.000), // = ( 1219 x 1829 ) mm = ( 48.00 x 72.00 ) in
'EN_ANTIQUARIAN' => array( 2232.000, 3816.000), // = ( 787 x 1346 ) mm = ( 31.00 x 53.00 ) in
'EN_GRAND_EAGLE' => array( 2070.000, 3024.000), // = ( 730 x 1067 ) mm = ( 28.75 x 42.00 ) in
'EN_DOUBLE_ELEPHANT' => array( 1926.000, 2880.000), // = ( 679 x 1016 ) mm = ( 26.75 x 40.00 ) in
'EN_ATLAS' => array( 1872.000, 2448.000), // = ( 660 x 864 ) mm = ( 26.00 x 34.00 ) in
'EN_COLOMBIER' => array( 1692.000, 2484.000), // = ( 597 x 876 ) mm = ( 23.50 x 34.50 ) in
'EN_ELEPHANT' => array( 1656.000, 2016.000), // = ( 584 x 711 ) mm = ( 23.00 x 28.00 ) in
'EN_DOUBLE_DEMY' => array( 1620.000, 2556.000), // = ( 572 x 902 ) mm = ( 22.50 x 35.50 ) in
'EN_IMPERIAL' => array( 1584.000, 2160.000), // = ( 559 x 762 ) mm = ( 22.00 x 30.00 ) in
'EN_PRINCESS' => array( 1548.000, 2016.000), // = ( 546 x 711 ) mm = ( 21.50 x 28.00 ) in
'EN_CARTRIDGE' => array( 1512.000, 1872.000), // = ( 533 x 660 ) mm = ( 21.00 x 26.00 ) in
'EN_DOUBLE_LARGE_POST' => array( 1512.000, 2376.000), // = ( 533 x 838 ) mm = ( 21.00 x 33.00 ) in
'EN_ROYAL' => array( 1440.000, 1800.000), // = ( 508 x 635 ) mm = ( 20.00 x 25.00 ) in
'EN_SHEET' => array( 1404.000, 1692.000), // = ( 495 x 597 ) mm = ( 19.50 x 23.50 ) in
'EN_HALF_POST' => array( 1404.000, 1692.000), // = ( 495 x 597 ) mm = ( 19.50 x 23.50 ) in
'EN_SUPER_ROYAL' => array( 1368.000, 1944.000), // = ( 483 x 686 ) mm = ( 19.00 x 27.00 ) in
'EN_DOUBLE_POST' => array( 1368.000, 2196.000), // = ( 483 x 775 ) mm = ( 19.00 x 30.50 ) in
'EN_MEDIUM' => array( 1260.000, 1656.000), // = ( 445 x 584 ) mm = ( 17.50 x 23.00 ) in
'EN_DEMY' => array( 1260.000, 1620.000), // = ( 445 x 572 ) mm = ( 17.50 x 22.50 ) in
'EN_LARGE_POST' => array( 1188.000, 1512.000), // = ( 419 x 533 ) mm = ( 16.50 x 21.00 ) in
'EN_COPY_DRAUGHT' => array( 1152.000, 1440.000), // = ( 406 x 508 ) mm = ( 16.00 x 20.00 ) in
'EN_POST' => array( 1116.000, 1386.000), // = ( 394 x 489 ) mm = ( 15.50 x 19.25 ) in
'EN_CROWN' => array( 1080.000, 1440.000), // = ( 381 x 508 ) mm = ( 15.00 x 20.00 ) in
'EN_PINCHED_POST' => array( 1062.000, 1332.000), // = ( 375 x 470 ) mm = ( 14.75 x 18.50 ) in
'EN_BRIEF' => array( 972.000, 1152.000), // = ( 343 x 406 ) mm = ( 13.50 x 16.00 ) in
'EN_FOOLSCAP' => array( 972.000, 1224.000), // = ( 343 x 432 ) mm = ( 13.50 x 17.00 ) in
'EN_SMALL_FOOLSCAP' => array( 954.000, 1188.000), // = ( 337 x 419 ) mm = ( 13.25 x 16.50 ) in
'EN_POTT' => array( 900.000, 1080.000), // = ( 318 x 381 ) mm = ( 12.50 x 15.00 ) in
// - Old Imperial Belgian Sizes
'BE_GRAND_AIGLE' => array( 1984.252, 2948.031), // = ( 700 x 1040 ) mm = ( 27.56 x 40.94 ) in
'BE_COLOMBIER' => array( 1757.480, 2409.449), // = ( 620 x 850 ) mm = ( 24.41 x 33.46 ) in
'BE_DOUBLE_CARRE' => array( 1757.480, 2607.874), // = ( 620 x 920 ) mm = ( 24.41 x 36.22 ) in
'BE_ELEPHANT' => array( 1746.142, 2182.677), // = ( 616 x 770 ) mm = ( 24.25 x 30.31 ) in
'BE_PETIT_AIGLE' => array( 1700.787, 2381.102), // = ( 600 x 840 ) mm = ( 23.62 x 33.07 ) in
'BE_GRAND_JESUS' => array( 1559.055, 2069.291), // = ( 550 x 730 ) mm = ( 21.65 x 28.74 ) in
'BE_JESUS' => array( 1530.709, 2069.291), // = ( 540 x 730 ) mm = ( 21.26 x 28.74 ) in
'BE_RAISIN' => array( 1417.323, 1842.520), // = ( 500 x 650 ) mm = ( 19.69 x 25.59 ) in
'BE_GRAND_MEDIAN' => array( 1303.937, 1714.961), // = ( 460 x 605 ) mm = ( 18.11 x 23.82 ) in
'BE_DOUBLE_POSTE' => array( 1233.071, 1601.575), // = ( 435 x 565 ) mm = ( 17.13 x 22.24 ) in
'BE_COQUILLE' => array( 1218.898, 1587.402), // = ( 430 x 560 ) mm = ( 16.93 x 22.05 ) in
'BE_PETIT_MEDIAN' => array( 1176.378, 1502.362), // = ( 415 x 530 ) mm = ( 16.34 x 20.87 ) in
'BE_RUCHE' => array( 1020.472, 1303.937), // = ( 360 x 460 ) mm = ( 14.17 x 18.11 ) in
'BE_PROPATRIA' => array( 977.953, 1218.898), // = ( 345 x 430 ) mm = ( 13.58 x 16.93 ) in
'BE_LYS' => array( 898.583, 1125.354), // = ( 317 x 397 ) mm = ( 12.48 x 15.63 ) in
'BE_POT' => array( 870.236, 1088.504), // = ( 307 x 384 ) mm = ( 12.09 x 15.12 ) in
'BE_ROSETTE' => array( 765.354, 983.622), // = ( 270 x 347 ) mm = ( 10.63 x 13.66 ) in
// - Old Imperial French Sizes
'FR_UNIVERS' => array( 2834.646, 3685.039), // = ( 1000 x 1300 ) mm = ( 39.37 x 51.18 ) in
'FR_DOUBLE_COLOMBIER' => array( 2551.181, 3571.654), // = ( 900 x 1260 ) mm = ( 35.43 x 49.61 ) in
'FR_GRANDE_MONDE' => array( 2551.181, 3571.654), // = ( 900 x 1260 ) mm = ( 35.43 x 49.61 ) in
'FR_DOUBLE_SOLEIL' => array( 2267.717, 3401.575), // = ( 800 x 1200 ) mm = ( 31.50 x 47.24 ) in
'FR_DOUBLE_JESUS' => array( 2154.331, 3174.803), // = ( 760 x 1120 ) mm = ( 29.92 x 44.09 ) in
'FR_GRAND_AIGLE' => array( 2125.984, 3004.724), // = ( 750 x 1060 ) mm = ( 29.53 x 41.73 ) in
'FR_PETIT_AIGLE' => array( 1984.252, 2664.567), // = ( 700 x 940 ) mm = ( 27.56 x 37.01 ) in
'FR_DOUBLE_RAISIN' => array( 1842.520, 2834.646), // = ( 650 x 1000 ) mm = ( 25.59 x 39.37 ) in
'FR_JOURNAL' => array( 1842.520, 2664.567), // = ( 650 x 940 ) mm = ( 25.59 x 37.01 ) in
'FR_COLOMBIER_AFFICHE' => array( 1785.827, 2551.181), // = ( 630 x 900 ) mm = ( 24.80 x 35.43 ) in
'FR_DOUBLE_CAVALIER' => array( 1757.480, 2607.874), // = ( 620 x 920 ) mm = ( 24.41 x 36.22 ) in
'FR_CLOCHE' => array( 1700.787, 2267.717), // = ( 600 x 800 ) mm = ( 23.62 x 31.50 ) in
'FR_SOLEIL' => array( 1700.787, 2267.717), // = ( 600 x 800 ) mm = ( 23.62 x 31.50 ) in
'FR_DOUBLE_CARRE' => array( 1587.402, 2551.181), // = ( 560 x 900 ) mm = ( 22.05 x 35.43 ) in
'FR_DOUBLE_COQUILLE' => array( 1587.402, 2494.488), // = ( 560 x 880 ) mm = ( 22.05 x 34.65 ) in
'FR_JESUS' => array( 1587.402, 2154.331), // = ( 560 x 760 ) mm = ( 22.05 x 29.92 ) in
'FR_RAISIN' => array( 1417.323, 1842.520), // = ( 500 x 650 ) mm = ( 19.69 x 25.59 ) in
'FR_CAVALIER' => array( 1303.937, 1757.480), // = ( 460 x 620 ) mm = ( 18.11 x 24.41 ) in
'FR_DOUBLE_COURONNE' => array( 1303.937, 2040.945), // = ( 460 x 720 ) mm = ( 18.11 x 28.35 ) in
'FR_CARRE' => array( 1275.591, 1587.402), // = ( 450 x 560 ) mm = ( 17.72 x 22.05 ) in
'FR_COQUILLE' => array( 1247.244, 1587.402), // = ( 440 x 560 ) mm = ( 17.32 x 22.05 ) in
'FR_DOUBLE_TELLIERE' => array( 1247.244, 1927.559), // = ( 440 x 680 ) mm = ( 17.32 x 26.77 ) in
'FR_DOUBLE_CLOCHE' => array( 1133.858, 1700.787), // = ( 400 x 600 ) mm = ( 15.75 x 23.62 ) in
'FR_DOUBLE_POT' => array( 1133.858, 1757.480), // = ( 400 x 620 ) mm = ( 15.75 x 24.41 ) in
'FR_ECU' => array( 1133.858, 1474.016), // = ( 400 x 520 ) mm = ( 15.75 x 20.47 ) in
'FR_COURONNE' => array( 1020.472, 1303.937), // = ( 360 x 460 ) mm = ( 14.17 x 18.11 ) in
'FR_TELLIERE' => array( 963.780, 1247.244), // = ( 340 x 440 ) mm = ( 13.39 x 17.32 ) in
'FR_POT' => array( 878.740, 1133.858), // = ( 310 x 400 ) mm = ( 12.20 x 15.75 ) in
);
/**
* Get page dimensions from format name.
* @param $format (mixed) The format name @see self::$page_format<ul>
* @return array containing page width and height in points
* @since 5.0.010 (2010-05-17)
* @public static
*/
public static function getPageSizeFromFormat($format) {
if (isset(self::$page_formats[$format])) {
return self::$page_formats[$format];
}
return self::$page_formats['A4'];
}
/**
* Set page boundaries.
* @param $page (int) page number
* @param $type (string) valid values are: <ul><li>'MediaBox' : the boundaries of the physical medium on which the page shall be displayed or printed;</li><li>'CropBox' : the visible region of default user space;</li><li>'BleedBox' : the region to which the contents of the page shall be clipped when output in a production environment;</li><li>'TrimBox' : the intended dimensions of the finished page after trimming;</li><li>'ArtBox' : the page's meaningful content (including potential white space).</li></ul>
* @param $llx (float) lower-left x coordinate in user units.
* @param $lly (float) lower-left y coordinate in user units.
* @param $urx (float) upper-right x coordinate in user units.
* @param $ury (float) upper-right y coordinate in user units.
* @param $points (boolean) If true uses user units as unit of measure, otherwise uses PDF points.
* @param $k (float) Scale factor (number of points in user unit).
* @param $pagedim (array) Array of page dimensions.
* @return pagedim array of page dimensions.
* @since 5.0.010 (2010-05-17)
* @public static
*/
public static function setPageBoxes($page, $type, $llx, $lly, $urx, $ury, $points=false, $k, $pagedim=array()) {
if (!isset($pagedim[$page])) {
// initialize array
$pagedim[$page] = array();
}
if (!in_array($type, self::$pageboxes)) {
return;
}
if ($points) {
$k = 1;
}
$pagedim[$page][$type]['llx'] = ($llx * $k);
$pagedim[$page][$type]['lly'] = ($lly * $k);
$pagedim[$page][$type]['urx'] = ($urx * $k);
$pagedim[$page][$type]['ury'] = ($ury * $k);
return $pagedim;
}
/**
* Swap X and Y coordinates of page boxes (change page boxes orientation).
* @param $page (int) page number
* @param $pagedim (array) Array of page dimensions.
* @return pagedim array of page dimensions.
* @since 5.0.010 (2010-05-17)
* @public static
*/
public static function swapPageBoxCoordinates($page, $pagedim) {
foreach (self::$pageboxes as $type) {
// swap X and Y coordinates
if (isset($pagedim[$page][$type])) {
$tmp = $pagedim[$page][$type]['llx'];
$pagedim[$page][$type]['llx'] = $pagedim[$page][$type]['lly'];
$pagedim[$page][$type]['lly'] = $tmp;
$tmp = $pagedim[$page][$type]['urx'];
$pagedim[$page][$type]['urx'] = $pagedim[$page][$type]['ury'];
$pagedim[$page][$type]['ury'] = $tmp;
}
}
return $pagedim;
}
/**
* Get the canonical page layout mode.
* @param $layout (string) The page layout. Possible values are:<ul><li>SinglePage Display one page at a time</li><li>OneColumn Display the pages in one column</li><li>TwoColumnLeft Display the pages in two columns, with odd-numbered pages on the left</li><li>TwoColumnRight Display the pages in two columns, with odd-numbered pages on the right</li><li>TwoPageLeft (PDF 1.5) Display the pages two at a time, with odd-numbered pages on the left</li><li>TwoPageRight (PDF 1.5) Display the pages two at a time, with odd-numbered pages on the right</li></ul>
* @return (string) Canonical page layout name.
* @public static
*/
public static function getPageLayoutMode($layout='SinglePage') {
switch ($layout) {
case 'default':
case 'single':
case 'SinglePage': {
$layout_mode = 'SinglePage';
break;
}
case 'continuous':
case 'OneColumn': {
$layout_mode = 'OneColumn';
break;
}
case 'two':
case 'TwoColumnLeft': {
$layout_mode = 'TwoColumnLeft';
break;
}
case 'TwoColumnRight': {
$layout_mode = 'TwoColumnRight';
break;
}
case 'TwoPageLeft': {
$layout_mode = 'TwoPageLeft';
break;
}
case 'TwoPageRight': {
$layout_mode = 'TwoPageRight';
break;
}
default: {
$layout_mode = 'SinglePage';
}
}
return $layout_mode;
}
/**
* Get the canonical page layout mode.
* @param $mode (string) A name object specifying how the document should be displayed when opened:<ul><li>UseNone Neither document outline nor thumbnail images visible</li><li>UseOutlines Document outline visible</li><li>UseThumbs Thumbnail images visible</li><li>FullScreen Full-screen mode, with no menu bar, window controls, or any other window visible</li><li>UseOC (PDF 1.5) Optional content group panel visible</li><li>UseAttachments (PDF 1.6) Attachments panel visible</li></ul>
* @return (string) Canonical page mode name.
* @public static
*/
public static function getPageMode($mode='UseNone') {
switch ($mode) {
case 'UseNone': {
$page_mode = 'UseNone';
break;
}
case 'UseOutlines': {
$page_mode = 'UseOutlines';
break;
}
case 'UseThumbs': {
$page_mode = 'UseThumbs';
break;
}
case 'FullScreen': {
$page_mode = 'FullScreen';
break;
}
case 'UseOC': {
$page_mode = 'UseOC';
break;
}
case '': {
$page_mode = 'UseAttachments';
break;
}
default: {
$page_mode = 'UseNone';
}
}
return $page_mode;
}
} // END OF TCPDF_STATIC CLASS
//============================================================+
// END OF FILE
//============================================================+
§]*)§([^§]*)§/i',
'', $cssdata);
1071 if (isset($cssblocks[
'all']) AND !empty($cssblocks[
'all'])) {
1072 $cssdata .= $cssblocks[
'all'];
1074 if (isset($cssblocks[
'print']) AND !empty($cssblocks[
'print'])) {
1075 $cssdata .= $cssblocks[
'print'];
1078 $cssblocks =
array();
1081 if (substr($cssdata, -1) ==
'}') {
1083 $cssdata = substr($cssdata, 0, -1);
1085 $matches = explode(
'}', $cssdata);
1086 foreach ($matches as $key => $block) {
1088 $cssblocks[$key] = explode(
'{', $block);
1089 if (!isset($cssblocks[$key][1])) {
1091 unset($cssblocks[$key]);
1095 foreach ($cssblocks as $key => $block) {
1096 if (strpos($block[0],
',') > 0) {
1097 $selectors = explode(
',', $block[0]);
1098 foreach ($selectors as $sel) {
1099 $cssblocks[] =
array(0 => trim($sel), 1 => $block[1]);
1101 unset($cssblocks[$key]);
1106 foreach ($cssblocks as $block) {
1107 $selector = $block[0];
1111 $b = intval(preg_match_all(
'/[\#]/', $selector, $matches));
1112 $c = intval(preg_match_all(
'/[\[\.]/', $selector, $matches));
1113 $c += intval(preg_match_all(
'/[\:]link|visited|hover|active|focus|target|lang|enabled|disabled|checked|indeterminate|root|nth|first|last|only|empty|contains|not/i', $selector, $matches));
1114 $d = intval(preg_match_all(
'/[>\+\~\s]{1}[a-zA-Z0-9]+/',
' '.$selector, $matches));
1115 $d += intval(preg_match_all(
'/[\:][\:]/', $selector, $matches));
1116 $specificity = $a.$b.$c.$d;
1118 $cssdata[$specificity.
' '.$selector] = $block[1];
1121 ksort($cssdata, SORT_STRING);
1139 public static function fixHTMLCode(
$html, $default_css=
'', $tagvs=
'', $tidy_options=
'', &$tagvspaces) {
1141 if ($tidy_options ===
'') {
1142 $tidy_options =
array (
1144 'drop-empty-paras' => 0,
1145 'drop-proprietary-attributes' => 1,
1146 'fix-backslash' => 1,
1147 'hide-comments' => 1,
1149 'lower-literals' => 1,
1152 'output-xhtml' => 1,
1162 $tidy = tidy_parse_string(
$html, $tidy_options);
1164 $tidy->cleanRepair();
1166 $tidy_head = tidy_get_head($tidy);
1167 $css = $tidy_head->value;
1168 $css = preg_replace(
'/<style([^>]+)>/ims',
'<style>', $css);
1169 $css = preg_replace(
'/<\/style>(.*)<style>/ims',
"\n", $css);
1170 $css = str_replace(
'/*<![CDATA[*/',
'', $css);
1171 $css = str_replace(
'/*]]>*/',
'', $css);
1172 preg_match(
'/<style>(.*)<\/style>/ims', $css, $matches);
1173 if (isset($matches[1])) {
1174 $css = strtolower($matches[1]);
1179 $css =
'<style>'.$default_css.$css.
'</style>';
1181 $tidy_body = tidy_get_body($tidy);
1182 $html = $tidy_body->value;
1184 $html = str_replace(
'<br>',
'<br />',
$html);
1186 $html = preg_replace(
'/<div([^>]*)><\/div>/',
'',
$html);
1187 $html = preg_replace(
'/<p([^>]*)><\/p>/',
'',
$html);
1188 if ($tagvs !==
'') {
1190 $tagvspaces = $tagvs;
1207 $tag = $dom[$key][
'value'];
1209 if (isset($dom[$key][
'attribute'][
'class']) AND !empty($dom[$key][
'attribute'][
'class'])) {
1210 $class = explode(
' ', strtolower($dom[$key][
'attribute'][
'class']));
1213 if (isset($dom[$key][
'attribute'][
'id']) AND !empty($dom[$key][
'attribute'][
'id'])) {
1214 $id = strtolower($dom[$key][
'attribute'][
'id']);
1216 $selector = preg_replace(
'/([>\+\~\s]{1})([\.]{1})([^>\+\~\s]*)/si',
'\\1*.\\3', $selector);
1218 if (preg_match_all(
'/([>\+\~\s]{1})([a-zA-Z0-9\*]+)([^>\+\~\s]*)/si', $selector, $matches, PREG_PATTERN_ORDER | PREG_OFFSET_CAPTURE) > 0) {
1219 $parentop = array_pop($matches[1]);
1220 $operator = $parentop[0];
1221 $offset = $parentop[1];
1222 $lasttag = array_pop($matches[2]);
1223 $lasttag = strtolower(trim($lasttag[0]));
1224 if (($lasttag ==
'*') OR ($lasttag == $tag)) {
1226 $attrib = array_pop($matches[3]);
1232 if (in_array(substr(
$attrib, 1), $class)) {
1238 if (substr(
$attrib, 1) == $id) {
1244 $attrmatch =
array();
1245 if (preg_match(
'/\[([a-zA-Z0-9]*)[\s]*([\~\^\$\*\|\=]*)[\s]*["]?([^"\]]*)["]?\]/i',
$attrib, $attrmatch) > 0) {
1246 $att = strtolower($attrmatch[1]);
1247 $val = $attrmatch[3];
1248 if (isset($dom[$key][
'attribute'][$att])) {
1249 switch ($attrmatch[2]) {
1251 if ($dom[$key][
'attribute'][$att] == $val) {
1257 if (in_array($val, explode(
' ', $dom[$key][
'attribute'][$att]))) {
1263 if ($val == substr($dom[$key][
'attribute'][$att], 0, strlen($val))) {
1269 if ($val == substr($dom[$key][
'attribute'][$att], -strlen($val))) {
1275 if (strpos($dom[$key][
'attribute'][$att], $val) !==
false) {
1281 if ($dom[$key][
'attribute'][$att] == $val) {
1283 } elseif (preg_match(
'/'.$val.
'[\-]{1}/i', $dom[$key][
'attribute'][$att]) > 0) {
1310 if (
$valid AND ($offset > 0)) {
1313 $selector = substr($selector, 0, $offset);
1314 switch ($operator) {
1316 while ($dom[$key][
'parent'] > 0) {
1317 if (self::isValidCSSSelectorForTag($dom, $dom[$key][
'parent'], $selector)) {
1321 $key = $dom[$key][
'parent'];
1327 $valid = self::isValidCSSSelectorForTag($dom, $dom[$key][
'parent'], $selector);
1331 for ($i = ($key - 1); $i > $dom[$key][
'parent']; --$i) {
1332 if ($dom[$i][
'tag'] AND $dom[$i][
'opening']) {
1333 $valid = self::isValidCSSSelectorForTag($dom, $i, $selector);
1340 for ($i = ($key - 1); $i > $dom[$key][
'parent']; --$i) {
1341 if ($dom[$i][
'tag'] AND $dom[$i][
'opening']) {
1342 if (self::isValidCSSSelectorForTag($dom, $i, $selector)) {
1366 $cssarray =
array();
1368 $selectors =
array();
1369 if (isset($dom[($dom[$key][
'parent'])][
'csssel'])) {
1370 $selectors = $dom[($dom[$key][
'parent'])][
'csssel'];
1373 foreach($css as $selector =>
$style) {
1374 $pos = strpos($selector,
' ');
1376 $specificity = substr($selector, 0, $pos);
1378 $selector = substr($selector, $pos);
1380 if (self::isValidCSSSelectorForTag($dom, $key, $selector)) {
1381 if (!in_array($selector, $selectors)) {
1383 $cssarray[] =
array(
'k' => $selector,
's' => $specificity,
'c' =>
$style);
1384 $selectors[] = $selector;
1388 if (isset($dom[$key][
'attribute'][
'style'])) {
1390 $cssarray[] =
array(
'k' =>
'',
's' =>
'1000',
'c' => $dom[$key][
'attribute'][
'style']);
1393 $cssordered =
array();
1394 foreach ($cssarray as $key => $val) {
1395 $skey = sprintf(
'%04d', $key);
1396 $cssordered[$val[
's'].
'_'.$skey] = $val;
1399 ksort($cssordered, SORT_STRING);
1400 return array($selectors, $cssordered);
1412 foreach ($css as
$style) {
1414 $csscmds = explode(
';', $style[
'c']);
1415 foreach ($csscmds as
$cmd) {
1417 $pos = strpos($cmd,
':');
1418 if ($pos !==
false) {
1419 $cmd = substr($cmd, 0, ($pos + 1));
1420 if (strpos($tagstyle, $cmd) !==
false) {
1422 $tagstyle = preg_replace(
'/'.$cmd.
'[^;]+/i',
'', $tagstyle);
1427 $tagstyle .=
';'.$style[
'c'];
1430 $tagstyle = preg_replace(
'/[;]+/',
';', $tagstyle);
1443 while ($number >= 1000) {
1447 while ($number >= 900) {
1451 while ($number >= 500) {
1455 while ($number >= 400) {
1459 while ($number >= 100) {
1463 while ($number >= 90) {
1467 while ($number >= 50) {
1471 while ($number >= 40) {
1475 while ($number >= 10) {
1479 while ($number >= 9) {
1483 while ($number >= 5) {
1487 while ($number >= 4) {
1491 while ($number >= 1) {
1507 public static function revstrpos($haystack, $needle, $offset = 0) {
1508 $length = strlen($haystack);
1509 $offset = ($offset > 0)?($length - $offset):abs($offset);
1510 $pos = strpos(strrev($haystack), strrev($needle), $offset);
1511 return ($pos ===
false)?
false:($length - $pos - strlen($needle));
1526 $patterns =
array();
1528 $data = preg_replace(
'/\%[^\n]*/',
'',
$data);
1530 preg_match(
'/\\\\patterns\{([^\}]*)\}/i',
$data, $matches);
1531 $data = trim(substr($matches[0], 10, -1));
1533 $patterns_array = preg_split(
'/[\s]+/',
$data);
1535 $patterns =
array();
1536 foreach($patterns_array as $val) {
1539 $val = str_replace(
'\'',
'\\\'', $val);
1540 $key = preg_replace(
'/[0-9]+/',
'', $val);
1541 $patterns[$key] = $val;
1628 if (!empty($default)) {
1629 $op = self::getPathPaintOperator($default,
'');
1649 $tm[0] = ($ta[0] * $tb[0]) + ($ta[2] * $tb[1]);
1650 $tm[1] = ($ta[1] * $tb[0]) + ($ta[3] * $tb[1]);
1651 $tm[2] = ($ta[0] * $tb[2]) + ($ta[2] * $tb[3]);
1652 $tm[3] = ($ta[1] * $tb[2]) + ($ta[3] * $tb[3]);
1653 $tm[4] = ($ta[0] * $tb[4]) + ($ta[2] * $tb[5]) + $ta[4];
1654 $tm[5] = ($ta[1] * $tb[4]) + ($ta[3] * $tb[5]) + $ta[5];
1668 $tm =
array(1, 0, 0, 1, 0, 0);
1669 $transform =
array();
1670 if (preg_match_all(
'/(matrix|translate|scale|rotate|skewX|skewY)[\s]*\(([^\)]+)\)/si', $attribute, $transform, PREG_SET_ORDER) > 0) {
1671 foreach ($transform as $key =>
$data) {
1672 if (!empty(
$data[2])) {
1682 if (preg_match(
'/([a-z0-9\-\.]+)[\,\s]+([a-z0-9\-\.]+)[\,\s]+([a-z0-9\-\.]+)[\,\s]+([a-z0-9\-\.]+)[\,\s]+([a-z0-9\-\.]+)[\,\s]+([a-z0-9\-\.]+)/si',
$data[2], $regs)) {
1693 if (preg_match(
'/([a-z0-9\-\.]+)[\,\s]+([a-z0-9\-\.]+)/si',
$data[2], $regs)) {
1696 } elseif (preg_match(
'/([a-z0-9\-\.]+)/si',
$data[2], $regs)) {
1702 if (preg_match(
'/([a-z0-9\-\.]+)[\,\s]+([a-z0-9\-\.]+)/si',
$data[2], $regs)) {
1705 } elseif (preg_match(
'/([a-z0-9\-\.]+)/si',
$data[2], $regs)) {
1712 if (preg_match(
'/([0-9\-\.]+)[\,\s]+([a-z0-9\-\.]+)[\,\s]+([a-z0-9\-\.]+)/si',
$data[2], $regs)) {
1713 $ang = deg2rad($regs[1]);
1720 $e = (
$x * (1 - $a)) - (
$y * $c);
1721 $f = (
$y * (1 -
$d)) - (
$x * $b);
1722 } elseif (preg_match(
'/([0-9\-\.]+)/si',
$data[2], $regs)) {
1723 $ang = deg2rad($regs[1]);
1734 if (preg_match(
'/([0-9\-\.]+)/si',
$data[2], $regs)) {
1735 $c = tan(deg2rad($regs[1]));
1740 if (preg_match(
'/([0-9\-\.]+)/si',
$data[2], $regs)) {
1741 $b = tan(deg2rad($regs[1]));
1746 $tm = self::getTransformationMatrixProduct($tm,
array($a, $b, $c,
$d, $e, $f));
1764 $dprod = ($x1 * $x2) + ($y1 * $y2);
1765 $dist1 = sqrt(($x1 * $x1) + ($y1 * $y1));
1766 $dist2 = sqrt(($x2 * $x2) + ($y2 * $y2));
1767 $angle = acos($dprod / ($dist1 * $dist2));
1771 if ((($x1 * $y2) - ($x2 * $y1)) < 0) {
1823 public static function pregSplit($pattern, $modifiers, $subject, $limit=NULL, $flags=NULL) {
1825 if ((strpos($modifiers,
'u') === FALSE) OR (count(preg_split(
'//u',
"\n\t", -1, PREG_SPLIT_NO_EMPTY)) == 2)) {
1826 return preg_split($pattern.$modifiers, $subject, $limit, $flags);
1830 while (($nl = strpos($subject,
"\n")) !== FALSE) {
1831 $ret = array_merge(
$ret, preg_split($pattern.$modifiers, substr($subject, 0, $nl), $limit, $flags));
1833 $subject = substr($subject, ($nl + 1));
1835 if (strlen($subject) > 0) {
1836 $ret = array_merge(
$ret, preg_split($pattern.$modifiers, $subject, $limit, $flags));
1849 if (strpos(
$filename,
'://') ===
false) {
1851 } elseif (stream_is_local(
$filename) !==
true) {
1869 if ((strlen(
$file) > 1)
1870 && (
$file[0] ===
'/')
1871 && (
$file[1] !==
'/')
1872 && !empty(
$_SERVER[
'DOCUMENT_ROOT'])
1873 && (
$_SERVER[
'DOCUMENT_ROOT'] !==
'/')
1876 if (($findroot ===
false) || ($findroot > 1)) {
1877 $alt[] = htmlspecialchars_decode(urldecode(
$_SERVER[
'DOCUMENT_ROOT'].
$file));
1882 if (!empty(
$_SERVER[
'HTTPS']) && (strtolower(
$_SERVER[
'HTTPS']) !=
'off')) {
1887 if (preg_match(
'%^//%',
$url) && !empty(
$_SERVER[
'HTTP_HOST'])) {
1888 $url = $protocol.
':'.str_replace(
' ',
'%20',
$url);
1890 $url = htmlspecialchars_decode(
$url);
1893 if (preg_match(
'%^(https?)://%',
$url)
1895 && empty(
$_SERVER[
'DOCUMENT_ROOT'])
1897 $urldata = parse_url(
$url);
1898 if (empty($urldata[
'query'])) {
1899 $host = $protocol.
'://'.
$_SERVER[
'HTTP_HOST'];
1900 if (strpos(
$url, $host) === 0) {
1902 $tmp = str_replace($host,
$_SERVER[
'DOCUMENT_ROOT'],
$url);
1903 $alt[] = htmlspecialchars_decode(urldecode($tmp));
1909 && !preg_match(
'%^(https?|ftp)://%',
$file)
1910 && !preg_match(
'%^//%',
$file)
1912 $urldata = @parse_url(
$_SERVER[
'SCRIPT_URI']);
1913 return $urldata[
'scheme'].
'://'.$urldata[
'host'].(($file[0] ==
'/') ?
'' :
'/').$file;
1916 $alt = array_unique($alt);
1918 foreach ($alt as
$path) {
1919 $ret = @file_get_contents($path);
1920 if (
$ret !==
false) {
1924 if (!ini_get(
'allow_url_fopen')
1925 && function_exists(
'curl_init')
1926 && preg_match(
'%^(https?|ftp)://%', $path)
1930 curl_setopt($crs, CURLOPT_URL, $path);
1931 curl_setopt($crs, CURLOPT_BINARYTRANSFER,
true);
1932 curl_setopt($crs, CURLOPT_FAILONERROR,
true);
1933 curl_setopt($crs, CURLOPT_RETURNTRANSFER,
true);
1934 if ((ini_get(
'open_basedir') ==
'') && (!ini_get(
'safe_mode'))) {
1935 curl_setopt($crs, CURLOPT_FOLLOWLOCATION,
true);
1937 curl_setopt($crs, CURLOPT_CONNECTTIMEOUT, 5);
1938 curl_setopt($crs, CURLOPT_TIMEOUT, 30);
1939 curl_setopt($crs, CURLOPT_SSL_VERIFYPEER,
false);
1940 curl_setopt($crs, CURLOPT_SSL_VERIFYHOST,
false);
1941 curl_setopt($crs, CURLOPT_USERAGENT,
'tc-lib-file');
1942 $ret = curl_exec($crs);
1944 if (
$ret !==
false) {
1964 $v = unpack(
'Ni', substr($str, $offset, 4));
1978 $v = unpack(
'ni', substr($str, $offset, 2));
1992 $v = unpack(
'si', substr($str, $offset, 2));
2006 $v = self::_getUSHORT($str, $offset);
2023 $v = self::_getUSHORT($str, $offset);
2038 $m = self::_getFWORD($str, $offset);
2040 $f = self::_getUSHORT($str, ($offset + 2));
2041 $v = floatval(
''.$m.
'.'.$f.
'');
2055 $v = unpack(
'Ci', substr($str, $offset, 1));
2068 public static function rfread($handle, $length) {
2069 $data = fread($handle, $length);
2070 if (
$data ===
false) {
2074 if ((
$rest > 0) && !feof($handle)) {
2087 $a = unpack(
'Ni', fread($f, 4));
2099 'A0' =>
array( 2383.937, 3370.394),
2100 'A1' =>
array( 1683.780, 2383.937),
2101 'A2' =>
array( 1190.551, 1683.780),
2102 'A3' =>
array( 841.890, 1190.551),
2103 'A4' =>
array( 595.276, 841.890),
2104 'A5' =>
array( 419.528, 595.276),
2105 'A6' =>
array( 297.638, 419.528),
2106 'A7' =>
array( 209.764, 297.638),
2107 'A8' =>
array( 147.402, 209.764),
2108 'A9' =>
array( 104.882, 147.402),
2109 'A10' =>
array( 73.701, 104.882),
2110 'A11' =>
array( 51.024, 73.701),
2111 'A12' =>
array( 36.850, 51.024),
2113 'B0' =>
array( 2834.646, 4008.189),
2114 'B1' =>
array( 2004.094, 2834.646),
2115 'B2' =>
array( 1417.323, 2004.094),
2116 'B3' =>
array( 1000.630, 1417.323),
2117 'B4' =>
array( 708.661, 1000.630),
2118 'B5' =>
array( 498.898, 708.661),
2119 'B6' =>
array( 354.331, 498.898),
2120 'B7' =>
array( 249.449, 354.331),
2121 'B8' =>
array( 175.748, 249.449),
2122 'B9' =>
array( 124.724, 175.748),
2123 'B10' =>
array( 87.874, 124.724),
2124 'B11' =>
array( 62.362, 87.874),
2125 'B12' =>
array( 42.520, 62.362),
2127 'C0' =>
array( 2599.370, 3676.535),
2128 'C1' =>
array( 1836.850, 2599.370),
2129 'C2' =>
array( 1298.268, 1836.850),
2130 'C3' =>
array( 918.425, 1298.268),
2131 'C4' =>
array( 649.134, 918.425),
2132 'C5' =>
array( 459.213, 649.134),
2133 'C6' =>
array( 323.150, 459.213),
2134 'C7' =>
array( 229.606, 323.150),
2135 'C8' =>
array( 161.575, 229.606),
2136 'C9' =>
array( 113.386, 161.575),
2137 'C10' =>
array( 79.370, 113.386),
2138 'C11' =>
array( 56.693, 79.370),
2139 'C12' =>
array( 39.685, 56.693),
2140 'C76' =>
array( 229.606, 459.213),
2141 'DL' =>
array( 311.811, 623.622),
2142 'DLE' =>
array( 323.150, 637.795),
2143 'DLX' =>
array( 340.158, 666.142),
2144 'DLP' =>
array( 280.630, 595.276),
2146 'E0' =>
array( 2491.654, 3517.795),
2147 'E1' =>
array( 1757.480, 2491.654),
2148 'E2' =>
array( 1247.244, 1757.480),
2149 'E3' =>
array( 878.740, 1247.244),
2150 'E4' =>
array( 623.622, 878.740),
2151 'E5' =>
array( 439.370, 623.622),
2152 'E6' =>
array( 311.811, 439.370),
2153 'E7' =>
array( 221.102, 311.811),
2154 'E8' =>
array( 155.906, 221.102),
2155 'E9' =>
array( 110.551, 155.906),
2156 'E10' =>
array( 76.535, 110.551),
2157 'E11' =>
array( 53.858, 76.535),
2158 'E12' =>
array( 36.850, 53.858),
2160 'G0' =>
array( 2715.591, 3838.110),
2161 'G1' =>
array( 1919.055, 2715.591),
2162 'G2' =>
array( 1357.795, 1919.055),
2163 'G3' =>
array( 958.110, 1357.795),
2164 'G4' =>
array( 677.480, 958.110),
2165 'G5' =>
array( 479.055, 677.480),
2166 'G6' =>
array( 337.323, 479.055),
2167 'G7' =>
array( 238.110, 337.323),
2168 'G8' =>
array( 167.244, 238.110),
2169 'G9' =>
array( 119.055, 167.244),
2170 'G10' =>
array( 82.205, 119.055),
2171 'G11' =>
array( 59.528, 82.205),
2172 'G12' =>
array( 39.685, 59.528),
2174 'RA0' =>
array( 2437.795, 3458.268),
2175 'RA1' =>
array( 1729.134, 2437.795),
2176 'RA2' =>
array( 1218.898, 1729.134),
2177 'RA3' =>
array( 864.567, 1218.898),
2178 'RA4' =>
array( 609.449, 864.567),
2179 'SRA0' =>
array( 2551.181, 3628.346),
2180 'SRA1' =>
array( 1814.173, 2551.181),
2181 'SRA2' =>
array( 1275.591, 1814.173),
2182 'SRA3' =>
array( 907.087, 1275.591),
2183 'SRA4' =>
array( 637.795, 907.087),
2185 '4A0' =>
array( 4767.874, 6740.787),
2186 '2A0' =>
array( 3370.394, 4767.874),
2188 'A2_EXTRA' =>
array( 1261.417, 1754.646),
2189 'A3+' =>
array( 932.598, 1369.134),
2190 'A3_EXTRA' =>
array( 912.756, 1261.417),
2191 'A3_SUPER' =>
array( 864.567, 1440.000),
2192 'SUPER_A3' =>
array( 864.567, 1380.472),
2193 'A4_EXTRA' =>
array( 666.142, 912.756),
2194 'A4_SUPER' =>
array( 649.134, 912.756),
2195 'SUPER_A4' =>
array( 643.465, 1009.134),
2196 'A4_LONG' =>
array( 595.276, 986.457),
2197 'F4' =>
array( 595.276, 935.433),
2198 'SO_B5_EXTRA' =>
array( 572.598, 782.362),
2199 'A5_EXTRA' =>
array( 490.394, 666.142),
2201 'ANSI_E' =>
array( 2448.000, 3168.000),
2202 'ANSI_D' =>
array( 1584.000, 2448.000),
2203 'ANSI_C' =>
array( 1224.000, 1584.000),
2204 'ANSI_B' =>
array( 792.000, 1224.000),
2205 'ANSI_A' =>
array( 612.000, 792.000),
2207 'USLEDGER' =>
array( 1224.000, 792.000),
2208 'LEDGER' =>
array( 1224.000, 792.000),
2209 'ORGANIZERK' =>
array( 792.000, 1224.000),
2210 'BIBLE' =>
array( 792.000, 1224.000),
2211 'USTABLOID' =>
array( 792.000, 1224.000),
2212 'TABLOID' =>
array( 792.000, 1224.000),
2213 'ORGANIZERM' =>
array( 612.000, 792.000),
2214 'USLETTER' =>
array( 612.000, 792.000),
2215 'LETTER' =>
array( 612.000, 792.000),
2216 'USLEGAL' =>
array( 612.000, 1008.000),
2217 'LEGAL' =>
array( 612.000, 1008.000),
2218 'GOVERNMENTLETTER' =>
array( 576.000, 756.000),
2219 'GLETTER' =>
array( 576.000, 756.000),
2220 'JUNIORLEGAL' =>
array( 576.000, 360.000),
2221 'JLEGAL' =>
array( 576.000, 360.000),
2223 'QUADDEMY' =>
array( 2520.000, 3240.000),
2224 'SUPER_B' =>
array( 936.000, 1368.000),
2225 'QUARTO' =>
array( 648.000, 792.000),
2226 'GOVERNMENTLEGAL' =>
array( 612.000, 936.000),
2227 'FOLIO' =>
array( 612.000, 936.000),
2228 'MONARCH' =>
array( 522.000, 756.000),
2229 'EXECUTIVE' =>
array( 522.000, 756.000),
2230 'ORGANIZERL' =>
array( 396.000, 612.000),
2231 'STATEMENT' =>
array( 396.000, 612.000),
2232 'MEMO' =>
array( 396.000, 612.000),
2233 'FOOLSCAP' =>
array( 595.440, 936.000),
2234 'COMPACT' =>
array( 306.000, 486.000),
2235 'ORGANIZERJ' =>
array( 198.000, 360.000),
2237 'P1' =>
array( 1587.402, 2437.795),
2238 'P2' =>
array( 1218.898, 1587.402),
2239 'P3' =>
array( 793.701, 1218.898),
2240 'P4' =>
array( 609.449, 793.701),
2241 'P5' =>
array( 396.850, 609.449),
2242 'P6' =>
array( 303.307, 396.850),
2244 'ARCH_E' =>
array( 2592.000, 3456.000),
2245 'ARCH_E1' =>
array( 2160.000, 3024.000),
2246 'ARCH_D' =>
array( 1728.000, 2592.000),
2247 'BROADSHEET' =>
array( 1296.000, 1728.000),
2248 'ARCH_C' =>
array( 1296.000, 1728.000),
2249 'ARCH_B' =>
array( 864.000, 1296.000),
2250 'ARCH_A' =>
array( 648.000, 864.000),
2253 'ANNENV_A2' =>
array( 314.640, 414.000),
2254 'ANNENV_A6' =>
array( 342.000, 468.000),
2255 'ANNENV_A7' =>
array( 378.000, 522.000),
2256 'ANNENV_A8' =>
array( 396.000, 584.640),
2257 'ANNENV_A10' =>
array( 450.000, 692.640),
2258 'ANNENV_SLIM' =>
array( 278.640, 638.640),
2260 'COMMENV_N6_1/4' =>
array( 252.000, 432.000),
2261 'COMMENV_N6_3/4' =>
array( 260.640, 468.000),
2262 'COMMENV_N8' =>
array( 278.640, 540.000),
2263 'COMMENV_N9' =>
array( 278.640, 638.640),
2264 'COMMENV_N10' =>
array( 296.640, 684.000),
2265 'COMMENV_N11' =>
array( 324.000, 746.640),
2266 'COMMENV_N12' =>
array( 342.000, 792.000),
2267 'COMMENV_N14' =>
array( 360.000, 828.000),
2269 'CATENV_N1' =>
array( 432.000, 648.000),
2270 'CATENV_N1_3/4' =>
array( 468.000, 684.000),
2271 'CATENV_N2' =>
array( 468.000, 720.000),
2272 'CATENV_N3' =>
array( 504.000, 720.000),
2273 'CATENV_N6' =>
array( 540.000, 756.000),
2274 'CATENV_N7' =>
array( 576.000, 792.000),
2275 'CATENV_N8' =>
array( 594.000, 810.000),
2276 'CATENV_N9_1/2' =>
array( 612.000, 756.000),
2277 'CATENV_N9_3/4' =>
array( 630.000, 810.000),
2278 'CATENV_N10_1/2' =>
array( 648.000, 864.000),
2279 'CATENV_N12_1/2' =>
array( 684.000, 900.000),
2280 'CATENV_N13_1/2' =>
array( 720.000, 936.000),
2281 'CATENV_N14_1/4' =>
array( 810.000, 882.000),
2282 'CATENV_N14_1/2' =>
array( 828.000, 1044.000),
2284 'JIS_B0' =>
array( 2919.685, 4127.244),
2285 'JIS_B1' =>
array( 2063.622, 2919.685),
2286 'JIS_B2' =>
array( 1459.843, 2063.622),
2287 'JIS_B3' =>
array( 1031.811, 1459.843),
2288 'JIS_B4' =>
array( 728.504, 1031.811),
2289 'JIS_B5' =>
array( 515.906, 728.504),
2290 'JIS_B6' =>
array( 362.835, 515.906),
2291 'JIS_B7' =>
array( 257.953, 362.835),
2292 'JIS_B8' =>
array( 181.417, 257.953),
2293 'JIS_B9' =>
array( 127.559, 181.417),
2294 'JIS_B10' =>
array( 90.709, 127.559),
2295 'JIS_B11' =>
array( 62.362, 90.709),
2296 'JIS_B12' =>
array( 45.354, 62.362),
2298 'PA0' =>
array( 2381.102, 3174.803),
2299 'PA1' =>
array( 1587.402, 2381.102),
2300 'PA2' =>
array( 1190.551, 1587.402),
2301 'PA3' =>
array( 793.701, 1190.551),
2302 'PA4' =>
array( 595.276, 793.701),
2303 'PA5' =>
array( 396.850, 595.276),
2304 'PA6' =>
array( 297.638, 396.850),
2305 'PA7' =>
array( 198.425, 297.638),
2306 'PA8' =>
array( 147.402, 198.425),
2307 'PA9' =>
array( 99.213, 147.402),
2308 'PA10' =>
array( 73.701, 99.213),
2310 'PASSPORT_PHOTO' =>
array( 99.213, 127.559),
2311 'E' =>
array( 233.858, 340.157),
2312 'L' =>
array( 252.283, 360.000),
2313 '3R' =>
array( 252.283, 360.000),
2314 'KG' =>
array( 289.134, 430.866),
2315 '4R' =>
array( 289.134, 430.866),
2316 '4D' =>
array( 340.157, 430.866),
2317 '2L' =>
array( 360.000, 504.567),
2318 '5R' =>
array( 360.000, 504.567),
2319 '8P' =>
array( 430.866, 575.433),
2320 '6R' =>
array( 430.866, 575.433),
2321 '6P' =>
array( 575.433, 720.000),
2322 '8R' =>
array( 575.433, 720.000),
2323 '6PW' =>
array( 575.433, 864.567),
2324 'S8R' =>
array( 575.433, 864.567),
2325 '4P' =>
array( 720.000, 864.567),
2326 '10R' =>
array( 720.000, 864.567),
2327 '4PW' =>
array( 720.000, 1080.000),
2328 'S10R' =>
array( 720.000, 1080.000),
2329 '11R' =>
array( 790.866, 1009.134),
2330 'S11R' =>
array( 790.866, 1224.567),
2331 '12R' =>
array( 864.567, 1080.000),
2332 'S12R' =>
array( 864.567, 1292.598),
2334 'NEWSPAPER_BROADSHEET' =>
array( 2125.984, 1700.787),
2335 'NEWSPAPER_BERLINER' =>
array( 1332.283, 892.913),
2336 'NEWSPAPER_TABLOID' =>
array( 1218.898, 793.701),
2337 'NEWSPAPER_COMPACT' =>
array( 1218.898, 793.701),
2339 'CREDIT_CARD' =>
array( 153.014, 242.646),
2340 'BUSINESS_CARD' =>
array( 153.014, 242.646),
2341 'BUSINESS_CARD_ISO7810' =>
array( 153.014, 242.646),
2342 'BUSINESS_CARD_ISO216' =>
array( 147.402, 209.764),
2343 'BUSINESS_CARD_IT' =>
array( 155.906, 240.945),
2344 'BUSINESS_CARD_UK' =>
array( 155.906, 240.945),
2345 'BUSINESS_CARD_FR' =>
array( 155.906, 240.945),
2346 'BUSINESS_CARD_DE' =>
array( 155.906, 240.945),
2347 'BUSINESS_CARD_ES' =>
array( 155.906, 240.945),
2348 'BUSINESS_CARD_CA' =>
array( 144.567, 252.283),
2349 'BUSINESS_CARD_US' =>
array( 144.567, 252.283),
2350 'BUSINESS_CARD_JP' =>
array( 155.906, 257.953),
2351 'BUSINESS_CARD_HK' =>
array( 153.071, 255.118),
2352 'BUSINESS_CARD_AU' =>
array( 155.906, 255.118),
2353 'BUSINESS_CARD_DK' =>
array( 155.906, 255.118),
2354 'BUSINESS_CARD_SE' =>
array( 155.906, 255.118),
2355 'BUSINESS_CARD_RU' =>
array( 141.732, 255.118),
2356 'BUSINESS_CARD_CZ' =>
array( 141.732, 255.118),
2357 'BUSINESS_CARD_FI' =>
array( 141.732, 255.118),
2358 'BUSINESS_CARD_HU' =>
array( 141.732, 255.118),
2359 'BUSINESS_CARD_IL' =>
array( 141.732, 255.118),
2361 '4SHEET' =>
array( 2880.000, 4320.000),
2362 '6SHEET' =>
array( 3401.575, 5102.362),
2363 '12SHEET' =>
array( 8640.000, 4320.000),
2364 '16SHEET' =>
array( 5760.000, 8640.000),
2365 '32SHEET' =>
array(11520.000, 8640.000),
2366 '48SHEET' =>
array(17280.000, 8640.000),
2367 '64SHEET' =>
array(23040.000, 8640.000),
2368 '96SHEET' =>
array(34560.000, 8640.000),
2371 'EN_EMPEROR' =>
array( 3456.000, 5184.000),
2372 'EN_ANTIQUARIAN' =>
array( 2232.000, 3816.000),
2373 'EN_GRAND_EAGLE' =>
array( 2070.000, 3024.000),
2374 'EN_DOUBLE_ELEPHANT' =>
array( 1926.000, 2880.000),
2375 'EN_ATLAS' =>
array( 1872.000, 2448.000),
2376 'EN_COLOMBIER' =>
array( 1692.000, 2484.000),
2377 'EN_ELEPHANT' =>
array( 1656.000, 2016.000),
2378 'EN_DOUBLE_DEMY' =>
array( 1620.000, 2556.000),
2379 'EN_IMPERIAL' =>
array( 1584.000, 2160.000),
2380 'EN_PRINCESS' =>
array( 1548.000, 2016.000),
2381 'EN_CARTRIDGE' =>
array( 1512.000, 1872.000),
2382 'EN_DOUBLE_LARGE_POST' =>
array( 1512.000, 2376.000),
2383 'EN_ROYAL' =>
array( 1440.000, 1800.000),
2384 'EN_SHEET' =>
array( 1404.000, 1692.000),
2385 'EN_HALF_POST' =>
array( 1404.000, 1692.000),
2386 'EN_SUPER_ROYAL' =>
array( 1368.000, 1944.000),
2387 'EN_DOUBLE_POST' =>
array( 1368.000, 2196.000),
2388 'EN_MEDIUM' =>
array( 1260.000, 1656.000),
2389 'EN_DEMY' =>
array( 1260.000, 1620.000),
2390 'EN_LARGE_POST' =>
array( 1188.000, 1512.000),
2391 'EN_COPY_DRAUGHT' =>
array( 1152.000, 1440.000),
2392 'EN_POST' =>
array( 1116.000, 1386.000),
2393 'EN_CROWN' =>
array( 1080.000, 1440.000),
2394 'EN_PINCHED_POST' =>
array( 1062.000, 1332.000),
2395 'EN_BRIEF' =>
array( 972.000, 1152.000),
2396 'EN_FOOLSCAP' =>
array( 972.000, 1224.000),
2397 'EN_SMALL_FOOLSCAP' =>
array( 954.000, 1188.000),
2398 'EN_POTT' =>
array( 900.000, 1080.000),
2400 'BE_GRAND_AIGLE' =>
array( 1984.252, 2948.031),
2401 'BE_COLOMBIER' =>
array( 1757.480, 2409.449),
2402 'BE_DOUBLE_CARRE' =>
array( 1757.480, 2607.874),
2403 'BE_ELEPHANT' =>
array( 1746.142, 2182.677),
2404 'BE_PETIT_AIGLE' =>
array( 1700.787, 2381.102),
2405 'BE_GRAND_JESUS' =>
array( 1559.055, 2069.291),
2406 'BE_JESUS' =>
array( 1530.709, 2069.291),
2407 'BE_RAISIN' =>
array( 1417.323, 1842.520),
2408 'BE_GRAND_MEDIAN' =>
array( 1303.937, 1714.961),
2409 'BE_DOUBLE_POSTE' =>
array( 1233.071, 1601.575),
2410 'BE_COQUILLE' =>
array( 1218.898, 1587.402),
2411 'BE_PETIT_MEDIAN' =>
array( 1176.378, 1502.362),
2412 'BE_RUCHE' =>
array( 1020.472, 1303.937),
2413 'BE_PROPATRIA' =>
array( 977.953, 1218.898),
2414 'BE_LYS' =>
array( 898.583, 1125.354),
2415 'BE_POT' =>
array( 870.236, 1088.504),
2416 'BE_ROSETTE' =>
array( 765.354, 983.622),
2418 'FR_UNIVERS' =>
array( 2834.646, 3685.039),
2419 'FR_DOUBLE_COLOMBIER' =>
array( 2551.181, 3571.654),
2420 'FR_GRANDE_MONDE' =>
array( 2551.181, 3571.654),
2421 'FR_DOUBLE_SOLEIL' =>
array( 2267.717, 3401.575),
2422 'FR_DOUBLE_JESUS' =>
array( 2154.331, 3174.803),
2423 'FR_GRAND_AIGLE' =>
array( 2125.984, 3004.724),
2424 'FR_PETIT_AIGLE' =>
array( 1984.252, 2664.567),
2425 'FR_DOUBLE_RAISIN' =>
array( 1842.520, 2834.646),
2426 'FR_JOURNAL' =>
array( 1842.520, 2664.567),
2427 'FR_COLOMBIER_AFFICHE' =>
array( 1785.827, 2551.181),
2428 'FR_DOUBLE_CAVALIER' =>
array( 1757.480, 2607.874),
2429 'FR_CLOCHE' =>
array( 1700.787, 2267.717),
2430 'FR_SOLEIL' =>
array( 1700.787, 2267.717),
2431 'FR_DOUBLE_CARRE' =>
array( 1587.402, 2551.181),
2432 'FR_DOUBLE_COQUILLE' =>
array( 1587.402, 2494.488),
2433 'FR_JESUS' =>
array( 1587.402, 2154.331),
2434 'FR_RAISIN' =>
array( 1417.323, 1842.520),
2435 'FR_CAVALIER' =>
array( 1303.937, 1757.480),
2436 'FR_DOUBLE_COURONNE' =>
array( 1303.937, 2040.945),
2437 'FR_CARRE' =>
array( 1275.591, 1587.402),
2438 'FR_COQUILLE' =>
array( 1247.244, 1587.402),
2439 'FR_DOUBLE_TELLIERE' =>
array( 1247.244, 1927.559),
2440 'FR_DOUBLE_CLOCHE' =>
array( 1133.858, 1700.787),
2441 'FR_DOUBLE_POT' =>
array( 1133.858, 1757.480),
2442 'FR_ECU' =>
array( 1133.858, 1474.016),
2443 'FR_COURONNE' =>
array( 1020.472, 1303.937),
2444 'FR_TELLIERE' =>
array( 963.780, 1247.244),
2445 'FR_POT' =>
array( 878.740, 1133.858),
2457 if (isset(self::$page_formats[$format])) {
2458 return self::$page_formats[$format];
2460 return self::$page_formats[
'A4'];
2478 public static function setPageBoxes($page, $type, $llx, $lly, $urx, $ury, $points=
false, $k, $pagedim=
array()) {
2479 if (!isset($pagedim[$page])) {
2481 $pagedim[$page] =
array();
2483 if (!in_array($type, self::$pageboxes)) {
2489 $pagedim[$page][$type][
'llx'] = ($llx * $k);
2490 $pagedim[$page][$type][
'lly'] = ($lly * $k);
2491 $pagedim[$page][$type][
'urx'] = ($urx * $k);
2492 $pagedim[$page][$type][
'ury'] = ($ury * $k);
2505 foreach (self::$pageboxes as $type) {
2507 if (isset($pagedim[$page][$type])) {
2508 $tmp = $pagedim[$page][$type][
'llx'];
2509 $pagedim[$page][$type][
'llx'] = $pagedim[$page][$type][
'lly'];
2510 $pagedim[$page][$type][
'lly'] = $tmp;
2511 $tmp = $pagedim[$page][$type][
'urx'];
2512 $pagedim[$page][$type][
'urx'] = $pagedim[$page][$type][
'ury'];
2513 $pagedim[$page][$type][
'ury'] = $tmp;
2529 case 'SinglePage': {
2530 $layout_mode =
'SinglePage';
2535 $layout_mode =
'OneColumn';
2539 case 'TwoColumnLeft': {
2540 $layout_mode =
'TwoColumnLeft';
2543 case 'TwoColumnRight': {
2544 $layout_mode =
'TwoColumnRight';
2547 case 'TwoPageLeft': {
2548 $layout_mode =
'TwoPageLeft';
2551 case 'TwoPageRight': {
2552 $layout_mode =
'TwoPageRight';
2556 $layout_mode =
'SinglePage';
2559 return $layout_mode;
2571 $page_mode =
'UseNone';
2574 case 'UseOutlines': {
2575 $page_mode =
'UseOutlines';
2579 $page_mode =
'UseThumbs';
2582 case 'FullScreen': {
2583 $page_mode =
'FullScreen';
2587 $page_mode =
'UseOC';
2591 $page_mode =
'UseAttachments';
2595 $page_mode =
'UseNone';
static convertHTMLColorToDec($hcolor, &$spotc, $defcol=array('R'=>128, 'G'=>128, 'B'=>128))
Returns an array (RGB or CMYK) from an html color name, or a six-digit (i.e.
static getPathPaintOperator($style, $default='S')
Get the Path-Painting Operators.
static isValidCSSSelectorForTag($dom, $key, $selector)
Returns true if the CSS selector is valid for the selected HTML tag.
static $pageboxes
Array page boxes names static.
static getFormattedDate($time)
Returns a formatted date-time.
static getTagStyleFromCSSarray($css)
Compact CSS data array into single string.
if((!isset($_SERVER['DOCUMENT_ROOT'])) OR(empty($_SERVER['DOCUMENT_ROOT']))) $_SERVER['DOCUMENT_ROOT']
static _getFIXED($str, $offset)
Get FIXED from string (32-bit signed fixed-point number (16.16).
static _escapeXML($str)
Escape some special characters (< > &) for XML output.
static swapPageBoxCoordinates($page, $pagedim)
Swap X and Y coordinates of page boxes (change page boxes orientation).
static intToRoman($number)
Returns the Roman representation of an integer number.
static _AES($key, $text)
Returns the input text exrypted using AES algorithm and the specified key.
$attrib
Regular expression to match HTML/XML attribute pairs within a tag.
static getUserPermissionCode($permissions, $mode=0)
Return the permission code used on encryption (P value).
static _getUFWORD($str, $offset)
Get UFWORD from string (Big Endian 16-bit unsigned integer).
static convertHexStringToString($bs)
Convert hexadecimal string to string.
static $page_formats
Array of page formats measures are calculated in this way: (inches * 72) or (millimeters * 72 / 25...
static removeSHY($txt='', $unicode=true)
Removes SHY characters from text.
static getEncPermissionsString($protection)
Convert encryption P value to a string of bytes, low-order byte first.
static getHyphenPatternsFromTEX($file)
Returns an array of hyphenation patterns.
static getRandomSeed($seed='')
Returns a string containing random data to be used as a seed for encryption methods.
static getBorderMode($brd, $position='start', $opencell=true)
Get the border mode accounting for multicell position (opens bottom side of multicell crossing pages)...
static getCSSdataArray($dom, $key, $css)
Returns the styles array that apply for the selected HTML tag.
static rfread($handle, $length)
Binary-safe and URL-safe file read.
static getTimestamp($date)
Returns timestamp in seconds from formatted date-time.
static sendOutputData($data, $length)
Output input data and compress it if possible.
static pregSplit($pattern, $modifiers, $subject, $limit=NULL, $flags=NULL)
Split string by a regular expression.
static formatTOCPageNumber($num)
Format the page numbers on the Table Of Content.
Static methods used by the TCPDF class.
const K_PATH_CACHE
Cache directory for temporary files (full path).
static isValidURL($url)
Check if the URL exist.
for($col=0; $col< 50; $col++) $d
static empty_string($str)
Determine whether a string is empty.
static _getSHORT($str, $offset)
Get SHORT from string (Big Endian 16-bit signed integer).
static set_mqr($mqr)
Sets the current active configuration setting of magic_quotes_runtime (if the set_magic_quotes_runtim...
static $alias_tot_pages
String alias for total number of pages.
static getTCPDFProducer()
Return the current TCPDF producer.
static formatPageNumber($num)
Format the page numbers.
static replacePageNumAliases($page, $replace, $diff=0)
Replace page number aliases with number.
static extractCSSproperties($cssdata)
Extracts the CSS properties from a CSS string.
static _AESnopad($key, $text)
Returns the input text exrypted using AES algorithm and the specified key.
static $tcpdf_version
Current TCPDF version.
static $alias_group_num_page
String alias for group page number.
static _getFWORD($str, $offset)
Get FWORD from string (Big Endian 16-bit signed integer).
static $byterange_string
ByteRange placemark used during digital signature process.
if(!is_array($argv)) $options
static getPageSizeFromFormat($format)
Get page dimensions from format name.
static $alias_num_page
String alias for page number.
static getPageMode($mode='UseNone')
Get the canonical page layout mode.
static $alias_group_tot_pages
String alias for total number of pages in a single group.
date( 'd-M-Y', $objPHPExcel->getProperties() ->getCreated())
static setPageBoxes($page, $type, $llx, $lly, $urx, $ury, $points=false, $k, $pagedim=array())
Set page boundaries.
static getPageLayoutMode($layout='SinglePage')
Get the canonical page layout mode.
static getTransformationMatrixProduct($ta, $tb)
Get the product of two SVG tranformation matrices.
static _escape($s)
Add "\" before "\", "(" and ")".
Add a drawing to the header
static _freadint($f)
Read a 4-byte (32 bit) integer from file.
static $enc_padding
Encryption padding string.
Create styles array
The data for the language used.
static getTCPDFVersion()
Return the current TCPDF version.
static _getULONG($str, $offset)
Get ULONG from string (Big Endian 32-bit unsigned integer).
static fixHTMLCode($html, $default_css='', $tagvs='', $tidy_options='', &$tagvspaces)
Cleanup HTML code (requires HTML Tidy library).
static _md5_16($str)
Encrypts a string using MD5 and returns it's value as a binary string.
static _getUSHORT($str, $offset)
Get USHORT from string (Big Endian 16-bit unsigned integer).
static $alias_right_shift
String alias for right shift compensation used to correctly align page numbers on the right...
static revstrpos($haystack, $needle, $offset=0)
Find position of last occurrence of a substring in a string.
static objclone($object)
Creates a copy of a class object.
if(!file_exists("$old.txt")) if($old===$new) if(file_exists("$new.txt")) $file
static getObjFilename($type='tmp', $file_id='')
Returns a temporary filename for caching object on filesystem.
static convertStringToHexString($s)
Convert string to hexadecimal string (byte string)
static _RC4($key, $text, &$last_enc_key, &$last_enc_key_c)
Returns the input text encrypted using RC4 algorithm and the specified key.
defined( 'APPLICATION_ENV')||define( 'APPLICATION_ENV'
static encodeNameObject($name)
Encode a name object.
static _getBYTE($str, $offset)
Get BYTE from string (8-bit unsigned integer).
static fopenLocal($filename, $mode)
Wrapper to use fopen only with local files.
static getSVGTransformMatrix($attribute)
Get the tranformation matrix from SVG transform attribute.
static getVectorsAngle($x1, $y1, $x2, $y2)
Returns the angle in radiants between two vectors.
static fileGetContents($file)
Reads entire file into a string.
static get_mqr()
Gets the current active configuration setting of magic_quotes_runtime (if the get_magic_quotes_runtim...
static getAnnotOptFromJSProp($prop, &$spot_colors, $rtl=false)
Convert JavaScript form fields properties array to Annotation Properties array.