added knp-snappy package for Jerry's UB04 work
[openemr.git] / vendor / knplabs / knp-snappy / doc / faq.md
blob561c2a0808e80203d487fcb63a0948b54a9cda94
1 # Frequently asked questions
3 ###### *Q*: It does not work and everything is broken.
5 *A*: Please, try to execute the command manually in your shell. Snappy is a thin PHP wrapper and most likely your issue is with wkhtmltopdf itself or is already described in this FAQ. If not, feel free to open the issue in Snappy issue tracker.
7 How to get the command to execute - 
9 ```php
10 var_dump($snappy->getCommand('http://google.com', 'test.pdf'), array('some' => 'option'));
11 ```
13 Please, note that wkhtmltopdf takes only input url or file name as a source.
16 ###### *Q*: My tables are broken when it is rendered on multiple pages with break.
18 *A*: Add ```thead``` and ```tbody``` tags. Add the following css 
19 ```css
20 table, tr, td, th, tbody, thead, tfoot {
21     page-break-inside: avoid !important;
23 ```
26 ###### *Q*: I have a PNG with a transparent background. When generating a PDF, the background turns black.
28 *A*: It is wkhtmltopdf bug as described in https://github.com/wkhtmltopdf/wkhtmltopdf/issues/2214. You should update wkhtmltopdf to at least 0.12.3-dev
31 ###### *Q*: Is there a way to secure the pdf so it can't be edited?
33 *A*:  There is no way to add a password via wkhtmltopdf, but there is a way via other linux tools like pdftk
36 ###### *Q*: We are using wkhtmltopdf to export html to pdf. It breaks the HTML in two pages of pdf. Can we add a break?
38 *A*: It is known problem of `wkhtmltopdf`. You can use css `page-break-after`, like:
39 ```html
40 <style type="text/css">
41     .page {
42         overflow: hidden;
43         page-break-after: always;
44     }
45 </style>
47 <div class="page">
48    new page
49 </div>
50 ```
53 ###### *Q*: It says `wkhtmltopdf: cannot connect to X server` or `xvfb-run: error: Xvfb failed to start.`
55 *A*: Please, check your `wkhtmltopdf` version. It is recommended to use at least `0.12.2.1` and what is important - starting from `wkhtmltopdf >= 0.12.2` it doesn't require X server or emulation anymore. You can download new version from http://wkhtmltopdf.org/downloads.html or install via composer for Linux servers as stated in [README](https://github.com/KnpLabs/snappy#wkhtmltopdf-binary-as-composer-dependencies). If there is no possibility to update `wkhtmltopdf`, please check http://stackoverflow.com/questions/9604625/wkhtmltopdf-cannot-connect-to-x-server
58 ###### *Q*: My PDF is always generated for a small screen resolution\I always receive a mobile version.
60 *A*: It is well-known issue of wkhtmltopdf, you can check https://github.com/wkhtmltopdf/wkhtmltopdf/issues/1508. One of solutions is to use xvbf and to setup xvbf resolution to desired one though a simple bit of css such as `zoom: .75;` would be sufficient in most cases.
62 ###### *Q*: My chars with accents in HTML document are not correctly rendered.
64 *A*: Make sure that you have set `<meta charset="UTF-8" />`
66 ###### *Q*: My document text is not correctly rendered, it is just black squares
68 *A*: Make sure you have installed `xfonts-base`, `xfonts-75dpi` and `urw-fonts`