Export notebooks as PDF with no page breaks (using HTML)
See original GitHub issueIs your feature request related to a problem? Please describe.
Currently jupyterbook’s Print to PDF functionality relies on ~nbconvert to export to a pdf intended for actual printing~ UPDATE: See below, nbconvert isn’t used here. Of course, most people do not actually want to print notebooks, but rather read/refer to them offline or on mobile devices.
@betatim has just created an extension that exports a notebook to PDF without LaTeX, and with the minimum amount of page-breaks.
Describe the solution you’d like
The nice thing is that the extension is also possible to use with nbconvert directly:
jupyter-nbconvert --to PDFviaHTML example.ipynb
So it’s very possible that this can already be configured to work today (but I just don’t know how).
Describe alternatives you’ve considered
- Using CSS to export to PDF (issue #761)
- Also briefly looked at @phaustin and co’s work in this issue
Additional context
I have tried it on a couple of notebooks and it works quite well. The only thing that is currently missing is the Myst-related directives image exports.
Below are two PDF exports from an example jupyter book that is not mine (ThreatHunter Playbook):
Currently the extension only puts H1 level headers in the auto-generated TOC, but lower level headings may be coming soon.
Issue Analytics
- State:
- Created 3 years ago
- Comments:7 (6 by maintainers)

Top Related StackOverflow Question
How about we re-name this issue as something like “make PDF through HTML output no page breaks”. That seems more specific and would be useful!
I think the fix would be somewhere around here:
https://github.com/executablebooks/jupyter-book/blob/master/jupyter_book/pdf.py#L42
Note that we’re (I believe) using the same library as @betatim so perhaps we can just copy his solution straightaway?
We are currently working on building
pdfvia LaTeX at the document level in this PR which is a different pathway than the one described here. In past experience on other projects – if you can get the LaTeX route supported it produces nicepdffiles. We are currently working on making the link to PDF via LaTeX available first – and then will work on robustness.@AakashGfude can you add to you
todolist to look at this suggestion as an alternative pathway for buildingpdffiles viabrowser. There is also this LaTex.css styling that makes sites look like LaTeX documents which may be promising as well.