7 * The root of your DOMPDF installation
14 * The location of a temporary directory.
16 * The directory specified must be writeable by the webserver process.
17 * The temporary directory is required to download remote images and when
18 * using the PFDLib back end.
25 * The location of the DOMPDF font directory
27 * The location of the directory where DOMPDF will store fonts and font metrics
28 * Note: This directory must exist and be writable by the webserver process.
35 * The location of the DOMPDF font cache directory
37 * This directory contains the cached font metrics for the fonts used by DOMPDF.
38 * This directory can be the same as $fontDir
40 * Note: This directory must exist and be writable by the webserver process.
49 * Prevents dompdf from accessing system files or other files on the webserver.
50 * All local files opened by dompdf must be in a subdirectory of this directory.
51 * DO NOT set it to '/' since this could allow an attacker to use dompdf to
52 * read any files on the server. This should be an absolute path.
55 * This setting may increase the risk of system exploit. Do not change
56 * this settings without understanding the consequences. Additional
57 * documentation is available on the dompdf wiki at:
58 * https://github.com/dompdf/dompdf/wiki
67 private $logOutputFile;
70 * html target media view which should be rendered into pdf.
71 * List of types and parsing rules for future extensions:
72 * http://www.w3.org/TR/REC-html40/types.html
73 * screen, tty, tv, projection, handheld, print, braille, aural, all
74 * Note: aural is deprecated in CSS 2.1 because it is replaced by speech in CSS 3.
75 * Note, even though the generated pdf file is intended for print output,
76 * the desired content might be different (e.g. screen or projection view of html file).
77 * Therefore allow specification of content here.
81 private $defaultMediaType = "screen";
84 * The default paper size.
86 * North America standard is "letter"; other countries generally "a4"
87 * @see Dompdf\Adapter\CPDF::PAPER_SIZES for valid sizes
91 private $defaultPaperSize = "letter";
94 * The default font family
96 * Used if no suitable fonts can be found. This must exist in the font folder.
100 private $defaultFont = "serif";
105 * This setting determines the default DPI setting for images and fonts. The
106 * DPI may be overridden for inline images by explictly setting the
107 * image's width & height style attributes (i.e. if the image's native
108 * width is 600 pixels and you specify the image's width as 72 points,
109 * the image will have a DPI of 600 in the rendered PDF. The DPI of
110 * background images can not be overridden and is controlled entirely
111 * via this parameter.
113 * For the purposes of DOMPDF, pixels per inch (PPI) = dots per inch (DPI).
114 * If a size in html is given as px (or without unit as image size),
115 * this tells the corresponding size in pt at 72 DPI.
116 * This adjusts the relative sizes to be similar to the rendering of the
117 * html page in a reference browser.
119 * In pdf, always 1 pt = 1/72 inch
126 * A ratio applied to the fonts height to be more like browsers' line height
130 private $fontHeightRatio = 1.1;
133 * Enable embedded PHP
135 * If this setting is set to true then DOMPDF will automatically evaluate
136 * embedded PHP contained within <script type="text/php"> ... </script> tags.
138 * ==== IMPORTANT ====
139 * Enabling this for documents you do not trust (e.g. arbitrary remote html
140 * pages) is a security risk. Embedded scripts are run with the same level of
141 * system access available to dompdf. Set this option to false (recommended)
142 * if you wish to process untrusted documents.
144 * This setting may increase the risk of system exploit. Do not change
145 * this settings without understanding the consequences. Additional
146 * documentation is available on the dompdf wiki at:
147 * https://github.com/dompdf/dompdf/wiki
151 private $isPhpEnabled = false;
154 * Enable remote file access
156 * If this setting is set to true, DOMPDF will access remote sites for
157 * images and CSS files as required.
159 * ==== IMPORTANT ====
160 * This can be a security risk, in particular in combination with isPhpEnabled and
161 * allowing remote html code to be passed to $dompdf = new DOMPDF(); $dompdf->load_html(...);
162 * This allows anonymous users to download legally doubtful internet content which on
163 * tracing back appears to being downloaded by your server, or allows malicious php code
164 * in remote html pages to be executed by your server with your account privileges.
166 * This setting may increase the risk of system exploit. Do not change
167 * this settings without understanding the consequences. Additional
168 * documentation is available on the dompdf wiki at:
169 * https://github.com/dompdf/dompdf/wiki
173 private $isRemoteEnabled = false;
176 * Enable inline Javascript
178 * If this setting is set to true then DOMPDF will automatically insert
179 * JavaScript code contained within <script type="text/javascript"> ... </script> tags.
183 private $isJavascriptEnabled = true;
186 * Use the more-than-experimental HTML5 Lib parser
190 private $isHtml5ParserEnabled = false;
193 * Whether to enable font subsetting or not.
197 private $isFontSubsettingEnabled = false;
202 private $debugPng = false;
207 private $debugKeepTemp = false;
212 private $debugCss = false;
217 private $debugLayout = false;
222 private $debugLayoutLines = true;
227 private $debugLayoutBlocks = true;
232 private $debugLayoutInline = true;
237 private $debugLayoutPaddingBox = true;
240 * The PDF rendering backend to use
242 * Valid settings are 'PDFLib', 'CPDF', 'GD', and 'auto'. 'auto' will
243 * look for PDFLib and use it if found, or if not it will fall back on
244 * CPDF. 'GD' renders PDFs to graphic files. {@link Dompdf\CanvasFactory}
245 * ultimately determines which rendering class to instantiate
246 * based on this setting.
250 private $pdfBackend = "CPDF";
255 * If you are using a licensed, commercial version of PDFlib, specify
256 * your license key here. If you are using PDFlib-Lite or are evaluating
257 * the commercial version of PDFlib, comment out this setting.
259 * @link http://www.pdflib.com
261 * If pdflib present in web server and auto or selected explicitely above,
262 * a real license code must exist!
266 private $pdflibLicense = "";
272 private $adminUsername = "user";
278 private $adminPassword = "password";
281 * @param array $attributes
283 public function __construct(array $attributes = null)
285 $this->setChroot(realpath(__DIR__
. "/../"));
286 $this->setRootDir($this->getChroot());
287 $this->setTempDir(sys_get_temp_dir());
288 $this->setFontDir($this->chroot
. DIRECTORY_SEPARATOR
. "lib" . DIRECTORY_SEPARATOR
. "fonts");
289 $this->setFontCache($this->getFontDir());
290 $this->setLogOutputFile($this->getTempDir() . DIRECTORY_SEPARATOR
. "log.htm");
292 if (null !== $attributes) {
293 $this->set($attributes);
298 * @param array|string $attributes
299 * @param null|mixed $value
302 public function set($attributes, $value = null)
304 if (!is_array($attributes)) {
305 $attributes = array($attributes => $value);
307 foreach ($attributes as $key => $value) {
308 if ($key === 'tempDir' ||
$key === 'temp_dir') {
309 $this->setTempDir($value);
310 } elseif ($key === 'fontDir' ||
$key === 'font_dir') {
311 $this->setFontDir($value);
312 } elseif ($key === 'fontCache' ||
$key === 'font_cache') {
313 $this->setFontCache($value);
314 } elseif ($key === 'chroot') {
315 $this->setChroot($value);
316 } elseif ($key === 'logOutputFile' ||
$key === 'log_output_file') {
317 $this->setLogOutputFile($value);
318 } elseif ($key === 'defaultMediaType' ||
$key === 'default_media_type') {
319 $this->setDefaultMediaType($value);
320 } elseif ($key === 'defaultPaperSize' ||
$key === 'default_paper_size') {
321 $this->setDefaultPaperSize($value);
322 } elseif ($key === 'defaultFont' ||
$key === 'default_font') {
323 $this->setDefaultFont($value);
324 } elseif ($key === 'dpi') {
325 $this->setDpi($value);
326 } elseif ($key === 'fontHeightRatio' ||
$key === 'font_height_ratio') {
327 $this->setFontHeightRatio($value);
328 } elseif ($key === 'isPhpEnabled' ||
$key === 'is_php_enabled' ||
$key === 'enable_php') {
329 $this->setIsPhpEnabled($value);
330 } elseif ($key === 'isRemoteEnabled' ||
$key === 'is_remote_enabled' ||
$key === 'enable_remote') {
331 $this->setIsRemoteEnabled($value);
332 } elseif ($key === 'isJavascriptEnabled' ||
$key === 'is_javascript_enabled' ||
$key === 'enable_javascript') {
333 $this->setIsJavascriptEnabled($value);
334 } elseif ($key === 'isHtml5ParserEnabled' ||
$key === 'is_html5_parser_enabled' ||
$key === 'enable_html5_parser') {
335 $this->setIsHtml5ParserEnabled($value);
336 } elseif ($key === 'isFontSubsettingEnabled' ||
$key === 'is_font_subsetting_enabled' ||
$key === 'enable_font_subsetting') {
337 $this->setIsFontSubsettingEnabled($value);
338 } elseif ($key === 'debugPng' ||
$key === 'debug_png') {
339 $this->setDebugPng($value);
340 } elseif ($key === 'debugKeepTemp' ||
$key === 'debug_keep_temp') {
341 $this->setDebugKeepTemp($value);
342 } elseif ($key === 'debugCss' ||
$key === 'debug_css') {
343 $this->setDebugCss($value);
344 } elseif ($key === 'debugLayout' ||
$key === 'debug_layout') {
345 $this->setDebugLayout($value);
346 } elseif ($key === 'debugLayoutLines' ||
$key === 'debug_layout_lines') {
347 $this->setDebugLayoutLines($value);
348 } elseif ($key === 'debugLayoutBlocks' ||
$key === 'debug_layout_blocks') {
349 $this->setDebugLayoutBlocks($value);
350 } elseif ($key === 'debugLayoutInline' ||
$key === 'debug_layout_inline') {
351 $this->setDebugLayoutInline($value);
352 } elseif ($key === 'debugLayoutPaddingBox' ||
$key === 'debug_layout_padding_box') {
353 $this->setDebugLayoutPaddingBox($value);
354 } elseif ($key === 'pdfBackend' ||
$key === 'pdf_backend') {
355 $this->setPdfBackend($value);
356 } elseif ($key === 'pdflibLicense' ||
$key === 'pdflib_license') {
357 $this->setPdflibLicense($value);
358 } elseif ($key === 'adminUsername' ||
$key === 'admin_username') {
359 $this->setAdminUsername($value);
360 } elseif ($key === 'adminPassword' ||
$key === 'admin_password') {
361 $this->setAdminPassword($value);
371 public function get($key)
373 if ($key === 'tempDir' ||
$key === 'temp_dir') {
374 return $this->getTempDir();
375 } elseif ($key === 'fontDir' ||
$key === 'font_dir') {
376 return $this->getFontDir();
377 } elseif ($key === 'fontCache' ||
$key === 'font_cache') {
378 return $this->getFontCache();
379 } elseif ($key === 'chroot') {
380 return $this->getChroot();
381 } elseif ($key === 'logOutputFile' ||
$key === 'log_output_file') {
382 return $this->getLogOutputFile();
383 } elseif ($key === 'defaultMediaType' ||
$key === 'default_media_type') {
384 return $this->getDefaultMediaType();
385 } elseif ($key === 'defaultPaperSize' ||
$key === 'default_paper_size') {
386 return $this->getDefaultPaperSize();
387 } elseif ($key === 'defaultFont' ||
$key === 'default_font') {
388 return $this->getDefaultFont();
389 } elseif ($key === 'dpi') {
390 return $this->getDpi();
391 } elseif ($key === 'fontHeightRatio' ||
$key === 'font_height_ratio') {
392 return $this->getFontHeightRatio();
393 } elseif ($key === 'isPhpEnabled' ||
$key === 'is_php_enabled' ||
$key === 'enable_php') {
394 return $this->getIsPhpEnabled();
395 } elseif ($key === 'isRemoteEnabled' ||
$key === 'is_remote_enabled' ||
$key === 'enable_remote') {
396 return $this->getIsRemoteEnabled();
397 } elseif ($key === 'isJavascriptEnabled' ||
$key === 'is_javascript_enabled' ||
$key === 'enable_javascript') {
398 return $this->getIsJavascriptEnabled();
399 } elseif ($key === 'isHtml5ParserEnabled' ||
$key === 'is_html5_parser_enabled' ||
$key === 'enable_html5_parser') {
400 return $this->getIsHtml5ParserEnabled();
401 } elseif ($key === 'isFontSubsettingEnabled' ||
$key === 'is_font_subsetting_enabled' ||
$key === 'enable_font_subsetting') {
402 return $this->getIsFontSubsettingEnabled();
403 } elseif ($key === 'debugPng' ||
$key === 'debug_png') {
404 return $this->getDebugPng();
405 } elseif ($key === 'debugKeepTemp' ||
$key === 'debug_keep_temp') {
406 return $this->getDebugKeepTemp();
407 } elseif ($key === 'debugCss' ||
$key === 'debug_css') {
408 return $this->getDebugCss();
409 } elseif ($key === 'debugLayout' ||
$key === 'debug_layout') {
410 return $this->getDebugLayout();
411 } elseif ($key === 'debugLayoutLines' ||
$key === 'debug_layout_lines') {
412 return $this->getDebugLayoutLines();
413 } elseif ($key === 'debugLayoutBlocks' ||
$key === 'debug_layout_blocks') {
414 return $this->getDebugLayoutBlocks();
415 } elseif ($key === 'debugLayoutInline' ||
$key === 'debug_layout_inline') {
416 return $this->getDebugLayoutInline();
417 } elseif ($key === 'debugLayoutPaddingBox' ||
$key === 'debug_layout_padding_box') {
418 return $this->getDebugLayoutPaddingBox();
419 } elseif ($key === 'pdfBackend' ||
$key === 'pdf_backend') {
420 return $this->getPdfBackend();
421 } elseif ($key === 'pdflibLicense' ||
$key === 'pdflib_license') {
422 return $this->getPdflibLicense();
423 } elseif ($key === 'adminUsername' ||
$key === 'admin_username') {
424 return $this->getAdminUsername();
425 } elseif ($key === 'adminPassword' ||
$key === 'admin_password') {
426 return $this->getAdminPassword();
432 * @param string $adminPassword
435 public function setAdminPassword($adminPassword)
437 $this->adminPassword
= $adminPassword;
444 public function getAdminPassword()
446 return $this->adminPassword
;
450 * @param string $adminUsername
453 public function setAdminUsername($adminUsername)
455 $this->adminUsername
= $adminUsername;
462 public function getAdminUsername()
464 return $this->adminUsername
;
468 * @param string $pdfBackend
471 public function setPdfBackend($pdfBackend)
473 $this->pdfBackend
= $pdfBackend;
480 public function getPdfBackend()
482 return $this->pdfBackend
;
486 * @param string $pdflibLicense
489 public function setPdflibLicense($pdflibLicense)
491 $this->pdflibLicense
= $pdflibLicense;
498 public function getPdflibLicense()
500 return $this->pdflibLicense
;
504 * @param string $chroot
507 public function setChroot($chroot)
509 $this->chroot
= $chroot;
516 public function getChroot()
518 return $this->chroot
;
522 * @param boolean $debugCss
525 public function setDebugCss($debugCss)
527 $this->debugCss
= $debugCss;
534 public function getDebugCss()
536 return $this->debugCss
;
540 * @param boolean $debugKeepTemp
543 public function setDebugKeepTemp($debugKeepTemp)
545 $this->debugKeepTemp
= $debugKeepTemp;
552 public function getDebugKeepTemp()
554 return $this->debugKeepTemp
;
558 * @param boolean $debugLayout
561 public function setDebugLayout($debugLayout)
563 $this->debugLayout
= $debugLayout;
570 public function getDebugLayout()
572 return $this->debugLayout
;
576 * @param boolean $debugLayoutBlocks
579 public function setDebugLayoutBlocks($debugLayoutBlocks)
581 $this->debugLayoutBlocks
= $debugLayoutBlocks;
588 public function getDebugLayoutBlocks()
590 return $this->debugLayoutBlocks
;
594 * @param boolean $debugLayoutInline
597 public function setDebugLayoutInline($debugLayoutInline)
599 $this->debugLayoutInline
= $debugLayoutInline;
606 public function getDebugLayoutInline()
608 return $this->debugLayoutInline
;
612 * @param boolean $debugLayoutLines
615 public function setDebugLayoutLines($debugLayoutLines)
617 $this->debugLayoutLines
= $debugLayoutLines;
624 public function getDebugLayoutLines()
626 return $this->debugLayoutLines
;
630 * @param boolean $debugLayoutPaddingBox
633 public function setDebugLayoutPaddingBox($debugLayoutPaddingBox)
635 $this->debugLayoutPaddingBox
= $debugLayoutPaddingBox;
642 public function getDebugLayoutPaddingBox()
644 return $this->debugLayoutPaddingBox
;
648 * @param boolean $debugPng
651 public function setDebugPng($debugPng)
653 $this->debugPng
= $debugPng;
660 public function getDebugPng()
662 return $this->debugPng
;
666 * @param string $defaultFont
669 public function setDefaultFont($defaultFont)
671 $this->defaultFont
= $defaultFont;
678 public function getDefaultFont()
680 return $this->defaultFont
;
684 * @param string $defaultMediaType
687 public function setDefaultMediaType($defaultMediaType)
689 $this->defaultMediaType
= $defaultMediaType;
696 public function getDefaultMediaType()
698 return $this->defaultMediaType
;
702 * @param string $defaultPaperSize
705 public function setDefaultPaperSize($defaultPaperSize)
707 $this->defaultPaperSize
= $defaultPaperSize;
714 public function getDefaultPaperSize()
716 return $this->defaultPaperSize
;
723 public function setDpi($dpi)
732 public function getDpi()
738 * @param string $fontCache
741 public function setFontCache($fontCache)
743 $this->fontCache
= $fontCache;
750 public function getFontCache()
752 return $this->fontCache
;
756 * @param string $fontDir
759 public function setFontDir($fontDir)
761 $this->fontDir
= $fontDir;
768 public function getFontDir()
770 return $this->fontDir
;
774 * @param float $fontHeightRatio
777 public function setFontHeightRatio($fontHeightRatio)
779 $this->fontHeightRatio
= $fontHeightRatio;
786 public function getFontHeightRatio()
788 return $this->fontHeightRatio
;
792 * @param boolean $isFontSubsettingEnabled
795 public function setIsFontSubsettingEnabled($isFontSubsettingEnabled)
797 $this->isFontSubsettingEnabled
= $isFontSubsettingEnabled;
804 public function getIsFontSubsettingEnabled()
806 return $this->isFontSubsettingEnabled
;
812 public function isFontSubsettingEnabled()
814 return $this->getIsFontSubsettingEnabled();
818 * @param boolean $isHtml5ParserEnabled
821 public function setIsHtml5ParserEnabled($isHtml5ParserEnabled)
823 $this->isHtml5ParserEnabled
= $isHtml5ParserEnabled;
830 public function getIsHtml5ParserEnabled()
832 return $this->isHtml5ParserEnabled
;
838 public function isHtml5ParserEnabled()
840 return $this->getIsHtml5ParserEnabled();
844 * @param boolean $isJavascriptEnabled
847 public function setIsJavascriptEnabled($isJavascriptEnabled)
849 $this->isJavascriptEnabled
= $isJavascriptEnabled;
856 public function getIsJavascriptEnabled()
858 return $this->isJavascriptEnabled
;
864 public function isJavascriptEnabled()
866 return $this->getIsJavascriptEnabled();
870 * @param boolean $isPhpEnabled
873 public function setIsPhpEnabled($isPhpEnabled)
875 $this->isPhpEnabled
= $isPhpEnabled;
882 public function getIsPhpEnabled()
884 return $this->isPhpEnabled
;
890 public function isPhpEnabled()
892 return $this->getIsPhpEnabled();
896 * @param boolean $isRemoteEnabled
899 public function setIsRemoteEnabled($isRemoteEnabled)
901 $this->isRemoteEnabled
= $isRemoteEnabled;
908 public function getIsRemoteEnabled()
910 return $this->isRemoteEnabled
;
916 public function isRemoteEnabled()
918 return $this->getIsRemoteEnabled();
922 * @param string $logOutputFile
925 public function setLogOutputFile($logOutputFile)
927 $this->logOutputFile
= $logOutputFile;
934 public function getLogOutputFile()
936 return $this->logOutputFile
;
940 * @param string $tempDir
943 public function setTempDir($tempDir)
945 $this->tempDir
= $tempDir;
952 public function getTempDir()
954 return $this->tempDir
;
958 * @param string $rootDir
961 public function setRootDir($rootDir)
963 $this->rootDir
= $rootDir;
970 public function getRootDir()
972 return $this->rootDir
;