Disable CSS `@page` directives when converting to PDF
- Dominant language
- Elm
- Stars
- 2.3k
- Forks
- 184
- Avg merge
- 8h 2m
- Merged PRs (30d)
- 4
Description
HTML&CSS files can use `@page` directives to instruct the browser to insert breaks between physical pages, place PDF pages on specific formats of physical paper, e.g. A4 or US Letter, and insert header/footer information.
`weasyprint` honours these directives, which makes it a great too for generating PDFs from webpages.
However, in the Docspell context, this can have unwanted side effects. For instance certain versions of Outlook create HTML emails that are bound to physical paper sizes that are dependent on the UI locale of the sender. That's stupid in and of itself, but that's not the end of the problem.
When converting email, Docspell inserts the email header information before the existing HTML body, before passing the resulting concatenation to the PDF converter. If the existing HTML body is enclosed in e.g. `
The following is a potential fix. `weasyprint` takes a `--stylesheet` argument and mixes the stylesheet in with the rest. If the `weasyprint` stanza in `docspell-joex.conf` is extended accordingly to pass such a stylesheet, which the contains:
```
* {
page: inherit !important;
}
```
then all `@page` directives are effectively ignored.
Maybe such a stylesheet could be provided by Docspell, possibly even by default, and something added to the documentation about it?
Contributor guide
Assessment
This issue has not been assessed yet.