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