fathyb / html2svg

Convert HTML and `<canvas>` to SVG, PDF, or images using Chromium
1.19k stars 30 forks source link

Jupyter notebooks' pages are not fully captured #30

Open s1291 opened 1 year ago

s1291 commented 1 year ago

Hello,

I am currently attempting to obtain a complete screenshot of a Jupyter notebook page and it appears that using the --full option has no effect on the output

Steps:

  1. Start jupyter notebook:
jupyter notebook

You will see an output similar to:

[I 14:24:59.613 NotebookApp] [jupyter_nbextensions_configurator] enabled 0.4.1
[I 14:24:59.614 NotebookApp] Serving notebooks from local directory: /tmp/allworks
[I 14:24:59.614 NotebookApp] Jupyter Notebook 6.5.2 is running at:
[I 14:24:59.614 NotebookApp] http://localhost:8888/?token=5407f1b5388261b6b2d6df85944231edd6353aeec3225131
[I 14:24:59.614 NotebookApp]  or http://127.0.0.1:8888/?token=5407f1b5388261b6b2d6df85944231edd6353aeec3225131
[I 14:24:59.614 NotebookApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).
[C 14:24:59.658 NotebookApp] 

    To access the notebook, open this file in a browser:
        file:///home/s.ouchene/.local/share/jupyter/runtime/nbserver-564465-open.html
    Or copy and paste one of these URLs:
        http://localhost:8888/?token=5407f1b5388261b6b2d6df85944231edd6353aeec3225131
     or http://127.0.0.1:8888/?token=5407f1b5388261b6b2d6df85944231edd6353aeec3225131
  1. Copy the token from the terminal to the clipboard.
  2. Create a new python3 notebook, and add some content to it (it should be long, i.e., its content should fit on more than 1 page).
  3. In the terminal, run:
TOKEN="paste the copied token here from step 2" # e.g 5407f1b5388261b6b2d6df85944231edd6353aeec3225131
NOTEBOOK_URL="Copy the URL of the notebook in the browser" # e.g. http://localhost:8888/notebooks/Fourier_Analysis.ipynb
docker run --network="host" fathyb/html2svg --full --wait 5 --format pdf "${NOTEBOOK_URL}?token=${TOKEN}"  > doc.pdf

Expected output

In my case, I expected to get a PDF document with at least 3 pages (which fully captures the notebook contents).

What happened

The notebook is not fully captured; the PDF document contains only one page.

Thank you