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