dompdf.php 10 KB

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