feat: Playwright PDF engine (allow the PDF engine to be configured in the mkdocs.yml)#58
feat: Playwright PDF engine (allow the PDF engine to be configured in the mkdocs.yml)#58
Conversation
Operating Systems that install chromium using snap such as Ubuntu cannot open files from /tmp
- Playwright bundles its own Chromium binary : None - When Playwright uses an external Chromium, it requires an absolute path
|
Please test whether the generated PDFs are fine or not. |
|
This is gonna be the next thing I look at. Hopefully, I'll have Sunday afternoon to do this. |
|
I've noticed a critical issue: page numbers are not appearing in the TOC, and neither are the author and copyright information. This seems to be a limitation of Chrome. Looking at other implementations (Vivliostyle), it appears they perform the PDF conversion using Chrome/Playwright and implement these features as a post-processing step. Given that this is an insufficient implementation, should we consider withdrawing it for now? Or should we proceed with it as an experimental implementation with the aim of implementing post-processing in the future? I'd like to integrate the insufficient Chrome-based PDF conversion as a hidden option, and then implement post-processing (adding page numbers to the TOC) as the next step. |
|
Thank you. been testing this branch and other than a few glitches it is working very well. a lot better than the default engine. Any expectations of a merge? |
|
Thanks, +1 on getting this merged. Have also been using this branch instead of the pip package for a while and can confirm it behaves nicer than the default engine. |
ref. #51
Experimental feature
headless_chrome_pathoption defaults to NoneInstall
python -m venv .venv source .venv/bin/activate pip install mkdocs-material git+https://github.com/domWalters/mkdocs-to-pdf.git@impl-playwright-pdf-engineBy default, Playwright requires the installation of its own Chromium
Otherwise, please specify the absolute path to the Chromium binary.
Code changed
weasyprint.urls.url_is_absolute->preprocessor.link.util.is_absolute_urlweasyprint.urls.iri_to_uri->preprocessor.link.util.iri_to_uriTest
pytest
PDF check(a little bit)
macOS 15.3.2 24D81
Windows 10 22H2
Docker container:
Note
pyproject.tomlsamples/mkdocs-material: PDF cuts off at Section 1.3.1 #34samples/mkdocs-material: Table of Contents indexes incorrectly when the PDF truncates. #35