HollowMan6 / mdbook-pdf

A backend for mdBook written in Rust for generating PDF based on headless chrome and Chrome DevTools Protocol. (用 Rust 编写的 mdBook 后端,基于headless chrome和Chrome开发工具协议生成PDF)
https://crates.io/crates/mdbook-pdf
GNU General Public License v3.0
150 stars 18 forks source link

PDF Bookmarks/Outlines/Table of Content Support #1

Closed seanmrnda closed 1 year ago

HollowMan6 commented 2 years ago

You mean the pdf bookmarks/outlines? No, and I had also explained this in the README common Issues part 3.

  1. Can you add the bookmark to the PDF reflecting the Table of Contents, just like what wkhtmltopdf supported?

This should be realized by Chromium, and an issue has already been filed for this here.

HollowMan6 commented 2 years ago

Other helpful links:

HollowMan6 commented 1 year ago

Hi! Finally support for the bookmark/outline of the PDF file is available now(mdbook-pdf-outline). It is written in Python and is another backend for mdbook and should be used with mdbook-pdf and the mdbook version mentioned in Common Issues 2 for fixing the broken links in print.html.

You can install this backend by pip install mdbook-pdf-outline.

Remember to put the following to the end of your book.toml, after [output.pdf]:

[output.pdf-outline]

If you want to use the table of content just like the one shown in the print.html page for PDF file, you can leave the book.toml as it is.

If you prefer to use the table of content just like the one generated by wkhtmltopdf (generate entries based on the headings), you can turn on the like-wkhtmltopdf option by using the following to your book.toml:

[output.pdf-outline]
like-wkhtmltopdf = true

You can find the outlined version at book/pdf-outline/output.pdf.

Todos: It would be great if we can rewrite mdbook-pdf-outline into rust, but I can hardly find a proper pdf library in rust that supports named destinations, lopdf is a promising one, let's wait for it to release the new feature.

HollowMan6 commented 1 year ago

Samples of PDFs with table of content: https://github.com/HollowMan6/mdbook-pdf/actions/runs/3789636358