Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Local HTML -> PDF rendering #4

Open
captn3m0 opened this issue May 26, 2021 · 5 comments
Open

Local HTML -> PDF rendering #4

captn3m0 opened this issue May 26, 2021 · 5 comments

Comments

@captn3m0
Copy link
Owner

# Title

- [chapter 1](chapter1.html)
- [chapter 2](chapter2.html)

Convert the HTML to PDFs and merge accordingly.

@captn3m0 captn3m0 changed the title HTML -> PDF rendering Local HTML -> PDF rendering May 26, 2021
@captn3m0
Copy link
Owner Author

captn3m0 commented Jun 27, 2021

Notes from PDF rendering research in Python:

  • The best results come from running pandoc, but that comes with latex dependencies, which we want to avoid.
  • The next best tools are:
    • wkhtml2pdf, which also has installation concerns. I don't like the render quality either.
    • xhtml2pdf which uses PyPDF2 (😞) and reportlab underneath.
    • Directly using reportlab, but this has a few native dependencies that it comes bundled with. (libfreetype, libpng, libz)
    • And finally, rinohtype, which is pure-python but is heavily under development and is missing some important features for now (such as remote images)
    • weasyprint, which I haven't tried much yet.

Did some experiments with all of the above to get close-to-pandoc typography. Will add some more details here.

@Vonter
Copy link
Collaborator

Vonter commented Jan 2, 2022

I tried out Weasyprint and the results look promising to me, but it does have a couple of external dependencies, including Pango. However there do seem to be plans to minimize the external dependencies

@captn3m0
Copy link
Owner Author

captn3m0 commented Jan 2, 2022

My recommended options are (not in any order):

@captn3m0
Copy link
Owner Author

I filed a PR to xhtml2pdf for PyPDF3 support: xhtml2pdf/xhtml2pdf#582.

@captn3m0
Copy link
Owner Author

xhtml2pdf moved back to pypdf2: https://github.com/xhtml2pdf/xhtml2pdf/pull/656/files which is now merged back to the pypdf project. PyPDF3 is unmaintained.

xhtml2pdf is getting regular updates now. There might even be scope to just let people pick between reportlab, xhtml2pdf, rinohtype, or borb as different "renderers".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants