question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Export notebooks as PDF with no page breaks (using HTML)

See original GitHub issue

Is 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

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):

  1. Standard Jupyterbook PDF export

  2. Using notebook as PDF extension to export

Currently the extension only puts H1 level headers in the auto-generated TOC, but lower level headings may be coming soon.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:7 (6 by maintainers)

github_iconTop GitHub Comments

2reactions
choldgrafcommented, Aug 24, 2020

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?

1reaction
mmckycommented, Aug 23, 2020

We are currently working on building pdf via 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 nice pdf files. 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 todo list to look at this suggestion as an alternative pathway for building pdf files via browser. There is also this LaTex.css styling that makes sites look like LaTeX documents which may be promising as well.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Export to .pdf without page breaks - Microsoft Community
Hi all, I want to export a word table to .pdf - table is long and the export forces page breaks while there...
Read more >
export notebook to pdf without code [duplicate] - Stack Overflow
Run Jupyter notebook and download the notebook in the browser: File->Download as->HTML and you will get a html page with code and output....
Read more >
Looking for a way to "Download as PDF via Latex" with no ...
I am looking for a, preferably jupyter-notebook native, way to download my .ipynb as a pdf (it also contains latex) with no page-breaks....
Read more >
Save Jupyter Notebooks as PDF - Tim Head's blog
This means the PDF you get will be very close to the look of a website, you can keep scrolling with no page...
Read more >
How I add pagebreak in my PDF when printing Jupyter ...
Assuming you are using Jupyter on Mac, do not want to learn LaTex for your ... we can use some CSS tricks to...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found