Advertisement
Guest User

Untitled

a guest
Nov 4th, 2019
130
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 91.99 KB | None | 0 0
  1. <?php
  2. define("mPDF_VERSION", "5.6");
  3. define("_MPDFK", 72 / 25.4);
  4. define("AUTOFONT_CJK", 1);
  5. define("AUTOFONT_THAIVIET", 2);
  6. define("AUTOFONT_RTL", 4);
  7. define("AUTOFONT_INDIC", 8);
  8. define("AUTOFONT_ALL", 15);
  9. define("_BORDER_ALL", 15);
  10. define("_BORDER_TOP", 8);
  11. define("_BORDER_RIGHT", 4);
  12. define("_BORDER_BOTTOM", 2);
  13. define("_BORDER_LEFT", 1);
  14. if (!defined("_MPDF_PATH")) {
  15. define("_MPDF_PATH", dirname(preg_replace("/\\\\/", "/", __FILE__)) . "/");
  16. }
  17.  
  18. if (!defined("_MPDF_URI")) {
  19. define("_MPDF_URI", _MPDF_PATH);
  20. }
  21.  
  22. require_once(_MPDF_PATH . "includes/functions.php");
  23. require_once(_MPDF_PATH . "config_cp.php");
  24. if (!defined("_JPGRAPH_PATH")) {
  25. define("_JPGRAPH_PATH", _MPDF_PATH . "jpgraph/");
  26. }
  27.  
  28. if (!defined("_MPDF_TEMP_PATH")) {
  29. define("_MPDF_TEMP_PATH", _MPDF_PATH . "tmp/");
  30. }
  31.  
  32. if (!defined("_MPDF_TTFONTPATH")) {
  33. define("_MPDF_TTFONTPATH", _MPDF_PATH . "ttfonts/");
  34. }
  35.  
  36. if (!defined("_MPDF_TTFONTDATAPATH")) {
  37. define("_MPDF_TTFONTDATAPATH", _MPDF_PATH . "ttfontdata/");
  38. }
  39.  
  40. $errorlevel = error_reporting();
  41. $errorlevel = error_reporting($errorlevel & ~8);
  42. if (function_exists("date_default_timezone_set") && ini_get("date.timezone") == "") {
  43. date_default_timezone_set("Europe/London");
  44. }
  45.  
  46. if (!function_exists("mb_strlen")) {
  47. exit("Error - mPDF requires mb_string functions. Ensure that PHP is compiled with php_mbstring.dll enabled.");
  48. }
  49.  
  50. if (!defined("PHP_VERSION_ID")) {
  51. $version = explode(".", PHP_VERSION);
  52. define("PHP_VERSION_ID", $version[0] * 10000 + $version[1] * 100 + $version[2]);
  53. }
  54.  
  55. $test = pack("d", 134455.474557333);
  56. define("_DSIZE", strlen($test));
  57.  
  58. class mPDF
  59. {
  60. public $margBuffer = NULL;
  61. public $splitTableBorderWidth = NULL;
  62. public $cacheTables = NULL;
  63. public $bookmarkStyles = NULL;
  64. public $useActiveForms = NULL;
  65. public $repackageTTF = NULL;
  66. public $allowCJKorphans = NULL;
  67. public $allowCJKoverflow = NULL;
  68. public $useKerning = NULL;
  69. public $restrictColorSpace = NULL;
  70. public $bleedMargin = NULL;
  71. public $crossMarkMargin = NULL;
  72. public $cropMarkMargin = NULL;
  73. public $cropMarkLength = NULL;
  74. public $nonPrintMargin = NULL;
  75. public $PDFX = NULL;
  76. public $PDFXauto = NULL;
  77. public $PDFA = NULL;
  78. public $PDFAauto = NULL;
  79. public $ICCProfile = NULL;
  80. public $printers_info = NULL;
  81. public $iterationCounter = NULL;
  82. public $smCapsScale = NULL;
  83. public $smCapsStretch = NULL;
  84. public $backupSubsFont = NULL;
  85. public $backupSIPFont = NULL;
  86. public $debugfonts = NULL;
  87. public $useAdobeCJK = NULL;
  88. public $percentSubset = NULL;
  89. public $maxTTFFilesize = NULL;
  90. public $BMPonly = NULL;
  91. public $tableMinSizePriority = NULL;
  92. public $dpi = NULL;
  93. public $watermarkImgAlphaBlend = NULL;
  94. public $watermarkImgBehind = NULL;
  95. public $justifyB4br = NULL;
  96. public $packTableData = NULL;
  97. public $pgsIns = NULL;
  98. public $simpleTables = NULL;
  99. public $enableImports = NULL;
  100. public $debug = NULL;
  101. public $showStats = NULL;
  102. public $setAutoTopMargin = NULL;
  103. public $setAutoBottomMargin = NULL;
  104. public $autoMarginPadding = NULL;
  105. public $collapseBlockMargins = NULL;
  106. public $falseBoldWeight = NULL;
  107. public $normalLineheight = NULL;
  108. public $progressBar = NULL;
  109. public $incrementFPR1 = NULL;
  110. public $incrementFPR2 = NULL;
  111. public $incrementFPR3 = NULL;
  112. public $incrementFPR4 = NULL;
  113. public $hyphenate = NULL;
  114. public $hyphenateTables = NULL;
  115. public $SHYlang = NULL;
  116. public $SHYleftmin = NULL;
  117. public $SHYrightmin = NULL;
  118. public $SHYcharmin = NULL;
  119. public $SHYcharmax = NULL;
  120. public $SHYlanguages = NULL;
  121. public $pagenumPrefix = NULL;
  122. public $pagenumSuffix = NULL;
  123. public $nbpgPrefix = NULL;
  124. public $nbpgSuffix = NULL;
  125. public $showImageErrors = NULL;
  126. public $allow_output_buffering = NULL;
  127. public $autoPadding = NULL;
  128. public $useGraphs = NULL;
  129. public $autoFontGroupSize = NULL;
  130. public $tabSpaces = NULL;
  131. public $useLang = NULL;
  132. public $restoreBlockPagebreaks = NULL;
  133. public $watermarkTextAlpha = NULL;
  134. public $watermarkImageAlpha = NULL;
  135. public $watermark_size = NULL;
  136. public $watermark_pos = NULL;
  137. public $annotSize = NULL;
  138. public $annotMargin = NULL;
  139. public $annotOpacity = NULL;
  140. public $title2annots = NULL;
  141. public $keepColumns = NULL;
  142. public $keep_table_proportions = NULL;
  143. public $ignore_table_widths = NULL;
  144. public $ignore_table_percents = NULL;
  145. public $list_align_style = NULL;
  146. public $list_number_suffix = NULL;
  147. public $useSubstitutions = NULL;
  148. public $CSSselectMedia = NULL;
  149. public $forcePortraitHeaders = NULL;
  150. public $forcePortraitMargins = NULL;
  151. public $displayDefaultOrientation = NULL;
  152. public $ignore_invalid_utf8 = NULL;
  153. public $allowedCSStags = NULL;
  154. public $onlyCoreFonts = NULL;
  155. public $allow_charset_conversion = NULL;
  156. public $jSWord = NULL;
  157. public $jSmaxChar = NULL;
  158. public $jSmaxCharLast = NULL;
  159. public $jSmaxWordLast = NULL;
  160. public $orphansAllowed = NULL;
  161. public $max_colH_correction = NULL;
  162. public $table_error_report = NULL;
  163. public $table_error_report_param = NULL;
  164. public $biDirectional = NULL;
  165. public $text_input_as_HTML = NULL;
  166. public $anchor2Bookmark = NULL;
  167. public $list_indent_first_level = NULL;
  168. public $shrink_tables_to_fit = NULL;
  169. public $allow_html_optional_endtags = NULL;
  170. public $img_dpi = NULL;
  171. public $defaultheaderfontsize = NULL;
  172. public $defaultheaderfontstyle = NULL;
  173. public $defaultheaderline = NULL;
  174. public $defaultfooterfontsize = NULL;
  175. public $defaultfooterfontstyle = NULL;
  176. public $defaultfooterline = NULL;
  177. public $header_line_spacing = NULL;
  178. public $footer_line_spacing = NULL;
  179. public $pregUHCchars = NULL;
  180. public $pregSJISchars = NULL;
  181. public $pregCJKchars = NULL;
  182. public $pregASCIIchars1 = NULL;
  183. public $pregASCIIchars2 = NULL;
  184. public $pregASCIIchars3 = NULL;
  185. public $pregVIETchars = NULL;
  186. public $pregVIETPluschars = NULL;
  187. public $pregRTLchars = NULL;
  188. public $pregHEBchars = NULL;
  189. public $pregARABICchars = NULL;
  190. public $pregNonARABICchars = NULL;
  191. public $pregHIchars = NULL;
  192. public $pregBNchars = NULL;
  193. public $pregPAchars = NULL;
  194. public $pregGUchars = NULL;
  195. public $pregORchars = NULL;
  196. public $pregTAchars = NULL;
  197. public $pregTEchars = NULL;
  198. public $pregKNchars = NULL;
  199. public $pregMLchars = NULL;
  200. public $pregSHchars = NULL;
  201. public $pregINDextra = NULL;
  202. public $mirrorMargins = NULL;
  203. public $default_lineheight_correction = NULL;
  204. public $watermarkText = NULL;
  205. public $watermarkImage = NULL;
  206. public $showWatermarkText = NULL;
  207. public $showWatermarkImage = NULL;
  208. public $fontsizes = NULL;
  209. public $UnvalidatedText = NULL;
  210. public $TopicIsUnvalidated = NULL;
  211. public $useOddEven = NULL;
  212. public $useSubstitutionsMB = NULL;
  213. public $grad = NULL;
  214. public $bmp = NULL;
  215. public $wmf = NULL;
  216. public $tocontents = NULL;
  217. public $form = NULL;
  218. public $directw = NULL;
  219. public $inMeter = NULL;
  220. public $CJKleading = NULL;
  221. public $CJKfollowing = NULL;
  222. public $CJKoverflow = NULL;
  223. public $textshadow = NULL;
  224. public $colsums = NULL;
  225. public $spanborder = NULL;
  226. public $spanborddet = NULL;
  227. public $visibility = NULL;
  228. public $useRC128encryption = NULL;
  229. public $uniqid = NULL;
  230. public $kerning = NULL;
  231. public $fixedlSpacing = NULL;
  232. public $minwSpacing = NULL;
  233. public $lSpacingCSS = NULL;
  234. public $wSpacingCSS = NULL;
  235. public $listDir = NULL;
  236. public $spotColorIDs = NULL;
  237. public $SVGcolors = NULL;
  238. public $spotColors = NULL;
  239. public $defTextColor = NULL;
  240. public $defDrawColor = NULL;
  241. public $defFillColor = NULL;
  242. public $tableBackgrounds = NULL;
  243. public $inlineDisplayOff = NULL;
  244. public $kt_y00 = NULL;
  245. public $kt_p00 = NULL;
  246. public $upperCase = NULL;
  247. public $checkSIP = NULL;
  248. public $checkSMP = NULL;
  249. public $checkCJK = NULL;
  250. public $tableCJK = NULL;
  251. public $watermarkImgAlpha = NULL;
  252. public $PDFAXwarnings = NULL;
  253. public $MetadataRoot = NULL;
  254. public $OutputIntentRoot = NULL;
  255. public $InfoRoot = NULL;
  256. public $current_filename = NULL;
  257. public $parsers = NULL;
  258. public $current_parser = NULL;
  259. public $_obj_stack = NULL;
  260. public $_don_obj_stack = NULL;
  261. public $_current_obj_id = NULL;
  262. public $tpls = NULL;
  263. public $tpl = NULL;
  264. public $tplprefix = NULL;
  265. public $_res = NULL;
  266. public $pdf_version = NULL;
  267. public $noImageFile = NULL;
  268. public $lastblockbottommargin = NULL;
  269. public $baselineC = NULL;
  270. public $subPos = NULL;
  271. public $subArrMB = NULL;
  272. public $ReqFontStyle = NULL;
  273. public $tableClipPath = NULL;
  274. public $forceExactLineheight = NULL;
  275. public $listOcc = NULL;
  276. public $fullImageHeight = NULL;
  277. public $inFixedPosBlock = NULL;
  278. public $fixedPosBlock = NULL;
  279. public $fixedPosBlockDepth = NULL;
  280. public $fixedPosBlockBBox = NULL;
  281. public $fixedPosBlockSave = NULL;
  282. public $maxPosL = NULL;
  283. public $maxPosR = NULL;
  284. public $loaded = NULL;
  285. public $extraFontSubsets = NULL;
  286. public $docTemplateStart = NULL;
  287. public $time0 = NULL;
  288. public $indic = NULL;
  289. public $barcode = NULL;
  290. public $SHYpatterns = NULL;
  291. public $loadedSHYpatterns = NULL;
  292. public $loadedSHYdictionary = NULL;
  293. public $SHYdictionary = NULL;
  294. public $SHYdictionaryWords = NULL;
  295. public $spanbgcolorarray = NULL;
  296. public $default_font = NULL;
  297. public $list_lineheight = NULL;
  298. public $headerbuffer = NULL;
  299. public $lastblocklevelchange = NULL;
  300. public $nestedtablejustfinished = NULL;
  301. public $linebreakjustfinished = NULL;
  302. public $cell_border_dominance_L = NULL;
  303. public $cell_border_dominance_R = NULL;
  304. public $cell_border_dominance_T = NULL;
  305. public $cell_border_dominance_B = NULL;
  306. public $tbCSSlvl = NULL;
  307. public $listCSSlvl = NULL;
  308. public $table_keep_together = NULL;
  309. public $plainCell_properties = NULL;
  310. public $inherit_lineheight = NULL;
  311. public $listitemtype = NULL;
  312. public $shrin_k1 = NULL;
  313. public $outerfilled = NULL;
  314. public $blockContext = NULL;
  315. public $floatDivs = NULL;
  316. public $tablecascadeCSS = NULL;
  317. public $listcascadeCSS = NULL;
  318. public $patterns = NULL;
  319. public $pageBackgrounds = NULL;
  320. public $bodyBackgroundGradient = NULL;
  321. public $bodyBackgroundImage = NULL;
  322. public $bodyBackgroundColor = NULL;
  323. public $writingHTMLheader = NULL;
  324. public $writingHTMLfooter = NULL;
  325. public $autoFontGroups = NULL;
  326. public $angle = NULL;
  327. public $gradients = NULL;
  328. public $kwt_Reference = NULL;
  329. public $kwt_BMoutlines = NULL;
  330. public $kwt_toc = NULL;
  331. public $tbrot_Reference = NULL;
  332. public $tbrot_BMoutlines = NULL;
  333. public $tbrot_toc = NULL;
  334. public $col_Reference = NULL;
  335. public $col_BMoutlines = NULL;
  336. public $col_toc = NULL;
  337. public $currentGraphId = NULL;
  338. public $graphs = NULL;
  339. public $floatbuffer = NULL;
  340. public $floatmargins = NULL;
  341. public $bullet = NULL;
  342. public $bulletarray = NULL;
  343. public $rtlAsArabicFarsi = NULL;
  344. public $currentLang = NULL;
  345. public $default_lang = NULL;
  346. public $default_available_fonts = NULL;
  347. public $pageTemplate = NULL;
  348. public $docTemplate = NULL;
  349. public $docTemplateContinue = NULL;
  350. public $arabGlyphs = NULL;
  351. public $arabHex = NULL;
  352. public $persianGlyphs = NULL;
  353. public $persianHex = NULL;
  354. public $arabVowels = NULL;
  355. public $arabPrevLink = NULL;
  356. public $arabNextLink = NULL;
  357. public $formobjects = NULL;
  358. public $InlineProperties = NULL;
  359. public $InlineAnnots = NULL;
  360. public $ktAnnots = NULL;
  361. public $tbrot_Annots = NULL;
  362. public $kwt_Annots = NULL;
  363. public $columnAnnots = NULL;
  364. public $columnForms = NULL;
  365. public $PageAnnots = NULL;
  366. public $pageDim = NULL;
  367. public $breakpoints = NULL;
  368. public $tableLevel = NULL;
  369. public $tbctr = NULL;
  370. public $innermostTableLevel = NULL;
  371. public $saveTableCounter = NULL;
  372. public $cellBorderBuffer = NULL;
  373. public $saveHTMLFooter_height = NULL;
  374. public $saveHTMLFooterE_height = NULL;
  375. public $firstPageBoxHeader = NULL;
  376. public $firstPageBoxHeaderEven = NULL;
  377. public $firstPageBoxFooter = NULL;
  378. public $firstPageBoxFooterEven = NULL;
  379. public $page_box = NULL;
  380. public $show_marks = NULL;
  381. public $basepathIsLocal = NULL;
  382. public $use_kwt = NULL;
  383. public $kwt = NULL;
  384. public $kwt_height = NULL;
  385. public $kwt_y0 = NULL;
  386. public $kwt_x0 = NULL;
  387. public $kwt_buffer = NULL;
  388. public $kwt_Links = NULL;
  389. public $kwt_moved = NULL;
  390. public $kwt_saved = NULL;
  391. public $PageNumSubstitutions = NULL;
  392. public $table_borders_separate = NULL;
  393. public $base_table_properties = NULL;
  394. public $borderstyles = NULL;
  395. public $listjustfinished = NULL;
  396. public $blockjustfinished = NULL;
  397. public $orig_bMargin = NULL;
  398. public $orig_tMargin = NULL;
  399. public $orig_lMargin = NULL;
  400. public $orig_rMargin = NULL;
  401. public $orig_hMargin = NULL;
  402. public $orig_fMargin = NULL;
  403. public $pageheaders = NULL;
  404. public $pagefooters = NULL;
  405. public $pageHTMLheaders = NULL;
  406. public $pageHTMLfooters = NULL;
  407. public $saveHTMLHeader = NULL;
  408. public $saveHTMLFooter = NULL;
  409. public $HTMLheaderPageLinks = NULL;
  410. public $HTMLheaderPageAnnots = NULL;
  411. public $HTMLheaderPageForms = NULL;
  412. public $available_unifonts = NULL;
  413. public $sans_fonts = NULL;
  414. public $serif_fonts = NULL;
  415. public $mono_fonts = NULL;
  416. public $defaultSubsFont = NULL;
  417. public $available_CJK_fonts = NULL;
  418. public $cascadeCSS = NULL;
  419. public $HTMLHeader = NULL;
  420. public $HTMLFooter = NULL;
  421. public $HTMLHeaderE = NULL;
  422. public $HTMLFooterE = NULL;
  423. public $bufferoutput = NULL;
  424. public $showdefaultpagenos = NULL;
  425. public $Big5_widths = NULL;
  426. public $GB_widths = NULL;
  427. public $SJIS_widths = NULL;
  428. public $UHC_widths = NULL;
  429. public $encrypted = NULL;
  430. public $Uvalue = NULL;
  431. public $Ovalue = NULL;
  432. public $Pvalue = NULL;
  433. public $enc_obj_id = NULL;
  434. public $last_rc4_key = NULL;
  435. public $last_rc4_key_c = NULL;
  436. public $encryption_key = NULL;
  437. public $padding = NULL;
  438. public $BMoutlines = NULL;
  439. public $OutlineRoot = NULL;
  440. public $ColActive = NULL;
  441. public $Reference = NULL;
  442. public $CurrCol = NULL;
  443. public $NbCol = NULL;
  444. public $y0 = NULL;
  445. public $ColL = NULL;
  446. public $ColWidth = NULL;
  447. public $ColGap = NULL;
  448. public $ColR = NULL;
  449. public $ChangeColumn = NULL;
  450. public $columnbuffer = NULL;
  451. public $ColDetails = NULL;
  452. public $columnLinks = NULL;
  453. public $colvAlign = NULL;
  454. public $substitute = NULL;
  455. public $entsearch = NULL;
  456. public $entsubstitute = NULL;
  457. public $defaultCSS = NULL;
  458. public $linemaxfontsize = NULL;
  459. public $lineheight_correction = NULL;
  460. public $lastoptionaltag = NULL;
  461. public $pageoutput = NULL;
  462. public $charset_in = NULL;
  463. public $blk = NULL;
  464. public $blklvl = NULL;
  465. public $ColumnAdjust = NULL;
  466. public $ws = NULL;
  467. public $HREF = NULL;
  468. public $pgwidth = NULL;
  469. public $fontlist = NULL;
  470. public $oldx = NULL;
  471. public $oldy = NULL;
  472. public $B = NULL;
  473. public $U = NULL;
  474. public $S = NULL;
  475. public $I = NULL;
  476. public $tdbegin = NULL;
  477. public $table = NULL;
  478. public $cell = NULL;
  479. public $col = NULL;
  480. public $row = NULL;
  481. public $divbegin = NULL;
  482. public $divalign = NULL;
  483. public $divwidth = NULL;
  484. public $divheight = NULL;
  485. public $divrevert = NULL;
  486. public $spanbgcolor = NULL;
  487. public $spanlvl = NULL;
  488. public $listlvl = NULL;
  489. public $listnum = NULL;
  490. public $listtype = NULL;
  491. public $listoccur = NULL;
  492. public $listlist = NULL;
  493. public $listitem = NULL;
  494. public $pjustfinished = NULL;
  495. public $ignorefollowingspaces = NULL;
  496. public $SUP = NULL;
  497. public $SUB = NULL;
  498. public $SMALL = NULL;
  499. public $BIG = NULL;
  500. public $toupper = NULL;
  501. public $tolower = NULL;
  502. public $capitalize = NULL;
  503. public $dash_on = NULL;
  504. public $dotted_on = NULL;
  505. public $strike = NULL;
  506. public $CSS = NULL;
  507. public $textbuffer = NULL;
  508. public $currentfontstyle = NULL;
  509. public $currentfontfamily = NULL;
  510. public $currentfontsize = NULL;
  511. public $colorarray = NULL;
  512. public $bgcolorarray = NULL;
  513. public $internallink = NULL;
  514. public $enabledtags = NULL;
  515. public $lineheight = NULL;
  516. public $basepath = NULL;
  517. public $outlineparam = NULL;
  518. public $outline_on = NULL;
  519. public $specialcontent = NULL;
  520. public $selectoption = NULL;
  521. public $objectbuffer = NULL;
  522. public $table_rotate = NULL;
  523. public $tbrot_maxw = NULL;
  524. public $tbrot_maxh = NULL;
  525. public $tablebuffer = NULL;
  526. public $tbrot_align = NULL;
  527. public $tbrot_Links = NULL;
  528. public $divbuffer = NULL;
  529. public $keep_block_together = NULL;
  530. public $ktLinks = NULL;
  531. public $ktBlock = NULL;
  532. public $ktForms = NULL;
  533. public $ktReference = NULL;
  534. public $ktBMoutlines = NULL;
  535. public $_kttoc = NULL;
  536. public $tbrot_y0 = NULL;
  537. public $tbrot_x0 = NULL;
  538. public $tbrot_w = NULL;
  539. public $tbrot_h = NULL;
  540. public $mb_enc = NULL;
  541. public $directionality = NULL;
  542. public $extgstates = NULL;
  543. public $mgl = NULL;
  544. public $mgt = NULL;
  545. public $mgr = NULL;
  546. public $mgb = NULL;
  547. public $tts = NULL;
  548. public $ttz = NULL;
  549. public $tta = NULL;
  550. public $headerDetails = NULL;
  551. public $footerDetails = NULL;
  552. public $page_break_after_avoid = NULL;
  553. public $margin_bottom_collapse = NULL;
  554. public $list_indent = NULL;
  555. public $list_align = NULL;
  556. public $list_margin_bottom = NULL;
  557. public $default_font_size = NULL;
  558. public $original_default_font_size = NULL;
  559. public $original_default_font = NULL;
  560. public $watermark_font = NULL;
  561. public $defaultAlign = NULL;
  562. public $defaultTableAlign = NULL;
  563. public $tablethead = NULL;
  564. public $thead_font_weight = NULL;
  565. public $thead_font_style = NULL;
  566. public $thead_font_smCaps = NULL;
  567. public $thead_valign_default = NULL;
  568. public $thead_textalign_default = NULL;
  569. public $tabletfoot = NULL;
  570. public $tfoot_font_weight = NULL;
  571. public $tfoot_font_style = NULL;
  572. public $tfoot_font_smCaps = NULL;
  573. public $tfoot_valign_default = NULL;
  574. public $tfoot_textalign_default = NULL;
  575. public $trow_text_rotate = NULL;
  576. public $cellPaddingL = NULL;
  577. public $cellPaddingR = NULL;
  578. public $cellPaddingT = NULL;
  579. public $cellPaddingB = NULL;
  580. public $table_lineheight = NULL;
  581. public $table_border_attr_set = NULL;
  582. public $table_border_css_set = NULL;
  583. public $shrin_k = NULL;
  584. public $shrink_this_table_to_fit = NULL;
  585. public $MarginCorrection = NULL;
  586. public $margin_footer = NULL;
  587. public $margin_header = NULL;
  588. public $tabletheadjustfinished = NULL;
  589. public $usingCoreFont = NULL;
  590. public $charspacing = NULL;
  591. public $DisplayPreferences = NULL;
  592. public $outlines = NULL;
  593. public $flowingBlockAttr = NULL;
  594. public $page = NULL;
  595. public $n = NULL;
  596. public $offsets = NULL;
  597. public $buffer = NULL;
  598. public $pages = NULL;
  599. public $state = NULL;
  600. public $compress = NULL;
  601. public $DefOrientation = NULL;
  602. public $CurOrientation = NULL;
  603. public $OrientationChanges = NULL;
  604. public $k = NULL;
  605. public $fwPt = NULL;
  606. public $fhPt = NULL;
  607. public $fw = NULL;
  608. public $fh = NULL;
  609. public $wPt = NULL;
  610. public $hPt = NULL;
  611. public $w = NULL;
  612. public $h = NULL;
  613. public $lMargin = NULL;
  614. public $tMargin = NULL;
  615. public $rMargin = NULL;
  616. public $bMargin = NULL;
  617. public $cMarginL = NULL;
  618. public $cMarginR = NULL;
  619. public $cMarginT = NULL;
  620. public $cMarginB = NULL;
  621. public $DeflMargin = NULL;
  622. public $DefrMargin = NULL;
  623. public $x = NULL;
  624. public $y = NULL;
  625. public $lasth = NULL;
  626. public $LineWidth = NULL;
  627. public $CoreFonts = NULL;
  628. public $fonts = NULL;
  629. public $FontFiles = NULL;
  630. public $images = NULL;
  631. public $PageLinks = NULL;
  632. public $links = NULL;
  633. public $FontFamily = NULL;
  634. public $FontStyle = NULL;
  635. public $CurrentFont = NULL;
  636. public $FontSizePt = NULL;
  637. public $FontSize = NULL;
  638. public $DrawColor = NULL;
  639. public $FillColor = NULL;
  640. public $TextColor = NULL;
  641. public $ColorFlag = NULL;
  642. public $autoPageBreak = NULL;
  643. public $PageBreakTrigger = NULL;
  644. public $InFooter = NULL;
  645. public $InHTMLFooter = NULL;
  646. public $processingFooter = NULL;
  647. public $processingHeader = NULL;
  648. public $ZoomMode = NULL;
  649. public $LayoutMode = NULL;
  650. public $title = NULL;
  651. public $subject = NULL;
  652. public $author = NULL;
  653. public $keywords = NULL;
  654. public $creator = NULL;
  655. public $aliasNbPg = NULL;
  656. public $aliasNbPgGp = NULL;
  657. public $aliasNbPgHex = NULL;
  658. public $aliasNbPgGpHex = NULL;
  659. public $ispre = NULL;
  660. public $outerblocktags = NULL;
  661. public $innerblocktags = NULL;
  662.  
  663. public function __construct($mode = "", $format = "A4", $default_font_size = 0, $default_font = "", $mgl = 15, $mgr = 15, $mgt = 16, $mgb = 16, $mgh = 9, $mgf = 9, $orientation = "P")
  664. {
  665. if (!class_exists("grad", false)) {
  666. include(_MPDF_PATH . "classes/grad.php");
  667. }
  668.  
  669. if (empty($this->grad)) {
  670. $this->grad = new grad($this);
  671. }
  672.  
  673. if (!class_exists("form", false)) {
  674. include(_MPDF_PATH . "classes/form.php");
  675. }
  676.  
  677. if (empty($this->form)) {
  678. $this->form = new form($this);
  679. }
  680.  
  681. $this->time0 = microtime(true);
  682. $this->_dochecks();
  683. $this->UnvalidatedText =& $this->watermarkText;
  684. $this->TopicIsUnvalidated =& $this->showWatermarkText;
  685. $this->AliasNbPg =& $this->aliasNbPg;
  686. $this->AliasNbPgGp =& $this->aliasNbPgGp;
  687. $this->BiDirectional =& $this->biDirectional;
  688. $this->Anchor2Bookmark =& $this->anchor2Bookmark;
  689. $this->KeepColumns =& $this->keepColumns;
  690. $this->useOddEven =& $this->mirrorMargins;
  691. $this->useSubstitutionsMB =& $this->useSubstitutions;
  692. $this->visibility = "visible";
  693. $this->spotColors = array();
  694. $this->spotColorIDs = array();
  695. $this->tableBackgrounds = array();
  696. $this->kt_y00 = "";
  697. $this->kt_p00 = "";
  698. $this->iterationCounter = false;
  699. $this->BMPonly = array();
  700. $this->page = 0;
  701. $this->n = 2;
  702. $this->buffer = "";
  703. $this->objectbuffer = array();
  704. $this->pages = array();
  705. $this->OrientationChanges = array();
  706. $this->state = 0;
  707. $this->fonts = array();
  708. $this->FontFiles = array();
  709. $this->images = array();
  710. $this->links = array();
  711. $this->InFooter = false;
  712. $this->processingFooter = false;
  713. $this->processingHeader = false;
  714. $this->lasth = 0;
  715. $this->FontFamily = "";
  716. $this->FontStyle = "";
  717. $this->FontSizePt = 9;
  718. $this->U = false;
  719. $this->upperCase = array();
  720. $this->S = false;
  721. $this->smCapsScale = 1;
  722. $this->smCapsStretch = 100;
  723. $this->margBuffer = 0;
  724. $this->inMeter = false;
  725. $this->defTextColor = $this->TextColor = $this->SetTColor($this->ConvertColor(0), true);
  726. $this->defDrawColor = $this->DrawColor = $this->SetDColor($this->ConvertColor(0), true);
  727. $this->defFillColor = $this->FillColor = $this->SetFColor($this->ConvertColor(255), true);
  728. $this->SVGcolors = array(
  729. "antiquewhite" => "#FAEBD7",
  730. "aqua" => "#00FFFF",
  731. "aquamarine" => "#7FFFD4",
  732. "beige" => "#F5F5DC",
  733. "black" => "#000000",
  734. "blue" => "#0000FF",
  735. "brown" => "#A52A2A",
  736. "cadetblue" => "#5F9EA0",
  737. "chocolate" => "#D2691E",
  738. "cornflowerblue" => "#6495ED",
  739. "crimson" => "#DC143C",
  740. "darkblue" => "#00008B",
  741. "darkgoldenrod" => "#B8860B",
  742. "darkgreen" => "#006400",
  743. "darkmagenta" => "#8B008B",
  744. "darkorange" => "#FF8C00",
  745. "darkred" => "#8B0000",
  746. "darkseagreen" => "#8FBC8F",
  747. "darkslategray" => "#2F4F4F",
  748. "darkviolet" => "#9400D3",
  749. "deepskyblue" => "#00BFFF",
  750. "dodgerblue" => "#1E90FF",
  751. "firebrick" => "#B22222",
  752. "forestgreen" => "#228B22",
  753. "fuchsia" => "#FF00FF",
  754. "gainsboro" => "#DCDCDC",
  755. "gold" => "#FFD700",
  756. "gray" => "#808080",
  757. "green" => "#008000",
  758. "greenyellow" => "#ADFF2F",
  759. "hotpink" => "#FF69B4",
  760. "indigo" => "#4B0082",
  761. "khaki" => "#F0E68C",
  762. "lavenderblush" => "#FFF0F5",
  763. "lemonchiffon" => "#FFFACD",
  764. "lightcoral" => "#F08080",
  765. "lightgoldenrodyellow" => "#FAFAD2",
  766. "lightgreen" => "#90EE90",
  767. "lightsalmon" => "#FFA07A",
  768. "lightskyblue" => "#87CEFA",
  769. "lightslategray" => "#778899",
  770. "lightyellow" => "#FFFFE0",
  771. "lime" => "#00FF00",
  772. "limegreen" => "#32CD32",
  773. "magenta" => "#FF00FF",
  774. "maroon" => "#800000",
  775. "mediumaquamarine" => "#66CDAA",
  776. "mediumorchid" => "#BA55D3",
  777. "mediumseagreen" => "#3CB371",
  778. "mediumspringgreen" => "#00FA9A",
  779. "mediumvioletred" => "#C71585",
  780. "midnightblue" => "#191970",
  781. "mintcream" => "#F5FFFA",
  782. "moccasin" => "#FFE4B5",
  783. "navy" => "#000080",
  784. "olive" => "#808000",
  785. "orange" => "#FFA500",
  786. "orchid" => "#DA70D6",
  787. "palegreen" => "#98FB98",
  788. "palevioletred" => "#D87093",
  789. "peachpuff" => "#FFDAB9",
  790. "pink" => "#FFC0CB",
  791. "powderblue" => "#B0E0E6",
  792. "purple" => "#800080",
  793. "red" => "#FF0000",
  794. "royalblue" => "#4169E1",
  795. "salmon" => "#FA8072",
  796. "seagreen" => "#2E8B57",
  797. "sienna" => "#A0522D",
  798. "silver" => "#C0C0C0",
  799. "skyblue" => "#87CEEB",
  800. "slategray" => "#708090",
  801. "springgreen" => "#00FF7F",
  802. "steelblue" => "#4682B4",
  803. "tan" => "#D2B48C",
  804. "teal" => "#008080",
  805. "thistle" => "#D8BFD8",
  806. "turquoise" => "#40E0D0",
  807. "violetred" => "#D02090",
  808. "white" => "#FFFFFF",
  809. "yellow" => "#FFFF00",
  810. "aliceblue" => "#f0f8ff",
  811. "azure" => "#f0ffff",
  812. "bisque" => "#ffe4c4",
  813. "blanchedalmond" => "#ffebcd",
  814. "blueviolet" => "#8a2be2",
  815. "burlywood" => "#deb887",
  816. "chartreuse" => "#7fff00",
  817. "coral" => "#ff7f50",
  818. "cornsilk" => "#fff8dc",
  819. "cyan" => "#00ffff",
  820. "darkcyan" => "#008b8b",
  821. "darkgray" => "#a9a9a9",
  822. "darkgrey" => "#a9a9a9",
  823. "darkkhaki" => "#bdb76b",
  824. "darkolivegreen" => "#556b2f",
  825. "darkorchid" => "#9932cc",
  826. "darksalmon" => "#e9967a",
  827. "darkslateblue" => "#483d8b",
  828. "darkslategrey" => "#2f4f4f",
  829. "darkturquoise" => "#00ced1",
  830. "deeppink" => "#ff1493",
  831. "dimgray" => "#696969",
  832. "dimgrey" => "#696969",
  833. "floralwhite" => "#fffaf0",
  834. "ghostwhite" => "#f8f8ff",
  835. "goldenrod" => "#daa520",
  836. "grey" => "#808080",
  837. "honeydew" => "#f0fff0",
  838. "indianred" => "#cd5c5c",
  839. "ivory" => "#fffff0",
  840. "lavender" => "#e6e6fa",
  841. "lawngreen" => "#7cfc00",
  842. "lightblue" => "#add8e6",
  843. "lightcyan" => "#e0ffff",
  844. "lightgray" => "#d3d3d3",
  845. "lightgrey" => "#d3d3d3",
  846. "lightpink" => "#ffb6c1",
  847. "lightseagreen" => "#20b2aa",
  848. "lightslategrey" => "#778899",
  849. "lightsteelblue" => "#b0c4de",
  850. "linen" => "#faf0e6",
  851. "mediumblue" => "#0000cd",
  852. "mediumpurple" => "#9370db",
  853. "mediumslateblue" => "#7b68ee",
  854. "mediumturquoise" => "#48d1cc",
  855. "mistyrose" => "#ffe4e1",
  856. "navajowhite" => "#ffdead",
  857. "oldlace" => "#fdf5e6",
  858. "olivedrab" => "#6b8e23",
  859. "orangered" => "#ff4500",
  860. "palegoldenrod" => "#eee8aa",
  861. "paleturquoise" => "#afeeee",
  862. "papayawhip" => "#ffefd5",
  863. "peru" => "#cd853f",
  864. "plum" => "#dda0dd",
  865. "rosybrown" => "#bc8f8f",
  866. "saddlebrown" => "#8b4513",
  867. "sandybrown" => "#f4a460",
  868. "seashell" => "#fff5ee",
  869. "slateblue" => "#6a5acd",
  870. "slategrey" => "#708090",
  871. "snow" => "#fffafa",
  872. "tomato" => "#ff6347",
  873. "violet" => "#ee82ee",
  874. "wheat" => "#f5deb3",
  875. "whitesmoke" => "#f5f5f5",
  876. "yellowgreen" => "#9acd32"
  877. );
  878. $this->ColorFlag = false;
  879. $this->extgstates = array();
  880. $this->mb_enc = "windows-1252";
  881. $this->directionality = "ltr";
  882. $this->defaultAlign = "L";
  883. $this->defaultTableAlign = "L";
  884. $this->fixedPosBlockSave = array();
  885. $this->extraFontSubsets = 0;
  886. $this->SHYpatterns = array();
  887. $this->loadedSHYdictionary = false;
  888. $this->SHYdictionary = array();
  889. $this->SHYdictionaryWords = array();
  890. $this->blockContext = 1;
  891. $this->floatDivs = array();
  892. $this->DisplayPreferences = "";
  893. $this->tablecascadeCSS = array();
  894. $this->listcascadeCSS = array();
  895. $this->patterns = array();
  896. $this->pageBackgrounds = array();
  897. $this->writingHTMLheader = false;
  898. $this->writingHTMLfooter = false;
  899. $this->gradients = array();
  900. $this->kwt_Reference = array();
  901. $this->kwt_BMoutlines = array();
  902. $this->kwt_toc = array();
  903. $this->tbrot_Reference = array();
  904. $this->tbrot_BMoutlines = array();
  905. $this->tbrot_toc = array();
  906. $this->col_Reference = array();
  907. $this->col_BMoutlines = array();
  908. $this->col_toc = array();
  909. $this->graphs = array();
  910. $this->pgsIns = array();
  911. $this->PDFAXwarnings = array();
  912. $this->inlineDisplayOff = false;
  913. $this->kerning = false;
  914. $this->lSpacingCSS = "";
  915. $this->wSpacingCSS = "";
  916. $this->fixedlSpacing = false;
  917. $this->minwSpacing = 0;
  918. $this->baselineC = 0.35;
  919. $this->noImageFile = str_replace("\\", "/", dirname(__FILE__)) . "/includes/no_image.jpg";
  920. $this->subPos = 0;
  921. $this->forceExactLineheight = false;
  922. $this->listOcc = 0;
  923. $this->normalLineheight = 1.3;
  924. $this->incrementFPR1 = 10;
  925. $this->incrementFPR2 = 10;
  926. $this->incrementFPR3 = 10;
  927. $this->incrementFPR4 = 10;
  928. $this->fullImageHeight = false;
  929. $this->floatbuffer = array();
  930. $this->floatmargins = array();
  931. $this->autoFontGroups = 0;
  932. $this->formobjects = array();
  933. $this->InlineProperties = array();
  934. $this->InlineAnnots = array();
  935. $this->ktAnnots = array();
  936. $this->tbrot_Annots = array();
  937. $this->kwt_Annots = array();
  938. $this->columnAnnots = array();
  939. $this->pageDim = array();
  940. $this->breakpoints = array();
  941. $this->tableLevel = 0;
  942. $this->tbctr = array();
  943. $this->page_box = array();
  944. $this->show_marks = "";
  945. $this->kwt = false;
  946. $this->kwt_height = 0;
  947. $this->kwt_y0 = 0;
  948. $this->kwt_x0 = 0;
  949. $this->kwt_buffer = array();
  950. $this->kwt_Links = array();
  951. $this->kwt_moved = false;
  952. $this->kwt_saved = false;
  953. $this->PageNumSubstitutions = array();
  954. $this->base_table_properties = array();
  955. $this->borderstyles = array(
  956. "inset",
  957. "groove",
  958. "outset",
  959. "ridge",
  960. "dotted",
  961. "dashed",
  962. "solid",
  963. "double"
  964. );
  965. $this->tbrot_align = "C";
  966. $this->pageheaders = array();
  967. $this->pagefooters = array();
  968. $this->pageHTMLheaders = array();
  969. $this->pageHTMLfooters = array();
  970. $this->HTMLheaderPageLinks = array();
  971. $this->HTMLheaderPageAnnots = array();
  972. $this->ktForms = array();
  973. $this->HTMLheaderPageForms = array();
  974. $this->columnForms = array();
  975. $this->tbrotForms = array();
  976. $this->useRC128encryption = false;
  977. $this->uniqid = "";
  978. $this->cascadeCSS = array();
  979. $this->bufferoutput = false;
  980. $this->encrypted = false;
  981. $this->BMoutlines = array();
  982. $this->ColActive = 0;
  983. $this->Reference = array();
  984. $this->CurrCol = 0;
  985. $this->ColL = array(
  986. 0
  987. );
  988. $this->ColR = array(
  989. 0
  990. );
  991. $this->ChangeColumn = 0;
  992. $this->columnbuffer = array();
  993. $this->ColDetails = array();
  994. $this->columnLinks = array();
  995. $this->substitute = array();
  996. $this->entsearch = array();
  997. $this->entsubstitute = array();
  998. $this->lastoptionaltag = "";
  999. $this->charset_in = "";
  1000. $this->blk = array();
  1001. $this->blklvl = 0;
  1002. $this->tts = false;
  1003. $this->ttz = false;
  1004. $this->tta = false;
  1005. $this->ispre = false;
  1006. $this->checkSIP = false;
  1007. $this->checkSMP = false;
  1008. $this->checkCJK = false;
  1009. $this->tableCJK = false;
  1010. $this->headerDetails = array();
  1011. $this->footerDetails = array();
  1012. $this->page_break_after_avoid = false;
  1013. $this->margin_bottom_collapse = false;
  1014. $this->tablethead = 0;
  1015. $this->tabletfoot = 0;
  1016. $this->table_border_attr_set = 0;
  1017. $this->table_border_css_set = 0;
  1018. $this->shrin_k = 1;
  1019. $this->shrink_this_table_to_fit = 0;
  1020. $this->MarginCorrection = 0;
  1021. $this->tabletheadjustfinished = false;
  1022. $this->usingCoreFont = false;
  1023. $this->charspacing = 0;
  1024. $this->outlines = array();
  1025. $this->autoPageBreak = true;
  1026. require(_MPDF_PATH . "config.php");
  1027. $this->_setPageSize($format, $orientation);
  1028. $this->DefOrientation = $orientation;
  1029. $this->margin_header = $mgh;
  1030. $this->margin_footer = $mgf;
  1031. $bmargin = $mgb;
  1032. $this->DeflMargin = $mgl;
  1033. $this->DefrMargin = $mgr;
  1034. $this->orig_tMargin = $mgt;
  1035. $this->orig_bMargin = $bmargin;
  1036. $this->orig_lMargin = $this->DeflMargin;
  1037. $this->orig_rMargin = $this->DefrMargin;
  1038. $this->orig_hMargin = $this->margin_header;
  1039. $this->orig_fMargin = $this->margin_footer;
  1040. if ($this->setAutoTopMargin == "pad") {
  1041. $mgt += $this->margin_header;
  1042. }
  1043.  
  1044. if ($this->setAutoBottomMargin == "pad") {
  1045. $mgb += $this->margin_footer;
  1046. }
  1047.  
  1048. $this->SetMargins($this->DeflMargin, $this->DefrMargin, $mgt);
  1049. $this->SetAutoPageBreak($this->autoPageBreak, $bmargin);
  1050. $this->pgwidth = $this->w - $this->lMargin - $this->rMargin;
  1051. $this->cMarginL = 1;
  1052. $this->cMarginR = 1;
  1053. $this->LineWidth = 0.567 / _MPDFK;
  1054. $this->AliasNbPages();
  1055. $this->AliasNbPageGroups();
  1056. $this->aliasNbPgHex = "{nbHEXmarker}";
  1057. $this->aliasNbPgGpHex = "{nbpgHEXmarker}";
  1058. $this->DisableTags();
  1059. $this->SetDisplayMode(100);
  1060. $this->SetCompression(true);
  1061. $this->SetDisplayPreferences("");
  1062. require(_MPDF_PATH . "config_fonts.php");
  1063. $this->available_unifonts = array();
  1064. foreach ($this->fontdata as $f => $fs) {
  1065. if (isset($fs["R"]) && $fs["R"]) {
  1066. $this->available_unifonts[] = $f;
  1067. }
  1068.  
  1069. if (isset($fs["B"]) && $fs["B"]) {
  1070. $this->available_unifonts[] = $f . "B";
  1071. }
  1072.  
  1073. if (isset($fs["I"]) && $fs["I"]) {
  1074. $this->available_unifonts[] = $f . "I";
  1075. }
  1076.  
  1077. if (isset($fs["BI"]) && $fs["BI"]) {
  1078. $this->available_unifonts[] = $f . "BI";
  1079. }
  1080.  
  1081. }
  1082. $this->default_available_fonts = $this->available_unifonts;
  1083. $optcore = false;
  1084. $onlyCoreFonts = false;
  1085. if (preg_match("/([\\-+])aCJK/i", $mode, $m)) {
  1086. preg_replace("/([\\-+])aCJK/i", "", $mode);
  1087. if ($m[1] == "+") {
  1088. $this->useAdobeCJK = true;
  1089. } else {
  1090. $this->useAdobeCJK = false;
  1091. }
  1092.  
  1093. }
  1094.  
  1095. if (strlen($mode) == 1) {
  1096. if ($mode == "s") {
  1097. $this->percentSubset = 100;
  1098. $mode = "";
  1099. } else {
  1100. if ($mode == "c") {
  1101. $onlyCoreFonts = true;
  1102. $mode = "";
  1103. }
  1104.  
  1105. }
  1106.  
  1107. } else {
  1108. if (substr($mode, -2) == "-s") {
  1109. $this->percentSubset = 100;
  1110. $mode = substr($mode, 0, strlen($mode) - 2);
  1111. } else {
  1112. if (substr($mode, -2) == "-c") {
  1113. $onlyCoreFonts = true;
  1114. $mode = substr($mode, 0, strlen($mode) - 2);
  1115. } else {
  1116. if (substr($mode, -2) == "-x") {
  1117. $optcore = true;
  1118. $mode = substr($mode, 0, strlen($mode) - 2);
  1119. }
  1120.  
  1121. }
  1122.  
  1123. }
  1124.  
  1125. }
  1126.  
  1127. if (strlen($mode) == 5 && $mode != "UTF-8" || strlen($mode) == 2) {
  1128. list($coreSuitable, $mpdf_pdf_unifonts) = GetLangOpts($mode, $this->useAdobeCJK);
  1129. if ($coreSuitable && $optcore) {
  1130. $onlyCoreFonts = true;
  1131. }
  1132.  
  1133. if ($mpdf_pdf_unifonts) {
  1134. $this->RestrictUnicodeFonts($mpdf_pdf_unifonts);
  1135. $this->default_available_fonts = $mpdf_pdf_unifonts;
  1136. }
  1137.  
  1138. $this->currentLang = $mode;
  1139. $this->default_lang = $mode;
  1140. }
  1141.  
  1142. $this->onlyCoreFonts = $onlyCoreFonts;
  1143. if ($this->onlyCoreFonts) {
  1144. $this->setMBencoding("windows-1252");
  1145. } else {
  1146. $this->setMBencoding("UTF-8");
  1147. }
  1148.  
  1149. @mb_regex_encoding("UTF-8");
  1150. $this->available_CJK_fonts = array(
  1151. "gb",
  1152. "big5",
  1153. "sjis",
  1154. "uhc",
  1155. "gbB",
  1156. "big5B",
  1157. "sjisB",
  1158. "uhcB",
  1159. "gbI",
  1160. "big5I",
  1161. "sjisI",
  1162. "uhcI",
  1163. "gbBI",
  1164. "big5BI",
  1165. "sjisBI",
  1166. "uhcBI"
  1167. );
  1168. $this->CoreFonts = array(
  1169. "ccourier" => "Courier",
  1170. "ccourierB" => "Courier-Bold",
  1171. "ccourierI" => "Courier-Oblique",
  1172. "ccourierBI" => "Courier-BoldOblique",
  1173. "chelvetica" => "Helvetica",
  1174. "chelveticaB" => "Helvetica-Bold",
  1175. "chelveticaI" => "Helvetica-Oblique",
  1176. "chelveticaBI" => "Helvetica-BoldOblique",
  1177. "ctimes" => "Times-Roman",
  1178. "ctimesB" => "Times-Bold",
  1179. "ctimesI" => "Times-Italic",
  1180. "ctimesBI" => "Times-BoldItalic",
  1181. "csymbol" => "Symbol",
  1182. "czapfdingbats" => "ZapfDingbats"
  1183. );
  1184. $this->fontlist = array(
  1185. "ctimes",
  1186. "ccourier",
  1187. "chelvetica",
  1188. "csymbol",
  1189. "czapfdingbats"
  1190. );
  1191. $this->setHiEntitySubstitutions();
  1192. if ($this->onlyCoreFonts) {
  1193. $this->useSubstitutions = true;
  1194. $this->SetSubstitutions();
  1195. } else {
  1196. $this->useSubstitutions = false;
  1197. }
  1198.  
  1199. if (file_exists(_MPDF_PATH . "mpdf.css")) {
  1200. $css = file_get_contents(_MPDF_PATH . "mpdf.css");
  1201. $css2 = $this->ReadDefaultCSS($css);
  1202. $this->defaultCSS = $this->array_merge_recursive_unique($this->defaultCSS, $css2);
  1203. }
  1204.  
  1205. if ($default_font == "") {
  1206. if ($this->onlyCoreFonts) {
  1207. if (in_array(strtolower($this->defaultCSS["BODY"]["FONT-FAMILY"]), $this->mono_fonts)) {
  1208. $default_font = "ccourier";
  1209. } else {
  1210. if (in_array(strtolower($this->defaultCSS["BODY"]["FONT-FAMILY"]), $this->sans_fonts)) {
  1211. $default_font = "chelvetica";
  1212. } else {
  1213. $default_font = "ctimes";
  1214. }
  1215.  
  1216. }
  1217.  
  1218. } else {
  1219. $default_font = $this->defaultCSS["BODY"]["FONT-FAMILY"];
  1220. }
  1221.  
  1222. }
  1223.  
  1224. if (!$default_font_size) {
  1225. $mmsize = $this->ConvertSize($this->defaultCSS["BODY"]["FONT-SIZE"]);
  1226. $default_font_size = $mmsize * _MPDFK;
  1227. }
  1228.  
  1229. if ($default_font) {
  1230. $this->SetDefaultFont($default_font);
  1231. }
  1232.  
  1233. if ($default_font_size) {
  1234. $this->SetDefaultFontSize($default_font_size);
  1235. }
  1236.  
  1237. $this->SetLineHeight();
  1238. $this->SetFColor($this->ConvertColor(255));
  1239. $this->HREF = "";
  1240. $this->oldy = -1;
  1241. $this->B = 0;
  1242. $this->U = false;
  1243. $this->S = false;
  1244. $this->I = 0;
  1245. $this->listlvl = 0;
  1246. $this->listnum = 0;
  1247. $this->listtype = "";
  1248. $this->listoccur = array();
  1249. $this->listlist = array();
  1250. $this->listitem = array();
  1251. $this->tdbegin = false;
  1252. $this->table = array();
  1253. $this->cell = array();
  1254. $this->col = -1;
  1255. $this->row = -1;
  1256. $this->cellBorderBuffer = array();
  1257. $this->divbegin = false;
  1258. $this->divalign = "";
  1259. $this->divwidth = 0;
  1260. $this->divheight = 0;
  1261. $this->spanbgcolor = false;
  1262. $this->divrevert = false;
  1263. $this->spanborder = false;
  1264. $this->spanborddet = array();
  1265. $this->blockjustfinished = false;
  1266. $this->listjustfinished = false;
  1267. $this->ignorefollowingspaces = true;
  1268. $this->toupper = false;
  1269. $this->tolower = false;
  1270. $this->capitalize = false;
  1271. $this->dash_on = false;
  1272. $this->dotted_on = false;
  1273. $this->SUP = false;
  1274. $this->SUB = false;
  1275. $this->strike = false;
  1276. $this->textshadow = "";
  1277. $this->currentfontfamily = "";
  1278. $this->currentfontsize = "";
  1279. $this->currentfontstyle = "";
  1280. $this->colorarray = array();
  1281. $this->spanbgcolorarray = array();
  1282. $this->textbuffer = array();
  1283. $this->CSS = array();
  1284. $this->internallink = array();
  1285. $this->basepath = "";
  1286. $this->SetBasePath("");
  1287. $this->outlineparam = array();
  1288. $this->outline_on = false;
  1289. $this->specialcontent = "";
  1290. $this->selectoption = array();
  1291. $this->tpls = array();
  1292. $this->tpl = 0;
  1293. $this->tplprefix = "/TPL";
  1294. $this->res = array();
  1295. if ($this->enableImports) {
  1296. $this->SetImportUse();
  1297. }
  1298.  
  1299. if ($this->progressBar) {
  1300. $this->StartProgressBarOutput($this->progressBar);
  1301. }
  1302.  
  1303. }
  1304.  
  1305. public function _setPageSize($format, &$orientation)
  1306. {
  1307. if (is_string($format)) {
  1308. if ($format == "") {
  1309. $format = "A4";
  1310. }
  1311.  
  1312. $pfo = "P";
  1313. if (preg_match("/([0-9a-zA-Z]*)-L/i", $format, $m)) {
  1314. $format = $m[1];
  1315. $pfo = "L";
  1316. }
  1317.  
  1318. $format = $this->_getPageFormat($format);
  1319. if (!$format) {
  1320. $this->Error("Unknown page format: " . $format);
  1321. } else {
  1322. $orientation = $pfo;
  1323. }
  1324.  
  1325. list($this->fwPt, $this->fhPt) = $format;
  1326. } else {
  1327. if (!$format[0] || !$format[1]) {
  1328. $this->Error("Invalid page format: " . $format[0] . " " . $format[1]);
  1329. }
  1330.  
  1331. $this->fwPt = $format[0] * _MPDFK;
  1332. $this->fhPt = $format[1] * _MPDFK;
  1333. }
  1334.  
  1335. $this->fw = $this->fwPt / _MPDFK;
  1336. $this->fh = $this->fhPt / _MPDFK;
  1337. $orientation = strtolower($orientation);
  1338. if ($orientation == "p" || $orientation == "portrait") {
  1339. $orientation = "P";
  1340. $this->wPt = $this->fwPt;
  1341. $this->hPt = $this->fhPt;
  1342. } else {
  1343. if ($orientation == "l" || $orientation == "landscape") {
  1344. $orientation = "L";
  1345. $this->wPt = $this->fhPt;
  1346. $this->hPt = $this->fwPt;
  1347. } else {
  1348. $this->Error("Incorrect orientation: " . $orientation);
  1349. }
  1350.  
  1351. }
  1352.  
  1353. $this->CurOrientation = $orientation;
  1354. $this->w = $this->wPt / _MPDFK;
  1355. $this->h = $this->hPt / _MPDFK;
  1356. }
  1357.  
  1358. public function _getPageFormat($format)
  1359. {
  1360. switch (strtoupper($format)) {
  1361. case "4A0":
  1362. $format = array(
  1363. 4767.87,
  1364. 6740.79
  1365. );
  1366. break;
  1367. case "2A0":
  1368. $format = array(
  1369. 3370.39,
  1370. 4767.87
  1371. );
  1372. break;
  1373. case "A0":
  1374. $format = array(
  1375. 2383.94,
  1376. 3370.39
  1377. );
  1378. break;
  1379. case "A1":
  1380. $format = array(
  1381. 1683.78,
  1382. 2383.94
  1383. );
  1384. break;
  1385. case "A2":
  1386. $format = array(
  1387. 1190.55,
  1388. 1683.78
  1389. );
  1390. break;
  1391. case "A3":
  1392. $format = array(
  1393. 841.89,
  1394. 1190.55
  1395. );
  1396. break;
  1397. case "A4":
  1398. $format = array(
  1399. 595.28,
  1400. 841.89
  1401. );
  1402. break;
  1403. case "A5":
  1404. $format = array(
  1405. 419.53,
  1406. 595.28
  1407. );
  1408. break;
  1409. case "A6":
  1410. $format = array(
  1411. 297.64,
  1412. 419.53
  1413. );
  1414. break;
  1415. case "A7":
  1416. $format = array(
  1417. 209.76,
  1418. 297.64
  1419. );
  1420. break;
  1421. case "A8":
  1422. $format = array(
  1423. 147.4,
  1424. 209.76
  1425. );
  1426. break;
  1427. case "A9":
  1428. $format = array(
  1429. 104.88,
  1430. 147.4
  1431. );
  1432. break;
  1433. case "A10":
  1434. $format = array(
  1435. 73.7,
  1436. 104.88
  1437. );
  1438. break;
  1439. case "B0":
  1440. $format = array(
  1441. 2834.65,
  1442. 4008.19
  1443. );
  1444. break;
  1445. case "B1":
  1446. $format = array(
  1447. 2004.09,
  1448. 2834.65
  1449. );
  1450. break;
  1451. case "B2":
  1452. $format = array(
  1453. 1417.32,
  1454. 2004.09
  1455. );
  1456. break;
  1457. case "B3":
  1458. $format = array(
  1459. 1000.63,
  1460. 1417.32
  1461. );
  1462. break;
  1463. case "B4":
  1464. $format = array(
  1465. 708.66,
  1466. 1000.63
  1467. );
  1468. break;
  1469. case "B5":
  1470. $format = array(
  1471. 498.9,
  1472. 708.66
  1473. );
  1474. break;
  1475. case "B6":
  1476. $format = array(
  1477. 354.33,
  1478. 498.9
  1479. );
  1480. break;
  1481. case "B7":
  1482. $format = array(
  1483. 249.45,
  1484. 354.33
  1485. );
  1486. break;
  1487. case "B8":
  1488. $format = array(
  1489. 175.75,
  1490. 249.45
  1491. );
  1492. break;
  1493. case "B9":
  1494. $format = array(
  1495. 124.72,
  1496. 175.75
  1497. );
  1498. break;
  1499. case "B10":
  1500. $format = array(
  1501. 87.87,
  1502. 124.72
  1503. );
  1504. break;
  1505. case "C0":
  1506. $format = array(
  1507. 2599.37,
  1508. 3676.54
  1509. );
  1510. break;
  1511. case "C1":
  1512. $format = array(
  1513. 1836.85,
  1514. 2599.37
  1515. );
  1516. break;
  1517. case "C2":
  1518. $format = array(
  1519. 1298.27,
  1520. 1836.85
  1521. );
  1522. break;
  1523. case "C3":
  1524. $format = array(
  1525. 918.43,
  1526. 1298.27
  1527. );
  1528. break;
  1529. case "C4":
  1530. $format = array(
  1531. 649.13,
  1532. 918.43
  1533. );
  1534. break;
  1535. case "C5":
  1536. $format = array(
  1537. 459.21,
  1538. 649.13
  1539. );
  1540. break;
  1541. case "C6":
  1542. $format = array(
  1543. 323.15,
  1544. 459.21
  1545. );
  1546. break;
  1547. case "C7":
  1548. $format = array(
  1549. 229.61,
  1550. 323.15
  1551. );
  1552. break;
  1553. case "C8":
  1554. $format = array(
  1555. 161.57,
  1556. 229.61
  1557. );
  1558. break;
  1559. case "C9":
  1560. $format = array(
  1561. 113.39,
  1562. 161.57
  1563. );
  1564. break;
  1565. case "C10":
  1566. $format = array(
  1567. 79.37,
  1568. 113.39
  1569. );
  1570. break;
  1571. case "RA0":
  1572. $format = array(
  1573. 2437.8,
  1574. 3458.27
  1575. );
  1576. break;
  1577. case "RA1":
  1578. $format = array(
  1579. 1729.13,
  1580. 2437.8
  1581. );
  1582. break;
  1583. case "RA2":
  1584. $format = array(
  1585. 1218.9,
  1586. 1729.13
  1587. );
  1588. break;
  1589. case "RA3":
  1590. $format = array(
  1591. 864.57,
  1592. 1218.9
  1593. );
  1594. break;
  1595. case "RA4":
  1596. $format = array(
  1597. 609.45,
  1598. 864.57
  1599. );
  1600. break;
  1601. case "SRA0":
  1602. $format = array(
  1603. 2551.18,
  1604. 3628.35
  1605. );
  1606. break;
  1607. case "SRA1":
  1608. $format = array(
  1609. 1814.17,
  1610. 2551.18
  1611. );
  1612. break;
  1613. case "SRA2":
  1614. $format = array(
  1615. 1275.59,
  1616. 1814.17
  1617. );
  1618. break;
  1619. case "SRA3":
  1620. $format = array(
  1621. 907.09,
  1622. 1275.59
  1623. );
  1624. break;
  1625. case "SRA4":
  1626. $format = array(
  1627. 637.8,
  1628. 907.09
  1629. );
  1630. break;
  1631. case "LETTER":
  1632. $format = array(
  1633. 612,
  1634. 792
  1635. );
  1636. break;
  1637. case "LEGAL":
  1638. $format = array(
  1639. 612,
  1640. 1008
  1641. );
  1642. break;
  1643. case "LEDGER":
  1644. $format = array(
  1645. 279,
  1646. 432
  1647. );
  1648. break;
  1649. case "TABLOID":
  1650. $format = array(
  1651. 279,
  1652. 432
  1653. );
  1654. break;
  1655. case "EXECUTIVE":
  1656. $format = array(
  1657. 521.86,
  1658. 756
  1659. );
  1660. break;
  1661. case "FOLIO":
  1662. $format = array(
  1663. 612,
  1664. 936
  1665. );
  1666. break;
  1667. case "B":
  1668. $format = array(
  1669. 362.83,
  1670. 561.26
  1671. );
  1672. break;
  1673. case "A":
  1674. $format = array(
  1675. 314.65,
  1676. 504.57
  1677. );
  1678. break;
  1679. case "DEMY":
  1680. $format = array(
  1681. 382.68,
  1682. 612.28
  1683. );
  1684. break;
  1685. case "ROYAL":
  1686. $format = array(
  1687. 433.7,
  1688. 663.3
  1689. );
  1690. break;
  1691. default:
  1692. $format = array(
  1693. 595.28,
  1694. 841.89
  1695. );
  1696. }
  1697. return $format;
  1698. }
  1699.  
  1700. public function StartProgressBarOutput($mode = 1)
  1701. {
  1702. if (!defined("_MPDF_URI")) {
  1703. $this->progressBar = false;
  1704. if ($this->debug) {
  1705. $this->Error("You need to define _MPDF_URI to use the progress bar!");
  1706. } else {
  1707. return false;
  1708. }
  1709.  
  1710. }
  1711.  
  1712. $this->progressBar = $mode;
  1713. if ($this->progbar_altHTML) {
  1714. echo $this->progbar_altHTML;
  1715. } else {
  1716. echo "<html>\r\n\t<head>\r\n\t<title>mPDF File Progress</title>\r\n\t<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" />\r\n\t<link rel=\"stylesheet\" type=\"text/css\" href=\"" . _MPDF_URI . "progbar.css\" />\r\n\t\t</head>\r\n\t<body>\r\n\t<div class=\"main\">\r\n\t\t<div class=\"heading\">" . $this->progbar_heading . "</div>\r\n\t\t<div class=\"demo\">\r\n\t ";
  1717. if ($this->progressBar == 2) {
  1718. echo "\t\t<table width=\"100%\"><tr><td style=\"width: 50%;\"> \r\n\t\t\t<span class=\"barheading\">Writing HTML code</span> <br/>\r\n\r\n\t\t\t<div class=\"progressBar\">\r\n\t\t\t<div id=\"element1\" class=\"innerBar\">&nbsp;</div>\r\n\t\t\t</div>\r\n\t\t\t<span class=\"code\" id=\"box1\"></span>\r\n\t\t\t</td><td style=\"width: 50%;\">\r\n\t\t\t<span class=\"barheading\">Autosizing elements</span> <br/>\r\n\t\t\t<div class=\"progressBar\">\r\n\t\t\t<div id=\"element4\" class=\"innerBar\">&nbsp;</div>\r\n\t\t\t</div>\r\n\t\t\t<span class=\"code\" id=\"box4\"></span>\r\n\t\t\t<br/><br/>\r\n\t\t\t<span class=\"barheading\">Writing Tables</span> <br/>\r\n\t\t\t<div class=\"progressBar\">\r\n\t\t\t<div id=\"element7\" class=\"innerBar\">&nbsp;</div>\r\n\t\t\t</div>\r\n\t\t\t<span class=\"code\" id=\"box7\"></span>\r\n\t\t\t</td></tr>\r\n\t\t\t<tr><td><br /><br /></td><td></td></tr>\r\n\t\t\t<tr><td style=\"width: 50%;\"> \r\n\t";
  1719. }
  1720.  
  1721. echo "\t\t\t<span class=\"barheading\">Writing PDF file</span> <br/>\r\n\t\t\t<div class=\"progressBar\">\r\n\t\t\t<div id=\"element2\" class=\"innerBar\">&nbsp;</div>\r\n\t\t\t</div>\r\n\t\t\t<span class=\"code\" id=\"box2\"></span>\r\n\t ";
  1722. if ($this->progressBar == 2) {
  1723. echo "\r\n\t\t\t</td><td style=\"width: 50%;\">\r\n\t\t\t<span class=\"barheading\">Memory usage</span> <br/>\r\n\t\t\t<div class=\"progressBar\">\r\n\t\t\t<div id=\"element5\" class=\"innerBar\">&nbsp;</div>\r\n\t\t\t</div>\r\n\t\t\t<span id=\"box5\">0</span> " . ini_get("memory_limit") . "<br />\r\n\t\t\t<br/><br/>\r\n\t\t\t<span class=\"barheading\">Memory usage (peak)</span> <br/>\r\n\t\t\t<div class=\"progressBar\">\r\n\t\t\t<div id=\"element6\" class=\"innerBar\">&nbsp;</div>\r\n\t\t\t</div>\r\n\t\t\t<span id=\"box6\">0</span> " . ini_get("memory_limit") . "<br />\r\n\t\t\t</td></tr>\r\n\t\t\t</table>\r\n\t ";
  1724. }
  1725.  
  1726. echo "\t\t\t<br/><br/>\r\n\t\t<span id=\"box3\"></span>\r\n\r\n\t\t</div>\r\n\t ";
  1727. }
  1728.  
  1729. ob_flush();
  1730. flush();
  1731. }
  1732.  
  1733. public function UpdateProgressBar($el, $val, $txt = "")
  1734. {
  1735. if ($this->progressBar < 2) {
  1736. if (3 < $el) {
  1737. return NULL;
  1738. }
  1739.  
  1740. if ($el == 1) {
  1741. $el = 2;
  1742. }
  1743.  
  1744. }
  1745.  
  1746. echo "<script type=\"text/javascript\">";
  1747. if ($val) {
  1748. echo " document.getElementById('element" . $el . "').style.width='" . $val . "%'; ";
  1749. }
  1750.  
  1751. if ($txt) {
  1752. echo " document.getElementById('box" . $el . "').innerHTML='" . $txt . "'; ";
  1753. }
  1754.  
  1755. if ($this->progressBar == 2) {
  1756. $m = round(memory_get_usage(true) / 1048576);
  1757. $m2 = round(memory_get_peak_usage(true) / 1048576);
  1758. $mem = ($m * 100) / (ini_get("memory_limit") + 0);
  1759. $mem2 = ($m2 * 100) / (ini_get("memory_limit") + 0);
  1760. echo " document.getElementById('element5').style.width='" . $mem . "%'; ";
  1761. echo " document.getElementById('element6').style.width='" . $mem2 . "%'; ";
  1762. echo " document.getElementById('box5').innerHTML='" . $m . "MB / '; ";
  1763. echo " document.getElementById('box6').innerHTML='" . $m2 . "MB / '; ";
  1764. }
  1765.  
  1766. echo "</script>" . "\n";
  1767. ob_flush();
  1768. flush();
  1769. }
  1770.  
  1771. public function RestrictUnicodeFonts($res)
  1772. {
  1773. if (count($res)) {
  1774. $this->available_unifonts = $res;
  1775. } else {
  1776. $this->available_unifonts = $this->default_available_fonts;
  1777. }
  1778.  
  1779. if (count($this->available_unifonts) == 0) {
  1780. $this->available_unifonts[] = $this->default_available_fonts[0];
  1781. }
  1782.  
  1783. $this->available_unifonts = array_values($this->available_unifonts);
  1784. }
  1785.  
  1786. public function setMBencoding($enc)
  1787. {
  1788. if ($this->mb_enc != $enc) {
  1789. $this->mb_enc = $enc;
  1790. mb_internal_encoding($this->mb_enc);
  1791. }
  1792.  
  1793. }
  1794.  
  1795. public function SetMargins($left, $right, $top)
  1796. {
  1797. $this->lMargin = $left;
  1798. $this->rMargin = $right;
  1799. $this->tMargin = $top;
  1800. }
  1801.  
  1802. public function ResetMargins()
  1803. {
  1804. if (($this->forcePortraitHeaders || $this->forcePortraitMargins) && $this->DefOrientation == "P" && $this->CurOrientation == "L") {
  1805. if ($this->mirrorMargins && $this->page % 2 == 0) {
  1806. $this->tMargin = $this->orig_rMargin;
  1807. $this->bMargin = $this->orig_lMargin;
  1808. } else {
  1809. $this->tMargin = $this->orig_lMargin;
  1810. $this->bMargin = $this->orig_rMargin;
  1811. }
  1812.  
  1813. $this->lMargin = $this->DeflMargin;
  1814. $this->rMargin = $this->DefrMargin;
  1815. $this->MarginCorrection = 0;
  1816. $this->PageBreakTrigger = $this->h - $this->bMargin;
  1817. } else {
  1818. if ($this->mirrorMargins && $this->page % 2 == 0) {
  1819. $this->lMargin = $this->DefrMargin;
  1820. $this->rMargin = $this->DeflMargin;
  1821. $this->MarginCorrection = $this->DefrMargin - $this->DeflMargin;
  1822. } else {
  1823. $this->lMargin = $this->DeflMargin;
  1824. $this->rMargin = $this->DefrMargin;
  1825. if ($this->mirrorMargins) {
  1826. $this->MarginCorrection = $this->DeflMargin - $this->DefrMargin;
  1827. }
  1828.  
  1829. }
  1830.  
  1831. }
  1832.  
  1833. $this->x = $this->lMargin;
  1834. }
  1835.  
  1836. public function SetLeftMargin($margin)
  1837. {
  1838. $this->lMargin = $margin;
  1839. if (0 < $this->page && $this->x < $margin) {
  1840. $this->x = $margin;
  1841. }
  1842.  
  1843. }
  1844.  
  1845. public function SetTopMargin($margin)
  1846. {
  1847. $this->tMargin = $margin;
  1848. }
  1849.  
  1850. public function SetRightMargin($margin)
  1851. {
  1852. $this->rMargin = $margin;
  1853. }
  1854.  
  1855. public function SetAutoPageBreak($auto, $margin = 0)
  1856. {
  1857. $this->autoPageBreak = $auto;
  1858. $this->bMargin = $margin;
  1859. $this->PageBreakTrigger = $this->h - $margin;
  1860. }
  1861.  
  1862. public function SetDisplayMode($zoom, $layout = "continuous")
  1863. {
  1864. if ($zoom == "fullpage" || $zoom == "fullwidth" || $zoom == "real" || $zoom == "default" || !is_string($zoom)) {
  1865. $this->ZoomMode = $zoom;
  1866. } else {
  1867. $this->Error("Incorrect zoom display mode: " . $zoom);
  1868. }
  1869.  
  1870. if ($layout == "single" || $layout == "continuous" || $layout == "two" || $layout == "twoleft" || $layout == "tworight" || $layout == "default") {
  1871. $this->LayoutMode = $layout;
  1872. } else {
  1873. $this->Error("Incorrect layout display mode: " . $layout);
  1874. }
  1875.  
  1876. }
  1877.  
  1878. public function SetCompression($compress)
  1879. {
  1880. if (function_exists("gzcompress")) {
  1881. $this->compress = $compress;
  1882. } else {
  1883. $this->compress = false;
  1884. }
  1885.  
  1886. }
  1887.  
  1888. public function SetTitle($title)
  1889. {
  1890. $this->title = $title;
  1891. }
  1892.  
  1893. public function SetSubject($subject)
  1894. {
  1895. $this->subject = $subject;
  1896. }
  1897.  
  1898. public function SetAuthor($author)
  1899. {
  1900. $this->author = $author;
  1901. }
  1902.  
  1903. public function SetKeywords($keywords)
  1904. {
  1905. $this->keywords = $keywords;
  1906. }
  1907.  
  1908. public function SetCreator($creator)
  1909. {
  1910. $this->creator = $creator;
  1911. }
  1912.  
  1913. public function SetAnchor2Bookmark($x)
  1914. {
  1915. $this->anchor2Bookmark = $x;
  1916. }
  1917.  
  1918. public function AliasNbPages($alias = "{nb}")
  1919. {
  1920. $this->aliasNbPg = $alias;
  1921. }
  1922.  
  1923. public function AliasNbPageGroups($alias = "{nbpg}")
  1924. {
  1925. $this->aliasNbPgGp = $alias;
  1926. }
  1927.  
  1928. public function SetAlpha($alpha, $bm = "Normal", $return = false, $mode = "B")
  1929. {
  1930. if (($this->PDFA || $this->PDFX) && $alpha != 1) {
  1931. if ($this->PDFA && !$this->PDFAauto || $this->PDFX && !$this->PDFXauto) {
  1932. $this->PDFAXwarnings[] = "Image opacity must be 100% (Opacity changed to 100%)";
  1933. }
  1934.  
  1935. $alpha = 1;
  1936. }
  1937.  
  1938. $a = array(
  1939. "BM" => "/" . $bm
  1940. );
  1941. if ($mode == "F" || ($mode = "B")) {
  1942. $a["ca"] = $alpha;
  1943. }
  1944.  
  1945. if ($mode == "S" || ($mode = "B")) {
  1946. $a["CA"] = $alpha;
  1947. }
  1948.  
  1949. $gs = $this->AddExtGState($a);
  1950. if ($return) {
  1951. return sprintf("/GS%d gs", $gs);
  1952. }
  1953.  
  1954. $this->_out(sprintf("/GS%d gs", $gs));
  1955. }
  1956.  
  1957. public function AddExtGState($parms)
  1958. {
  1959. $n = count($this->extgstates);
  1960. for ($i = 1; $i <= $n; $i++) {
  1961. if (count($this->extgstates[$i]["parms"]) == count($parms)) {
  1962. $same = true;
  1963. foreach ($this->extgstates[$i]["parms"] as $k => $v) {
  1964. if (!isset($parms[$k]) || $parms[$k] != $v) {
  1965. $same = false;
  1966. break;
  1967. }
  1968.  
  1969. }
  1970. if ($same) {
  1971. return $i;
  1972. }
  1973.  
  1974. }
  1975.  
  1976. }
  1977. $n++;
  1978. $this->extgstates[$n]["parms"] = $parms;
  1979. return $n;
  1980. }
  1981.  
  1982. public function SetVisibility($v)
  1983. {
  1984. if (($this->PDFA || $this->PDFX) && $this->visibility != "visible") {
  1985. $this->PDFAXwarnings[] = "Cannot set visibility to anything other than full when using PDFA or PDFX";
  1986. return "";
  1987. }
  1988.  
  1989. if (!$this->PDFA && !$this->PDFX) {
  1990. $this->pdf_version = "1.5";
  1991. }
  1992.  
  1993. if ($this->visibility != "visible") {
  1994. $this->_out("EMC");
  1995. $this->hasOC = true;
  1996. }
  1997.  
  1998. if ($v == "printonly") {
  1999. $this->_out("/OC /OC1 BDC");
  2000. } else {
  2001. if ($v == "screenonly") {
  2002. $this->_out("/OC /OC2 BDC");
  2003. } else {
  2004. if ($v == "hidden") {
  2005. $this->_out("/OC /OC3 BDC");
  2006. } else {
  2007. if ($v != "visible") {
  2008. $this->Error("Incorrect visibility: " . $v);
  2009. }
  2010.  
  2011. }
  2012.  
  2013. }
  2014.  
  2015. }
  2016.  
  2017. $this->visibility = $v;
  2018. }
  2019.  
  2020. public function Error($msg)
  2021. {
  2022. header("Content-Type: text/html; charset=utf-8");
  2023. exit("<B>mPDF error: </B>" . $msg);
  2024. }
  2025.  
  2026. public function Open()
  2027. {
  2028. if ($this->state == 0) {
  2029. $this->_begindoc();
  2030. }
  2031.  
  2032. }
  2033.  
  2034. public function Close()
  2035. {
  2036. if ($this->progressBar) {
  2037. $this->UpdateProgressBar(2, "2", "Closing last page");
  2038. }
  2039.  
  2040. if ($this->state == 3) {
  2041. return NULL;
  2042. }
  2043.  
  2044. if ($this->page == 0) {
  2045. $this->AddPage($this->CurOrientation);
  2046. }
  2047.  
  2048. if (count($this->cellBorderBuffer)) {
  2049. $this->printcellbuffer();
  2050. }
  2051.  
  2052. if ($this->tablebuffer) {
  2053. $this->printtablebuffer();
  2054. }
  2055.  
  2056. if ($this->ColActive) {
  2057. $this->SetColumns(0);
  2058. $this->ColActive = 0;
  2059. if (count($this->columnbuffer)) {
  2060. $this->printcolumnbuffer();
  2061. }
  2062.  
  2063. }
  2064.  
  2065. if (count($this->divbuffer)) {
  2066. $this->printdivbuffer();
  2067. }
  2068.  
  2069. $s = "";
  2070. $s .= $this->PrintBodyBackgrounds();
  2071. $s .= $this->PrintPageBackgrounds();
  2072. $this->pages[$this->page] = preg_replace("/(___BACKGROUND___PATTERNS" . date("jY") . ")/", "\n" . $s . "\n" . "\\1", $this->pages[$this->page]);
  2073. $this->pageBackgrounds = array();
  2074. if ($this->visibility != "visible") {
  2075. $this->SetVisibility("visible");
  2076. }
  2077.  
  2078. if (!$this->tocontents || !$this->tocontents->TOCmark) {
  2079. $this->InFooter = true;
  2080. $this->Footer();
  2081. $this->InFooter = false;
  2082. }
  2083.  
  2084. if ($this->tocontents && ($this->tocontents->TOCmark || count($this->tocontents->m_TOC))) {
  2085. $this->tocontents->insertTOC();
  2086. }
  2087.  
  2088. $this->_endpage();
  2089. $this->_enddoc();
  2090. }
  2091.  
  2092. public function _resizeBackgroundImage($imw, $imh, $cw, $ch, $resize = 0, $repx, $repy)
  2093. {
  2094. $cw = $cw * _MPDFK;
  2095. $ch = $ch * _MPDFK;
  2096. if (!$resize) {
  2097. return array(
  2098. $imw,
  2099. $imh,
  2100. $repx,
  2101. $repy
  2102. );
  2103. }
  2104.  
  2105. if ($resize == 1 && $cw < $imw) {
  2106. $h = ($imh * $cw) / $imw;
  2107. $repx = false;
  2108. return array(
  2109. $cw,
  2110. $h,
  2111. $repx,
  2112. $repy
  2113. );
  2114. }
  2115.  
  2116. if ($resize == 2 && $ch < $imh) {
  2117. $w = ($imw * $ch) / $imh;
  2118. $repy = false;
  2119. return array(
  2120. $w,
  2121. $ch,
  2122. $repx,
  2123. $repy
  2124. );
  2125. }
  2126.  
  2127. if ($resize == 3) {
  2128. $w = $imw;
  2129. $h = $imh;
  2130. $saverepx = $repx;
  2131. if ($cw < $w) {
  2132. $h = ($h * $cw) / $w;
  2133. $w = $cw;
  2134. $repx = false;
  2135. }
  2136.  
  2137. if ($ch < $h) {
  2138. $w = ($w * $ch) / $h;
  2139. $h = $ch;
  2140. $repy = false;
  2141. $repx = $saverepx;
  2142. }
  2143.  
  2144. return array(
  2145. $w,
  2146. $h,
  2147. $repx,
  2148. $repy
  2149. );
  2150. }
  2151.  
  2152. if ($resize == 4) {
  2153. $h = ($imh * $cw) / $imw;
  2154. $repx = false;
  2155. return array(
  2156. $cw,
  2157. $h,
  2158. $repx,
  2159. $repy
  2160. );
  2161. }
  2162.  
  2163. if ($resize == 5) {
  2164. $w = ($imw * $ch) / $imh;
  2165. $repy = false;
  2166. return array(
  2167. $w,
  2168. $ch,
  2169. $repx,
  2170. $repy
  2171. );
  2172. }
  2173.  
  2174. if ($resize == 6) {
  2175. $repx = false;
  2176. $repy = false;
  2177. return array(
  2178. $cw,
  2179. $ch,
  2180. $repx,
  2181. $repy
  2182. );
  2183. }
  2184.  
  2185. return array(
  2186. $imw,
  2187. $imh,
  2188. $repx,
  2189. $repy
  2190. );
  2191. }
  2192.  
  2193. public function SetBackground(&$properties, &$maxwidth)
  2194. {
  2195. if (preg_match("/(-moz-)*(repeating-)*(linear|radial)-gradient/", $properties["BACKGROUND-IMAGE"])) {
  2196. return array(
  2197. "gradient" => $properties["BACKGROUND-IMAGE"]
  2198. );
  2199. }
  2200.  
  2201. $file = $properties["BACKGROUND-IMAGE"];
  2202. $sizesarray = $this->Image($file, 0, 0, 0, 0, "", "", false, false, false, false, true);
  2203. if (isset($sizesarray["IMAGE_ID"])) {
  2204. $image_id = $sizesarray["IMAGE_ID"];
  2205. $orig_w = $sizesarray["WIDTH"] * _MPDFK;
  2206. $orig_h = $sizesarray["HEIGHT"] * _MPDFK;
  2207. if (isset($properties["BACKGROUND-IMAGE-RESOLUTION"])) {
  2208. if (preg_match("/from-image/i", $properties["BACKGROUND-IMAGE-RESOLUTION"]) && isset($sizesarray["set-dpi"]) && 0 < $sizesarray["set-dpi"]) {
  2209. $orig_w *= $this->img_dpi / $sizesarray["set-dpi"];
  2210. $orig_h *= $this->img_dpi / $sizesarray["set-dpi"];
  2211. } else {
  2212. if (preg_match("/(\\d+)dpi/i", $properties["BACKGROUND-IMAGE-RESOLUTION"], $m)) {
  2213. $dpi = $m[1];
  2214. if (0 < $dpi) {
  2215. $orig_w *= $this->img_dpi / $dpi;
  2216. $orig_h *= $this->img_dpi / $dpi;
  2217. }
  2218.  
  2219. }
  2220.  
  2221. }
  2222.  
  2223. }
  2224.  
  2225. $x_repeat = true;
  2226. $y_repeat = true;
  2227. if (isset($properties["BACKGROUND-REPEAT"])) {
  2228. if ($properties["BACKGROUND-REPEAT"] == "no-repeat" || $properties["BACKGROUND-REPEAT"] == "repeat-x") {
  2229. $y_repeat = false;
  2230. }
  2231.  
  2232. if ($properties["BACKGROUND-REPEAT"] == "no-repeat" || $properties["BACKGROUND-REPEAT"] == "repeat-y") {
  2233. $x_repeat = false;
  2234. }
  2235.  
  2236. }
  2237.  
  2238. $x_pos = 0;
  2239. $y_pos = 0;
  2240. if (isset($properties["BACKGROUND-POSITION"])) {
  2241. $ppos = preg_split("/\\s+/", $properties["BACKGROUND-POSITION"]);
  2242. list($x_pos, $y_pos) = $ppos;
  2243. if (!stristr($x_pos, "%")) {
  2244. $x_pos = $this->ConvertSize($x_pos, $maxwidth, $this->FontSize);
  2245. }
  2246.  
  2247. if (!stristr($y_pos, "%")) {
  2248. $y_pos = $this->ConvertSize($y_pos, $maxwidth, $this->FontSize);
  2249. }
  2250.  
  2251. }
  2252.  
  2253. if (isset($properties["BACKGROUND-IMAGE-RESIZE"])) {
  2254. $resize = $properties["BACKGROUND-IMAGE-RESIZE"];
  2255. } else {
  2256. $resize = 0;
  2257. }
  2258.  
  2259. if (isset($properties["BACKGROUND-IMAGE-OPACITY"])) {
  2260. $opacity = $properties["BACKGROUND-IMAGE-OPACITY"];
  2261. } else {
  2262. $opacity = 1;
  2263. }
  2264.  
  2265. return array(
  2266. "image_id" => $image_id,
  2267. "orig_w" => $orig_w,
  2268. "orig_h" => $orig_h,
  2269. "x_pos" => $x_pos,
  2270. "y_pos" => $y_pos,
  2271. "x_repeat" => $x_repeat,
  2272. "y_repeat" => $y_repeat,
  2273. "resize" => $resize,
  2274. "opacity" => $opacity,
  2275. "itype" => $sizesarray["itype"]
  2276. );
  2277. }
  2278.  
  2279. return false;
  2280. }
  2281.  
  2282. public function PrintBodyBackgrounds()
  2283. {
  2284. $s = "";
  2285. $clx = 0;
  2286. $cly = 0;
  2287. $clw = $this->w;
  2288. $clh = $this->h;
  2289. if ($this->pageDim[$this->page]["outer_width_LR"] || $this->pageDim[$this->page]["outer_width_TB"]) {
  2290. $clx = $this->pageDim[$this->page]["outer_width_LR"] - $this->pageDim[$this->page]["bleedMargin"];
  2291. $cly = $this->pageDim[$this->page]["outer_width_TB"] - $this->pageDim[$this->page]["bleedMargin"];
  2292. $clw = $this->w - 2 * $clx;
  2293. $clh = $this->h - 2 * $cly;
  2294. }
  2295.  
  2296. if ($this->bodyBackgroundColor) {
  2297. $s .= "q " . $this->SetFColor($this->bodyBackgroundColor, true) . "\n";
  2298. if ($this->bodyBackgroundColor[0] == 5) {
  2299. $s .= $this->SetAlpha(ord($this->bodyBackgroundColor[4]) / 100, "Normal", true, "F") . "\n";
  2300. } else {
  2301. if ($this->bodyBackgroundColor[0] == 6) {
  2302. $s .= $this->SetAlpha(ord($this->bodyBackgroundColor[5]) / 100, "Normal", true, "F") . "\n";
  2303. }
  2304.  
  2305. }
  2306.  
  2307. $s .= sprintf("%.3F %.3F %.3F %.3F re f Q", $clx * _MPDFK, $cly * _MPDFK, $clw * _MPDFK, $clh * _MPDFK) . "\n";
  2308. }
  2309.  
  2310. if ($this->bodyBackgroundGradient) {
  2311. $g = $this->grad->parseBackgroundGradient($this->bodyBackgroundGradient);
  2312. if ($g) {
  2313. $s .= $this->grad->Gradient($clx, $cly, $clw, $clh, (isset($g["gradtype"]) ? $g["gradtype"] : NULL), $g["stops"], $g["colorspace"], $g["coords"], $g["extend"], true);
  2314. }
  2315.  
  2316. }
  2317.  
  2318. if ($this->bodyBackgroundImage) {
  2319. if ($this->bodyBackgroundImage["gradient"] && preg_match("/(-moz-)*(repeating-)*(linear|radial)-gradient/", $this->bodyBackgroundImage["gradient"])) {
  2320. $g = $this->grad->parseMozGradient($this->bodyBackgroundImage["gradient"]);
  2321. if ($g) {
  2322. $s .= $this->grad->Gradient($clx, $cly, $clw, $clh, $g["type"], $g["stops"], $g["colorspace"], $g["coords"], $g["extend"], true);
  2323. }
  2324.  
  2325. } else {
  2326. if ($this->bodyBackgroundImage["image_id"]) {
  2327. $n = count($this->patterns) + 1;
  2328. list($orig_w, $orig_h, $x_repeat, $y_repeat) = $this->_resizeBackgroundImage($this->bodyBackgroundImage["orig_w"], $this->bodyBackgroundImage["orig_h"], $clw, $clh, $this->bodyBackgroundImage["resize"], $this->bodyBackgroundImage["x_repeat"], $this->bodyBackgroundImage["y_repeat"]);
  2329. $this->patterns[$n] = array(
  2330. "x" => $clx,
  2331. "y" => $cly,
  2332. "w" => $clw,
  2333. "h" => $clh,
  2334. "pgh" => $this->h,
  2335. "image_id" => $this->bodyBackgroundImage["image_id"],
  2336. "orig_w" => $orig_w,
  2337. "orig_h" => $orig_h,
  2338. "x_pos" => $this->bodyBackgroundImage["x_pos"],
  2339. "y_pos" => $this->bodyBackgroundImage["y_pos"],
  2340. "x_repeat" => $x_repeat,
  2341. "y_repeat" => $y_repeat,
  2342. "itype" => $this->bodyBackgroundImage["itype"]
  2343. );
  2344. if ((0 < $this->bodyBackgroundImage["opacity"] || $this->bodyBackgroundImage["opacity"] === "0") && $this->bodyBackgroundImage["opacity"] < 1) {
  2345. $opac = $this->SetAlpha($this->bodyBackgroundImage["opacity"], "Normal", true);
  2346. } else {
  2347. $opac = "";
  2348. }
  2349.  
  2350. $s .= sprintf("q /Pattern cs /P%d scn %s %.3F %.3F %.3F %.3F re f Q", $n, $opac, $clx * _MPDFK, $cly * _MPDFK, $clw * _MPDFK, $clh * _MPDFK) . "\n";
  2351. }
  2352.  
  2353. }
  2354.  
  2355. }
  2356.  
  2357. return $s;
  2358. }
  2359.  
  2360. public function PrintPageBackgrounds($adjustmenty = 0)
  2361. {
  2362. $s = "";
  2363. ksort($this->pageBackgrounds);
  2364. foreach ($this->pageBackgrounds as $bl => $pbs) {
  2365. foreach ($pbs as $pb) {
  2366. if (!isset($pb["image_id"]) && !isset($pb["gradient"]) || isset($pb["shadowonly"])) {
  2367. if ($pb["visibility"] != "visible") {
  2368. if ($pb["visibility"] == "printonly") {
  2369. $s .= "/OC /OC1 BDC" . "\n";
  2370. } else {
  2371. if ($pb["visibility"] == "screenonly") {
  2372. $s .= "/OC /OC2 BDC" . "\n";
  2373. } else {
  2374. if ($pb["visibility"] == "hidden") {
  2375. $s .= "/OC /OC3 BDC" . "\n";
  2376. }
  2377.  
  2378. }
  2379.  
  2380. }
  2381.  
  2382. }
  2383.  
  2384. if (isset($pb["shadow"]) && $pb["shadow"]) {
  2385. $s .= $pb["shadow"] . "\n";
  2386. }
  2387.  
  2388. if (isset($pb["clippath"]) && $pb["clippath"]) {
  2389. $s .= $pb["clippath"] . "\n";
  2390. }
  2391.  
  2392. $s .= "q " . $this->SetFColor($pb["col"], true) . "\n";
  2393. if ($pb["col"][0] == 5) {
  2394. $s .= $this->SetAlpha(ord($pb["col"][4]) / 100, "Normal", true, "F") . "\n";
  2395. } else {
  2396. if ($pb["col"][0] == 6) {
  2397. $s .= $this->SetAlpha(ord($pb["col"][5]) / 100, "Normal", true, "F") . "\n";
  2398. }
  2399.  
  2400. }
  2401.  
  2402. $s .= sprintf("%.3F %.3F %.3F %.3F re f Q", $pb["x"] * _MPDFK, ($this->h - $pb["y"]) * _MPDFK, $pb["w"] * _MPDFK, (0 - $pb["h"]) * _MPDFK) . "\n";
  2403. if (isset($pb["clippath"]) && $pb["clippath"]) {
  2404. $s .= "Q" . "\n";
  2405. }
  2406.  
  2407. if ($pb["visibility"] != "visible") {
  2408. $s .= "EMC" . "\n";
  2409. }
  2410.  
  2411. }
  2412.  
  2413. }
  2414. foreach ($pbs as $pb) {
  2415. if ($pb["visibility"] != "visible") {
  2416. if ($pb["visibility"] == "printonly") {
  2417. $s .= "/OC /OC1 BDC" . "\n";
  2418. } else {
  2419. if ($pb["visibility"] == "screenonly") {
  2420. $s .= "/OC /OC2 BDC" . "\n";
  2421. } else {
  2422. if ($pb["visibility"] == "hidden") {
  2423. $s .= "/OC /OC3 BDC" . "\n";
  2424. }
  2425.  
  2426. }
  2427.  
  2428. }
  2429.  
  2430. }
  2431.  
  2432. if (isset($pb["gradient"]) && $pb["gradient"]) {
  2433. if (isset($pb["clippath"]) && $pb["clippath"]) {
  2434. $s .= $pb["clippath"] . "\n";
  2435. }
  2436.  
  2437. $s .= $this->grad->Gradient($pb["x"], $pb["y"], $pb["w"], $pb["h"], $pb["gradtype"], $pb["stops"], $pb["colorspace"], $pb["coords"], $pb["extend"], true);
  2438. if (isset($pb["clippath"]) && $pb["clippath"]) {
  2439. $s .= "Q" . "\n";
  2440. }
  2441.  
  2442. } else {
  2443. if (isset($pb["image_id"]) && $pb["image_id"]) {
  2444. $pb["y"] -= $adjustmenty;
  2445. $pb["h"] += $adjustmenty;
  2446. $n = count($this->patterns) + 1;
  2447. list($orig_w, $orig_h, $x_repeat, $y_repeat) = $this->_resizeBackgroundImage($pb["orig_w"], $pb["orig_h"], $pb["w"], $pb["h"], $pb["resize"], $pb["x_repeat"], $pb["y_repeat"]);
  2448. $this->patterns[$n] = array(
  2449. "x" => $pb["x"],
  2450. "y" => $pb["y"],
  2451. "w" => $pb["w"],
  2452. "h" => $pb["h"],
  2453. "pgh" => $this->h,
  2454. "image_id" => $pb["image_id"],
  2455. "orig_w" => $orig_w,
  2456. "orig_h" => $orig_h,
  2457. "x_pos" => $pb["x_pos"],
  2458. "y_pos" => $pb["y_pos"],
  2459. "x_repeat" => $x_repeat,
  2460. "y_repeat" => $y_repeat,
  2461. "itype" => $pb["itype"]
  2462. );
  2463. $x = $pb["x"] * _MPDFK;
  2464. $y = ($this->h - $pb["y"]) * _MPDFK;
  2465. $w = $pb["w"] * _MPDFK;
  2466. $h = (0 - $pb["h"]) * _MPDFK;
  2467. if (isset($pb["clippath"]) && $pb["clippath"]) {
  2468. $s .= $pb["clippath"] . "\n";
  2469. }
  2470.  
  2471. if ($this->writingHTMLfooter || $this->writingHTMLheader) {
  2472. $iw = $pb["orig_w"] / _MPDFK;
  2473. $ih = $pb["orig_h"] / _MPDFK;
  2474. $w = $pb["w"];
  2475. $h = $pb["h"];
  2476. $x0 = $pb["x"];
  2477. $y0 = $pb["y"];
  2478. if ($pb["x_repeat"]) {
  2479. $nx = ceil($w / $iw);
  2480. } else {
  2481. $nx = 1;
  2482. }
  2483.  
  2484. if ($pb["y_repeat"]) {
  2485. $ny = ceil($h / $ih);
  2486. } else {
  2487. $ny = 1;
  2488. }
  2489.  
  2490. $x_pos = $pb["x_pos"];
  2491. if (stristr($x_pos, "%")) {
  2492. $x_pos += 0;
  2493. $x_pos /= 100;
  2494. $x_pos = $w * $x_pos - $iw * $x_pos;
  2495. }
  2496.  
  2497. $y_pos = $pb["y_pos"];
  2498. if (stristr($y_pos, "%")) {
  2499. $y_pos += 0;
  2500. $y_pos /= 100;
  2501. $y_pos = $h * $y_pos - $ih * $y_pos;
  2502. }
  2503.  
  2504. if (1 < $nx) {
  2505. while (0 < $x_pos) {
  2506. $x_pos -= $iw;
  2507. }
  2508. }
  2509.  
  2510. if (1 < $ny) {
  2511. while (0 < $y_pos) {
  2512. $y_pos -= $ih;
  2513. }
  2514. }
  2515.  
  2516. for ($xi = 0; $xi < $nx; $xi++) {
  2517. for ($yi = 0; $yi < $ny; $yi++) {
  2518. $x = $x0 + $x_pos + $iw * $xi;
  2519. $y = $y0 + $y_pos + $ih * $yi;
  2520. if (0 < $pb["opacity"] && $pb["opacity"] < 1) {
  2521. $opac = $this->SetAlpha($pb["opacity"], "Normal", true);
  2522. } else {
  2523. $opac = "";
  2524. }
  2525.  
  2526. $s .= sprintf("q %s %.3F 0 0 %.3F %.3F %.3F cm /I%d Do Q", $opac, $iw * _MPDFK, $ih * _MPDFK, $x * _MPDFK, ($this->h - ($y + $ih)) * _MPDFK, $pb["image_id"]) . "\n";
  2527. }
  2528. }
  2529. } else {
  2530. if ((0 < $pb["opacity"] || $pb["opacity"] === "0") && $pb["opacity"] < 1) {
  2531. $opac = $this->SetAlpha($pb["opacity"], "Normal", true);
  2532. } else {
  2533. $opac = "";
  2534. }
  2535.  
  2536. $s .= sprintf("q /Pattern cs /P%d scn %s %.3F %.3F %.3F %.3F re f Q", $n, $opac, $x, $y, $w, $h) . "\n";
  2537. }
  2538.  
  2539. if (isset($pb["clippath"]) && $pb["clippath"]) {
  2540. $s .= "Q" . "\n";
  2541. }
  2542.  
  2543. }
  2544.  
  2545. }
  2546.  
  2547. if ($pb["visibility"] != "visible") {
  2548. $s .= "EMC" . "\n";
  2549. }
  2550.  
  2551. }
  2552. }
  2553. return $s;
  2554. }
  2555.  
  2556. public function PrintTableBackgrounds($adjustmenty = 0)
  2557. {
  2558. $s = "";
  2559. ksort($this->tableBackgrounds);
  2560. foreach ($this->tableBackgrounds as $bl => $pbs) {
  2561. foreach ($pbs as $pb) {
  2562. if ((!isset($pb["gradient"]) || !$pb["gradient"]) && (!isset($pb["image_id"]) || !$pb["image_id"])) {
  2563. $s .= "q " . $this->SetFColor($pb["col"], true) . "\n";
  2564. if ($pb["col"][0] == 5) {
  2565. $s .= $this->SetAlpha(ord($pb["col"][4]) / 100, "Normal", true, "F") . "\n";
  2566. } else {
  2567. if ($pb["col"][0] == 6) {
  2568. $s .= $this->SetAlpha(ord($pb["col"][5]) / 100, "Normal", true, "F") . "\n";
  2569. }
  2570.  
  2571. }
  2572.  
  2573. $s .= sprintf("%.3F %.3F %.3F %.3F re %s Q", $pb["x"] * _MPDFK, ($this->h - $pb["y"]) * _MPDFK, $pb["w"] * _MPDFK, (0 - $pb["h"]) * _MPDFK, "f") . "\n";
  2574. }
  2575.  
  2576. if (isset($pb["gradient"]) && $pb["gradient"]) {
  2577. if (isset($pb["clippath"]) && $pb["clippath"]) {
  2578. $s .= $pb["clippath"] . "\n";
  2579. }
  2580.  
  2581. $s .= $this->grad->Gradient($pb["x"], $pb["y"], $pb["w"], $pb["h"], $pb["gradtype"], $pb["stops"], $pb["colorspace"], $pb["coords"], $pb["extend"], true);
  2582. if (isset($pb["clippath"]) && $pb["clippath"]) {
  2583. $s .= "Q" . "\n";
  2584. }
  2585.  
  2586. }
  2587.  
  2588. if (isset($pb["image_id"]) && $pb["image_id"]) {
  2589. $pb["y"] -= $adjustmenty;
  2590. $pb["h"] += $adjustmenty;
  2591. $n = count($this->patterns) + 1;
  2592. list($orig_w, $orig_h, $x_repeat, $y_repeat) = $this->_resizeBackgroundImage($pb["orig_w"], $pb["orig_h"], $pb["w"], $pb["h"], $pb["resize"], $pb["x_repeat"], $pb["y_repeat"]);
  2593. $this->patterns[$n] = array(
  2594. "x" => $pb["x"],
  2595. "y" => $pb["y"],
  2596. "w" => $pb["w"],
  2597. "h" => $pb["h"],
  2598. "pgh" => $this->h,
  2599. "image_id" => $pb["image_id"],
  2600. "orig_w" => $orig_w,
  2601. "orig_h" => $orig_h,
  2602. "x_pos" => $pb["x_pos"],
  2603. "y_pos" => $pb["y_pos"],
  2604. "x_repeat" => $x_repeat,
  2605. "y_repeat" => $y_repeat,
  2606. "itype" => $pb["itype"]
  2607. );
  2608. $x = $pb["x"] * _MPDFK;
  2609. $y = ($this->h - $pb["y"]) * _MPDFK;
  2610. $w = $pb["w"] * _MPDFK;
  2611. $h = (0 - $pb["h"]) * _MPDFK;
  2612. if (isset($pb["clippath"]) && $pb["clippath"]) {
  2613. $s .= $pb["clippath"] . "\n";
  2614. }
  2615.  
  2616. if (0 < $pb["opacity"] && $pb["opacity"] < 1) {
  2617. $opac = $this->SetAlpha($pb["opacity"], "Normal", true);
  2618. } else {
  2619. $opac = "";
  2620. }
  2621.  
  2622. $s .= sprintf("q /Pattern cs /P%d scn %s %.3F %.3F %.3F %.3F re f Q", $n, $opac, $x, $y, $w, $h) . "\n";
  2623. if (isset($pb["clippath"]) && $pb["clippath"]) {
  2624. $s .= "Q" . "\n";
  2625. }
  2626.  
  2627. }
  2628.  
  2629. }
  2630. }
  2631. return $s;
  2632. }
  2633.  
  2634. public function AddPages($orientation = "", $condition = "", $resetpagenum = "", $pagenumstyle = "", $suppress = "", $mgl = "", $mgr = "", $mgt = "", $mgb = "", $mgh = "", $mgf = "", $ohname = "", $ehname = "", $ofname = "", $efname = "", $ohvalue = 0, $ehvalue = 0, $ofvalue = 0, $efvalue = 0, $pagesel = "", $newformat = "")
  2635. {
  2636. $this->AddPage($orientation, $condition, $resetpagenum, $pagenumstyle, $suppress, $mgl, $mgr, $mgt, $mgb, $mgh, $mgf, $ohname, $ehname, $ofname, $efname, $ohvalue, $ehvalue, $ofvalue, $efvalue, $pagesel, $newformat);
  2637. }
  2638.  
  2639. public function AddPageByArray($a)
  2640. {
  2641. if (!is_array($a)) {
  2642. $a = array();
  2643. }
  2644.  
  2645. $orientation = (isset($a["orientation"]) ? $a["orientation"] : "");
  2646. $condition = (isset($a["condition"]) ? $a["condition"] : (isset($a["type"]) ? $a["type"] : ""));
  2647. $resetpagenum = (isset($a["resetpagenum"]) ? $a["resetpagenum"] : "");
  2648. $pagenumstyle = (isset($a["pagenumstyle"]) ? $a["pagenumstyle"] : "");
  2649. $suppress = (isset($a["suppress"]) ? $a["suppress"] : "");
  2650. $mgl = (isset($a["mgl"]) ? $a["mgl"] : (isset($a["margin-left"]) ? $a["margin-left"] : ""));
  2651. $mgr = (isset($a["mgr"]) ? $a["mgr"] : (isset($a["margin-right"]) ? $a["margin-right"] : ""));
  2652. $mgt = (isset($a["mgt"]) ? $a["mgt"] : (isset($a["margin-top"]) ? $a["margin-top"] : ""));
  2653. $mgb = (isset($a["mgb"]) ? $a["mgb"] : (isset($a["margin-bottom"]) ? $a["margin-bottom"] : ""));
  2654. $mgh = (isset($a["mgh"]) ? $a["mgh"] : (isset($a["margin-header"]) ? $a["margin-header"] : ""));
  2655. $mgf = (isset($a["mgf"]) ? $a["mgf"] : (isset($a["margin-footer"]) ? $a["margin-footer"] : ""));
  2656. $ohname = (isset($a["ohname"]) ? $a["ohname"] : (isset($a["odd-header-name"]) ? $a["odd-header-name"] : ""));
  2657. $ehname = (isset($a["ehname"]) ? $a["ehname"] : (isset($a["even-header-name"]) ? $a["even-header-name"] : ""));
  2658. $ofname = (isset($a["ofname"]) ? $a["ofname"] : (isset($a["odd-footer-name"]) ? $a["odd-footer-name"] : ""));
  2659. $efname = (isset($a["efname"]) ? $a["efname"] : (isset($a["even-footer-name"]) ? $a["even-footer-name"] : ""));
  2660. $ohvalue = (isset($a["ohvalue"]) ? $a["ohvalue"] : (isset($a["odd-header-value"]) ? $a["odd-header-value"] : 0));
  2661. $ehvalue = (isset($a["ehvalue"]) ? $a["ehvalue"] : (isset($a["even-header-value"]) ? $a["even-header-value"] : 0));
  2662. $ofvalue = (isset($a["ofvalue"]) ? $a["ofvalue"] : (isset($a["odd-footer-value"]) ? $a["odd-footer-value"] : 0));
  2663. $efvalue = (isset($a["efvalue"]) ? $a["efvalue"] : (isset($a["even-footer-value"]) ? $a["even-footer-value"] : 0));
  2664. $pagesel = (isset($a["pagesel"]) ? $a["pagesel"] : (isset($a["pageselector"]) ? $a["pageselector"] : ""));
  2665. $newformat = (isset($a["newformat"]) ? $a["newformat"] : (isset($a["sheet-size"]) ? $a["sheet-size"] : ""));
  2666. $this->AddPage($orientation, $condition, $resetpagenum, $pagenumstyle, $suppress, $mgl, $mgr, $mgt, $mgb, $mgh, $mgf, $ohname, $ehname, $ofname, $efname, $ohvalue, $ehvalue, $ofvalue, $efvalue, $pagesel, $newformat);
  2667. }
  2668.  
  2669. public function AddPage($orientation = "", $condition = "", $resetpagenum = "", $pagenumstyle = "", $suppress = "", $mgl = "", $mgr = "", $mgt = "", $mgb = "", $mgh = "", $mgf = "", $ohname = "", $ehname = "", $ofname = "", $efname = "", $ohvalue = 0, $ehvalue = 0, $ofvalue = 0, $efvalue = 0, $pagesel = "", $newformat = "")
  2670. {
  2671. if (0 < $this->state && $this->page < count($this->pages)) {
  2672. $bak_cml = $this->cMarginL;
  2673. $bak_cmr = $this->cMarginR;
  2674. $bak_dw = $this->divwidth;
  2675. if (0 < $this->blklvl) {
  2676. $save_tr = $this->table_rotate;
  2677. $this->table_rotate = 0;
  2678. if ($this->y == $this->blk[$this->blklvl]["y0"]) {
  2679. $this->blk[$this->blklvl]["startpage"]++;
  2680. }
  2681.  
  2682. if ($this->blk[$this->blklvl]["y0"] < $this->y || $this->flowingBlockAttr["is_table"]) {
  2683. $toplvl = $this->blklvl;
  2684. } else {
  2685. $toplvl = $this->blklvl - 1;
  2686. }
  2687.  
  2688. $sy = $this->y;
  2689. for ($bl = 1; $bl <= $toplvl; $bl++) {
  2690. $this->PaintDivBB("pagebottom", 0, $bl);
  2691. }
  2692. $this->y = $sy;
  2693. $this->table_rotate = $save_tr;
  2694. }
  2695.  
  2696. $s = $this->PrintPageBackgrounds();
  2697. $this->pages[$this->page] = preg_replace("/(___BACKGROUND___PATTERNS" . date("jY") . ")/", "\\1" . "\n" . $s . "\n", $this->pages[$this->page]);
  2698. $this->pageBackgrounds = array();
  2699. $family = $this->FontFamily;
  2700. $style = $this->FontStyle . (($this->U ? "U" : "")) . (($this->S ? "S" : ""));
  2701. $size = $this->FontSizePt;
  2702. $lw = $this->LineWidth;
  2703. $dc = $this->DrawColor;
  2704. $fc = $this->FillColor;
  2705. $tc = $this->TextColor;
  2706. $cf = $this->ColorFlag;
  2707. $this->printfloatbuffer();
  2708. $this->page++;
  2709. $this->ResetMargins();
  2710. $this->SetAutoPageBreak($this->autoPageBreak, $this->bMargin);
  2711. $this->x = $this->lMargin;
  2712. $this->y = $this->tMargin;
  2713. $this->FontFamily = "";
  2714. $this->_out("2 J");
  2715. $this->LineWidth = $lw;
  2716. $this->_out(sprintf("%.3F w", $lw * _MPDFK));
  2717. if ($family) {
  2718. $this->SetFont($family, $style, $size, true, true);
  2719. }
  2720.  
  2721. $this->DrawColor = $dc;
  2722. if ($dc != $this->defDrawColor) {
  2723. $this->_out($dc);
  2724. }
  2725.  
  2726. $this->FillColor = $fc;
  2727. if ($fc != $this->defFillColor) {
  2728. $this->_out($fc);
  2729. }
  2730.  
  2731. $this->TextColor = $tc;
  2732. $this->ColorFlag = $cf;
  2733. for ($bl = 1; $bl <= $this->blklvl; $bl++) {
  2734. $this->blk[$bl]["y0"] = $this->y;
  2735. if (!isset($this->blk[$bl]["marginCorrected"][$this->page])) {
  2736. $this->blk[$bl]["x0"] += $this->MarginCorrection;
  2737. }
  2738.  
  2739. $this->blk[$bl]["marginCorrected"][$this->page] = true;
  2740. }
  2741. $this->cMarginL = $bak_cml;
  2742. $this->cMarginR = $bak_cmr;
  2743. $this->divwidth = $bak_dw;
  2744. return "";
  2745. }
  2746.  
  2747. if ($this->state == 0) {
  2748. $this->Open();
  2749. }
  2750.  
  2751. $bak_cml = $this->cMarginL;
  2752. $bak_cmr = $this->cMarginR;
  2753. $bak_dw = $this->divwidth;
  2754. $bak_lh = $this->lineheight;
  2755. $orientation = substr(strtoupper($orientation), 0, 1);
  2756. $condition = strtoupper($condition);
  2757. if ($condition == "NEXT-EVEN") {
  2758. if (!$this->mirrorMargins) {
  2759. $condition = "";
  2760. } else {
  2761. if ($pagesel) {
  2762. $pbch = $pagesel;
  2763. $pagesel = "";
  2764. } else {
  2765. $pbch = false;
  2766. }
  2767.  
  2768. $this->AddPage($this->CurOrientation, "O");
  2769. if ($pbch) {
  2770. $pagesel = $pbch;
  2771. }
  2772.  
  2773. $condition = "";
  2774. }
  2775.  
  2776. }
  2777.  
  2778. if ($condition == "NEXT-ODD") {
  2779. if (!$this->mirrorMargins) {
  2780. $condition = "";
  2781. } else {
  2782. if ($pagesel) {
  2783. $pbch = $pagesel;
  2784. $pagesel = "";
  2785. } else {
  2786. $pbch = false;
  2787. }
  2788.  
  2789. $this->AddPage($this->CurOrientation, "E");
  2790. if ($pbch) {
  2791. $pagesel = $pbch;
  2792. }
  2793.  
  2794. $condition = "";
  2795. }
  2796.  
  2797. }
  2798.  
  2799. if ($condition == "E" && (!$this->mirrorMargins || $this->page % 2 == 0)) {
  2800. return false;
  2801. }
  2802.  
  2803. if ($condition == "O" && (!$this->mirrorMargins || $this->page % 2 == 1)) {
  2804. return false;
  2805. }
  2806.  
  2807. if ($resetpagenum || $pagenumstyle || $suppress) {
  2808. $this->PageNumSubstitutions[] = array(
  2809. "from" => $this->page + 1,
  2810. "reset" => $resetpagenum,
  2811. "type" => $pagenumstyle,
  2812. "suppress" => $suppress
  2813. );
  2814. }
  2815.  
  2816. $save_tr = $this->table_rotate;
  2817. $this->table_rotate = 0;
  2818. $save_kwt = $this->kwt;
  2819. $this->kwt = 0;
  2820. if (!$this->ColActive && 0 < $this->blklvl) {
  2821. if (isset($this->blk[$this->blklvl]["y0"]) && $this->y == $this->blk[$this->blklvl]["y0"]) {
  2822. if (isset($this->blk[$this->blklvl]["startpage"])) {
  2823. $this->blk[$this->blklvl]["startpage"]++;
  2824. } else {
  2825. $this->blk[$this->blklvl]["startpage"] = 1;
  2826. }
  2827.  
  2828. }
  2829.  
  2830. if (isset($this->blk[$this->blklvl]["y0"]) && $this->blk[$this->blklvl]["y0"] < $this->y || $this->flowingBlockAttr["is_table"]) {
  2831. $toplvl = $this->blklvl;
  2832. } else {
  2833. $toplvl = $this->blklvl - 1;
  2834. }
  2835.  
  2836. $sy = $this->y;
  2837. for ($bl = 1; $bl <= $toplvl; $bl++) {
  2838. $this->PaintDivBB("pagebottom", 0, $bl);
  2839. }
  2840. $this->y = $sy;
  2841. }
  2842.  
  2843. if (0 < $this->page) {
  2844. $s = "";
  2845. $s .= $this->PrintBodyBackgrounds();
  2846. $s .= $this->PrintPageBackgrounds();
  2847. $this->pages[$this->page] = preg_replace("/(___BACKGROUND___PATTERNS" . date("jY") . ")/", "\n" . $s . "\n" . "\\1", $this->pages[$this->page]);
  2848. $this->pageBackgrounds = array();
  2849. }
  2850.  
  2851. $save_kt = $this->keep_block_together;
  2852. $this->keep_block_together = 0;
  2853. $save_cols = false;
  2854. if ($this->ColActive) {
  2855. $save_cols = true;
  2856. $save_nbcol = $this->NbCol;
  2857. $this->SetColumns(0);
  2858. }
  2859.  
  2860. $save_vis = $this->visibility;
  2861. if ($this->visibility != "visible") {
  2862. $this->SetVisibility("visible");
  2863. }
  2864.  
  2865. $family = $this->FontFamily;
  2866. $style = $this->FontStyle . (($this->U ? "U" : "")) . (($this->S ? "S" : ""));
  2867. $size = $this->FontSizePt;
  2868. $this->ColumnAdjust = true;
  2869. $lw = $this->LineWidth;
  2870. $dc = $this->DrawColor;
  2871. $fc = $this->FillColor;
  2872. $tc = $this->TextColor;
  2873. $cf = $this->ColorFlag;
  2874. if (0 < $this->page) {
  2875. $this->InFooter = true;
  2876. $this->Reset();
  2877. $this->pageoutput[$this->page] = array();
  2878. $this->Footer();
  2879. $this->_endpage();
  2880. }
  2881.  
  2882. $this->_beginpage($orientation, $mgl, $mgr, $mgt, $mgb, $mgh, $mgf, $ohname, $ehname, $ofname, $efname, $ohvalue, $ehvalue, $ofvalue, $efvalue, $pagesel, $newformat);
  2883. if ($this->docTemplate) {
  2884. $pagecount = $this->SetSourceFile($this->docTemplate);
  2885. if ($pagecount < $this->page - $this->docTemplateStart) {
  2886. if ($this->docTemplateContinue) {
  2887. $tplIdx = $this->ImportPage($pagecount);
  2888. $this->UseTemplate($tplIdx);
  2889. }
  2890.  
  2891. } else {
  2892. $tplIdx = $this->ImportPage($this->page - $this->docTemplateStart);
  2893. $this->UseTemplate($tplIdx);
  2894. }
  2895.  
  2896. }
  2897.  
  2898. if ($this->pageTemplate) {
  2899. $this->UseTemplate($this->pageTemplate);
  2900. }
  2901.  
  2902. $this->_out("___PAGE___START" . date("jY"));
  2903. $this->_out("___BACKGROUND___PATTERNS" . date("jY"));
  2904. $this->_out("___HEADER___MARKER" . date("jY"));
  2905. $this->pageBackgrounds = array();
  2906. $this->SetLineCap(2);
  2907. $this->LineWidth = $lw;
  2908. $this->_out(sprintf("%.3F w", $lw * _MPDFK));
  2909. if ($family) {
  2910. $this->SetFont($family, $style, $size, true, true);
  2911. }
  2912.  
  2913. $this->DrawColor = $dc;
  2914. if ($dc != $this->defDrawColor) {
  2915. $this->_out($dc);
  2916. }
  2917.  
  2918. $this->FillColor = $fc;
  2919. if ($fc != $this->defFillColor) {
  2920. $this->_out($fc);
  2921. }
  2922.  
  2923. $this->TextColor = $tc;
  2924. $this->ColorFlag = $cf;
  2925. $this->Header();
  2926. if ($this->LineWidth != $lw) {
  2927. $this->LineWidth = $lw;
  2928. $this->_out(sprintf("%.3F w", $lw * _MPDFK));
  2929. }
  2930.  
  2931. if ($family) {
  2932. $this->SetFont($family, $style, $size, true, true);
  2933. }
  2934.  
  2935. if ($this->DrawColor != $dc) {
  2936. $this->DrawColor = $dc;
  2937. $this->_out($dc);
  2938. }
  2939.  
  2940. if ($this->FillColor != $fc) {
  2941. $this->FillColor = $fc;
  2942. $this->_out($fc);
  2943. }
  2944.  
  2945. $this->TextColor = $tc;
  2946. $this->ColorFlag = $cf;
  2947. $this->InFooter = false;
  2948. if ($save_vis != "visible") {
  2949. $this->SetVisibility($save_vis);
  2950. }
  2951.  
  2952. if ($save_cols) {
  2953. $this->SetColumns($save_nbcol, $this->colvAlign, $this->ColGap);
  2954. }
  2955.  
  2956. if ($this->ColActive) {
  2957. $this->SetCol(0);
  2958. }
  2959.  
  2960. if (!$this->ColActive) {
  2961. for ($bl = 1; $bl <= $this->blklvl; $bl++) {
  2962. $this->blk[$bl]["y0"] = $this->y;
  2963. if (isset($this->blk[$bl]["x0"])) {
  2964. $this->blk[$bl]["x0"] += $this->MarginCorrection;
  2965. } else {
  2966. $this->blk[$bl]["x0"] = $this->MarginCorrection;
  2967. }
  2968.  
  2969. $this->blk[$bl]["marginCorrected"][$this->page] = true;
  2970. }
  2971. }
  2972.  
  2973. $this->table_rotate = $save_tr;
  2974. $this->kwt = $save_kwt;
  2975. $this->keep_block_together = $save_kt;
  2976. $this->cMarginL = $bak_cml;
  2977. $this->cMarginR = $bak_cmr;
  2978. $this->divwidth = $bak_dw;
  2979. $this->lineheight = $bak_lh;
  2980. }
  2981.  
  2982. public function PageNo()
  2983. {
  2984. return $this->page;
  2985. }
  2986.  
  2987. public function AddSpotColorsFromFile($file)
  2988. {
  2989. $colors = @file($file) or exit("Cannot load spot colors file - " . $file);
  2990. foreach ($colors as $sc) {
  2991. list($name, $c, $m, $y, $k) = preg_split("/\t/", $sc);
  2992. $c = intval($c);
  2993. $m = intval($m);
  2994. $y = intval($y);
  2995. $k = intval($k);
  2996. $this->AddSpotColor($name, $c, $m, $y, $k);
  2997. }
  2998. }
  2999.  
  3000. public function AddSpotColor($name, $c, $m, $y, $k)
  3001. {
  3002. $name = strtoupper(trim($name));
  3003. if (!isset($this->spotColors[$name])) {
  3004. $i = count($this->spotColors) + 1;
  3005. $this->spotColors[$name] = array(
  3006. "i" => $i,
  3007. "c" => $c,
  3008. "m" => $m,
  3009. "y" => $y,
  3010. "k" => $k
  3011. );
  3012. $this->spotColorIDs[$i] = $name;
  3013. }
  3014.  
  3015. }
  3016.  
  3017. public function SetColor($col, $type = "")
  3018. {
  3019. $out = "";
  3020. if ($col[0] == 3 || $col[0] == 5) {
  3021. $out = sprintf("%.3F %.3F %.3F rg", ord($col[1]) / 255, ord($col[2]) / 255, ord($col[3]) / 255);
  3022. } else {
  3023. if ($col[0] == 1) {
  3024. $out = sprintf("%.3F g", ord($col[1]) / 255);
  3025. } else {
  3026. if ($col[0] == 2) {
  3027. $out = sprintf("/CS%d cs %.3F scn", ord($col[1]), ord($col[2]) / 100);
  3028. } else {
  3029. if ($col[0] == 4 || $col[0] == 6) {
  3030. $out = sprintf("%.3F %.3F %.3F %.3F k", ord($col[1]) / 100, ord($col[2]) / 100, ord($col[3]) / 100, ord($col[4]) / 100);
  3031. }
  3032.  
  3033. }
  3034.  
  3035. }
  3036.  
  3037. }
  3038.  
  3039. if ($type == "Draw") {
  3040. $out = strtoupper($out);
  3041. } else {
  3042. if ($type == "CodeOnly") {
  3043. $out = preg_replace("/\\s(rg|g|k)/", "", $out);
  3044. }
  3045.  
  3046. }
  3047.  
  3048. return $out;
  3049. }
  3050.  
  3051. public function SetDColor($col, $return = false)
  3052. {
  3053. $out = $this->SetColor($col, "Draw");
  3054. if ($return) {
  3055. return $out;
  3056. }
  3057.  
  3058. if ($out == "") {
  3059. return "";
  3060. }
  3061.  
  3062. $this->DrawColor = $out;
  3063. if (0 < $this->page && (isset($this->pageoutput[$this->page]["DrawColor"]) && $this->pageoutput[$this->page]["DrawColor"] != $this->DrawColor || !isset($this->pageoutput[$this->page]["DrawColor"]) || $this->keep_block_together)) {
  3064. $this->_out($this->DrawColor);
  3065. }
  3066.  
  3067. $this->pageoutput[$this->page]["DrawColor"] = $this->DrawColor;
  3068. }
  3069.  
  3070. public function SetFColor($col, $return = false)
  3071. {
  3072. $out = $this->SetColor($col, "Fill");
  3073. if ($return) {
  3074. return $out;
  3075. }
  3076.  
  3077. if ($out == "") {
  3078. return "";
  3079. }
  3080.  
  3081. $this->FillColor = $out;
  3082. $this->ColorFlag = $out != $this->TextColor;
  3083. if (0 < $this->page && (isset($this->pageoutput[$this->page]["FillColor"]) && $this->pageoutput[$this->page]["FillColor"] != $this->FillColor || !isset($this->pageoutput[$this->page]["FillColor"]) || $this->keep_block_together)) {
  3084. $this->_out($this->FillColor);
  3085. }
  3086.  
  3087. $this->pageoutput[$this->page]["FillColor"] = $this->FillColor;
  3088. }
  3089.  
  3090. public function SetTColor($col, $return = false)
  3091. {
  3092. $out = $this->SetColor($col, "Text");
  3093. if ($return) {
  3094. return $out;
  3095. }
  3096.  
  3097. if ($out == "") {
  3098. return "";
  3099. }
  3100.  
  3101. $this->TextColor = $out;
  3102. $this->ColorFlag = $this->FillColor != $out;
  3103. }
  3104.  
  3105. public function SetDrawColor($r, $g = -1, $b = -1, $col4 = -1, $return = false)
  3106. {
  3107. $col = array();
  3108. if ($r == 0 && $g == 0 && $b == 0 && $col4 == -1 || $g == -1) {
  3109. $col = $this->ConvertColor($r);
  3110. } else {
  3111. if ($col4 == -1) {
  3112. $col = $this->ConvertColor("rgb(" . $r . "," . $g . "," . $b . ")");
  3113. } else {
  3114. $col = $this->ConvertColor("cmyk(" . $r . "," . $g . "," . $b . "," . $col4 . ")");
  3115. }
  3116.  
  3117. }
  3118.  
  3119. $out = $this->SetDColor($col, $return);
  3120. return $out;
  3121. }
  3122.  
  3123. public function SetFillColor($r, $g = -1, $b = -1, $col4 = -1, $return = false)
  3124. {
  3125. $col = array();
  3126. if ($r == 0 && $g == 0 && $b == 0 && $col4 == -1 || $g == -1) {
  3127. $col = $this->ConvertColor($r);
  3128. } else {
  3129. if ($col4 == -1) {
  3130. $col = $this->ConvertColor("rgb(" . $r . "," . $g . "," . $b . ")");
  3131. } else {
  3132. $col = $this->ConvertColor("cmyk(" . $r . "," . $g . "," . $b . "," . $col4 . ")");
  3133. }
  3134.  
  3135. }
  3136.  
  3137. $out = $this->SetFColor($col, $return);
  3138. return $out;
  3139. }
  3140.  
  3141. public function SetTextColor($r, $g = -1, $b = -1, $col4 = -1, $return = false)
  3142. {
  3143. $col = array();
  3144. if ($r == 0 && $g == 0 && $b == 0 && $col4 == -1 || $g == -1) {
  3145. $col = $this->ConvertColor($r);
  3146. } else {
  3147. if ($col4 == -1) {
  3148. $col = $this->ConvertColor("rgb(" . $r . "," . $g . "," . $b . ")");
  3149. } else {
  3150. $col = $this->ConvertColor("cmyk(" . $r . "," . $g . "," . $b . "," . $col4 . ")");
  3151. }
  3152.  
  3153. }
  3154.  
  3155. $out = $this->SetTColor($col, $return);
  3156. return $out;
  3157. }
  3158.  
  3159. public function _getCharWidth(&$cw, $u, $isdef = true)
  3160. {
  3161. if ($u == 0) {
  3162. $w = false;
  3163. } else {
  3164. $w = (ord($cw[$u * 2]) << 8) + ord($cw[$u * 2 + 1]);
  3165. }
  3166.  
  3167. if ($w == 65535) {
  3168. return 0;
  3169. }
  3170.  
  3171. if ($w) {
  3172. return $w;
  3173. }
  3174.  
  3175. if ($isdef) {
  3176. return false;
  3177. }
  3178.  
  3179. return 0;
  3180. }
  3181.  
  3182. public function _charDefined(&$cw, $u)
  3183. {
  3184. if ($u == 0) {
  3185. return false;
  3186. }
  3187.  
  3188. $w = (ord($cw[$u * 2]) << 8) + ord($cw[$u * 2 + 1]);
  3189. if ($w) {
  3190. return true;
  3191. }
  3192.  
  3193. return false;
  3194. }
  3195.  
  3196. public function GetCharWidthCore($c)
  3197. {
  3198. $c = (string) $c;
  3199. $w = 0;
  3200. if ($c == chr(173) && $this->FontFamily != "csymbol" && $this->FontFamily != "czapfdingbats") {
  3201. return 0;
  3202. }
  3203.  
  3204. if ($this->S && isset($this->upperCase[ord($c)])) {
  3205. $charw = $this->CurrentFont["cw"][chr($this->upperCase[ord($c)])];
  3206. if ($charw !== false) {
  3207. $charw = ($charw * $this->smCapsScale * $this->smCapsStretch) / 100;
  3208. $w += $charw;
  3209. }
  3210.  
  3211. } else {
  3212. if (isset($this->CurrentFont["cw"][$c])) {
  3213. $w += $this->CurrentFont["cw"][$c];
  3214. } else {
  3215. if (isset($this->CurrentFont["cw"][ord($c)])) {
  3216. $w += $this->CurrentFont["cw"][ord($c)];
  3217. }
  3218.  
  3219. }
  3220.  
  3221. }
  3222.  
  3223. $w *= $this->FontSize / 1000;
  3224. if ($this->minwSpacing || $this->fixedlSpacing) {
  3225. if ($c == " ") {
  3226. $nb_spaces = 1;
  3227. } else {
  3228. $nb_spaces = 0;
  3229. }
  3230.  
  3231. $w += $this->fixedlSpacing + $nb_spaces * $this->minwSpacing;
  3232. }
  3233.  
  3234. return $w;
  3235. }
  3236.  
  3237. public function GetCharWidthNonCore($c, $addSubset = true)
  3238. {
  3239. $c = (string) $c;
  3240. $w = 0;
  3241. $unicode = $this->UTF8StringToArray($c, $addSubset);
  3242. $char = $unicode[0];
  3243. if ($this->CurrentFont["type"] == "Type0") {
  3244. if ($char == 173) {
  3245. return 0;
  3246. }
  3247.  
  3248. if (isset($this->CurrentFont["cw"][$char])) {
  3249. $w += $this->CurrentFont["cw"][$char];
  3250. } else {
  3251. if (isset($this->CurrentFont["MissingWidth"])) {
  3252. $w += $this->CurrentFont["MissingWidth"];
  3253. } else {
  3254. $w += 500;
  3255. }
  3256.  
  3257. }
  3258.  
  3259. } else {
  3260. if ($char == 173) {
  3261. ....................................................................
  3262. .........................................
  3263. ..............
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement