You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

dompdf.php 11KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267
  1. <?php
  2. return [
  3. /*
  4. |--------------------------------------------------------------------------
  5. | Settings
  6. |--------------------------------------------------------------------------
  7. |
  8. | Set some default values. It is possible to add all defines that can be set
  9. | in dompdf_config.inc.php. You can also override the entire config file.
  10. |
  11. */
  12. 'show_warnings' => false, // Throw an Exception on warnings from dompdf
  13. 'public_path' => null, // Override the public path if needed
  14. /*
  15. * Dejavu Sans font is missing glyphs for converted entities, turn it off if you need to show € and £.
  16. */
  17. 'convert_entities' => true,
  18. 'options' => [
  19. /**
  20. * The location of the DOMPDF font directory
  21. *
  22. * The location of the directory where DOMPDF will store fonts and font metrics
  23. * Note: This directory must exist and be writable by the webserver process.
  24. * *Please note the trailing slash.*
  25. *
  26. * Notes regarding fonts:
  27. * Additional .afm font metrics can be added by executing load_font.php from command line.
  28. *
  29. * Only the original "Base 14 fonts" are present on all pdf viewers. Additional fonts must
  30. * be embedded in the pdf file or the PDF may not display correctly. This can significantly
  31. * increase file size unless font subsetting is enabled. Before embedding a font please
  32. * review your rights under the font license.
  33. *
  34. * Any font specification in the source HTML is translated to the closest font available
  35. * in the font directory.
  36. *
  37. * The pdf standard "Base 14 fonts" are:
  38. * Courier, Courier-Bold, Courier-BoldOblique, Courier-Oblique,
  39. * Helvetica, Helvetica-Bold, Helvetica-BoldOblique, Helvetica-Oblique,
  40. * Times-Roman, Times-Bold, Times-BoldItalic, Times-Italic,
  41. * Symbol, ZapfDingbats.
  42. */
  43. 'font_dir' => storage_path('fonts'), // advised by dompdf (https://github.com/dompdf/dompdf/pull/782)
  44. /**
  45. * The location of the DOMPDF font cache directory
  46. *
  47. * This directory contains the cached font metrics for the fonts used by DOMPDF.
  48. * This directory can be the same as DOMPDF_FONT_DIR
  49. *
  50. * Note: This directory must exist and be writable by the webserver process.
  51. */
  52. 'font_cache' => storage_path('fonts'),
  53. /**
  54. * The location of a temporary directory.
  55. *
  56. * The directory specified must be writeable by the webserver process.
  57. * The temporary directory is required to download remote images and when
  58. * using the PDFLib back end.
  59. */
  60. 'temp_dir' => sys_get_temp_dir(),
  61. /**
  62. * ==== IMPORTANT ====
  63. *
  64. * dompdf's "chroot": Prevents dompdf from accessing system files or other
  65. * files on the webserver. All local files opened by dompdf must be in a
  66. * subdirectory of this directory. DO NOT set it to '/' since this could
  67. * allow an attacker to use dompdf to read any files on the server. This
  68. * should be an absolute path.
  69. * This is only checked on command line call by dompdf.php, but not by
  70. * direct class use like:
  71. * $dompdf = new DOMPDF(); $dompdf->load_html($htmldata); $dompdf->render(); $pdfdata = $dompdf->output();
  72. */
  73. 'chroot' => realpath(base_path()),
  74. /**
  75. * Protocol whitelist
  76. *
  77. * Protocols and PHP wrappers allowed in URIs, and the validation rules
  78. * that determine if a resource may be loaded. Full support is not guaranteed
  79. * for the protocols/wrappers specified
  80. * by this array.
  81. *
  82. * @var array
  83. */
  84. 'allowed_protocols' => [
  85. 'file://' => ['rules' => []],
  86. 'http://' => ['rules' => []],
  87. 'https://' => ['rules' => []],
  88. ],
  89. 'log_output_file' => null,
  90. /**
  91. * Whether to enable font subsetting or not.
  92. */
  93. 'enable_font_subsetting' => true,
  94. /**
  95. * The PDF rendering backend to use
  96. *
  97. * Valid settings are 'PDFLib', 'CPDF' (the bundled R&OS PDF class), 'GD' and
  98. * 'auto'. 'auto' will look for PDFLib and use it if found, or if not it will
  99. * fall back on CPDF. 'GD' renders PDFs to graphic files. {@link * Canvas_Factory} ultimately determines which rendering class to instantiate
  100. * based on this setting.
  101. *
  102. * Both PDFLib & CPDF rendering backends provide sufficient rendering
  103. * capabilities for dompdf, however additional features (e.g. object,
  104. * image and font support, etc.) differ between backends. Please see
  105. * {@link PDFLib_Adapter} for more information on the PDFLib backend
  106. * and {@link CPDF_Adapter} and lib/class.pdf.php for more information
  107. * on CPDF. Also see the documentation for each backend at the links
  108. * below.
  109. *
  110. * The GD rendering backend is a little different than PDFLib and
  111. * CPDF. Several features of CPDF and PDFLib are not supported or do
  112. * not make any sense when creating image files. For example,
  113. * multiple pages are not supported, nor are PDF 'objects'. Have a
  114. * look at {@link GD_Adapter} for more information. GD support is
  115. * experimental, so use it at your own risk.
  116. *
  117. * @link http://www.pdflib.com
  118. * @link http://www.ros.co.nz/pdf
  119. * @link http://www.php.net/image
  120. */
  121. 'pdf_backend' => 'CPDF',
  122. /**
  123. * PDFlib license key
  124. *
  125. * If you are using a licensed, commercial version of PDFlib, specify
  126. * your license key here. If you are using PDFlib-Lite or are evaluating
  127. * the commercial version of PDFlib, comment out this setting.
  128. *
  129. * @link http://www.pdflib.com
  130. *
  131. * If pdflib present in web server and auto or selected explicitly above,
  132. * a real license code must exist!
  133. */
  134. //"DOMPDF_PDFLIB_LICENSE" => "your license key here",
  135. /**
  136. * html target media view which should be rendered into pdf.
  137. * List of types and parsing rules for future extensions:
  138. * http://www.w3.org/TR/REC-html40/types.html
  139. * screen, tty, tv, projection, handheld, print, braille, aural, all
  140. * Note: aural is deprecated in CSS 2.1 because it is replaced by speech in CSS 3.
  141. * Note, even though the generated pdf file is intended for print output,
  142. * the desired content might be different (e.g. screen or projection view of html file).
  143. * Therefore allow specification of content here.
  144. */
  145. 'default_media_type' => 'screen',
  146. /**
  147. * The default paper size.
  148. *
  149. * North America standard is "letter"; other countries generally "a4"
  150. *
  151. * @see CPDF_Adapter::PAPER_SIZES for valid sizes ('letter', 'legal', 'A4', etc.)
  152. */
  153. 'default_paper_size' => 'a4',
  154. /**
  155. * The default paper orientation.
  156. *
  157. * The orientation of the page (portrait or landscape).
  158. */
  159. 'default_paper_orientation' => 'portrait',
  160. /**
  161. * The default font family
  162. *
  163. * Used if no suitable fonts can be found. This must exist in the font folder.
  164. */
  165. 'default_font' => 'sans-serif',
  166. /**
  167. * Image DPI setting
  168. *
  169. * This setting determines the default DPI setting for images and fonts. The
  170. * DPI may be overridden for inline images by explicitly setting the
  171. * image's width & height style attributes (i.e. if the image's native
  172. * width is 600 pixels and you specify the image's width as 72 points,
  173. * the image will have a DPI of 600 in the rendered PDF. The DPI of
  174. * background images can not be overridden and is controlled entirely
  175. * via this parameter.
  176. *
  177. * For the purposes of DOMPDF, pixels per inch (PPI) = dots per inch (DPI).
  178. * If a size in html is given as px (or without unit as image size),
  179. * this tells the corresponding size in pt.
  180. * This adjusts the relative sizes to be similar to the rendering of the
  181. * html page in a reference browser.
  182. *
  183. * In pdf, always 1 pt = 1/72 inch
  184. *
  185. * Rendering resolution of various browsers in px per inch:
  186. * Windows Firefox and Internet Explorer:
  187. * SystemControl->Display properties->FontResolution: Default:96, largefonts:120, custom:?
  188. * Linux Firefox:
  189. * about:config *resolution: Default:96
  190. * (xorg screen dimension in mm and Desktop font dpi settings are ignored)
  191. *
  192. * Take care about extra font/image zoom factor of browser.
  193. *
  194. * In images, <img> size in pixel attribute, img css style, are overriding
  195. * the real image dimension in px for rendering.
  196. */
  197. 'dpi' => 96,
  198. /**
  199. * Enable inline PHP
  200. *
  201. * If this setting is set to true then DOMPDF will automatically evaluate
  202. * inline PHP contained within <script type="text/php"> ... </script> tags.
  203. *
  204. * Enabling this for documents you do not trust (e.g. arbitrary remote html
  205. * pages) is a security risk. Set this option to false if you wish to process
  206. * untrusted documents.
  207. */
  208. 'enable_php' => true,
  209. /**
  210. * Enable inline Javascript
  211. *
  212. * If this setting is set to true then DOMPDF will automatically insert
  213. * JavaScript code contained within <script type="text/javascript"> ... </script> tags.
  214. */
  215. 'enable_javascript' => true,
  216. /**
  217. * Enable remote file access
  218. *
  219. * If this setting is set to true, DOMPDF will access remote sites for
  220. * images and CSS files as required.
  221. * This is required for part of test case www/test/image_variants.html through www/examples.php
  222. *
  223. * Attention!
  224. * This can be a security risk, in particular in combination with DOMPDF_ENABLE_PHP and
  225. * allowing remote access to dompdf.php or on allowing remote html code to be passed to
  226. * $dompdf = new DOMPDF(, $dompdf->load_html(...,
  227. * This allows anonymous users to download legally doubtful internet content which on
  228. * tracing back appears to being downloaded by your server, or allows malicious php code
  229. * in remote html pages to be executed by your server with your account privileges.
  230. */
  231. 'enable_remote' => true,
  232. /**
  233. * A ratio applied to the fonts height to be more like browsers' line height
  234. */
  235. 'font_height_ratio' => 1.1,
  236. /**
  237. * Use the HTML5 Lib parser
  238. *
  239. * @deprecated This feature is now always on in dompdf 2.x
  240. */
  241. 'enable_html5_parser' => true,
  242. ],
  243. ];