]> BookStack Code Mirror - website/blob - content/docs/admin/pdf-rendering.md
Script refresh, now compatible with RHEL 8.9 with PHP 8.1
[website] / content / docs / admin / pdf-rendering.md
1 +++
2 title = "PDF Rendering"
3 description = "Options to configure PDF rendering within BookStack"
4 date = "2017-01-22"
5 type = "admin-doc"
6 +++
7
8 By default BookStack uses [dompdf](https://github.com/dompdf/dompdf) to export pages as PDF documents. The benefit of using dompdf is that it doesn't require any additional installation or setup but the rendering capabilities are somewhat limited.
9
10 As an alternative you can use [wkhtmltopdf](http://wkhtmltopdf.org/) to generate PDF documents instead. wkhtmltopdf uses the Qt WebKit rendering engine to provide a more accurate overall result, but comes with additional security concerns to be aware of.
11
12 ### Using wkhtmltopdf
13
14 Pre-compiled binaries for wkhtmltopdf can be found on the downloads page of [their website](http://wkhtmltopdf.org/downloads.html).
15 BookStack will check for a file named `wkhtmltopdf` at the base folder of a BookStack install. If found it will use that to render PDF exports. 
16 If that does not exist it will check for a `WKHTMLTOPDF` variable in the `.env` file. 
17 You can use the below variable in your `.env` file to set an alternate location to wkhtmltopdf:
18
19 ```bash
20 WKHTMLTOPDF=/home/user/bins/wkhtmltopdf
21 ```
22
23 If neither of those exist, or if the below mentioned security option is not enabled, the default dompdf renderer will be used instead.
24
25 **Note:** As of BookStack v21.08 the `ALLOW_UNTRUSTED_SERVER_FETCHING` must also be set to `true` for wkhtmltopdf to be enabled, without this dompdf will be used instead. 
26 This change was made for security since, in many cases, wkhtmltopdf will perform fetches to external URLs which may be defined by users.
27 You should only enable the below option in environments where users & visitors are trusted.
28
29 ```bash
30 ALLOW_UNTRUSTED_SERVER_FETCHING=true
31 ```
32
33 [See our security page for more detail regarding this option](/docs/admin/security/#server-side-requests).
34
35 ### Export Page Size
36
37 By default PDF exports are generated at an A4 size. If you'd prefer exports to be generated at "US Letter" standard sizes
38 you can specify this within your `.env` like so:
39
40 ```bash
41 # US Letter
42 EXPORT_PAGE_SIZE=letter
43 ```