mdbook-pdf
A backend for mdbook written in Python for generating PDF based on Chrome DevTools Protocol.
Usage
Put mdbook-pdf in PATH. Have google-chrome/chromium available (in PATH or location configured).
Ensure you have installed python selenium library, corresponding chromedriver is in PATH or in the book repo or location configured.
Build it with mdbook build
command. Make sure the following exists in your book.toml
:
[output.html]
[output.html.print]
enable = true
[output.pdf]
if you are using Windows, Put this script in the book repo, add the following line to [output.pdf]
in your book.toml
:
command = "python ../../mdbook-pdf"
Configuration
Check book.toml for available configurations of [output.pdf]
.
Known issue
Sometimes the program may crash with errors like this:
selenium.common.exceptions.WebDriverException: Message: unknown error: session deleted because of page crash
from unknown error: cannot determine loading status
from tab crashed
This may be led by resources outrage.
To-do
Rewrite the whole thing in Rust, directly call to Chrome DevTools Protocol instead of using selenium.