pagedjs / pagedjs

Display paginated content in the browser and generate print books using web technology
https://pagedjs.org
MIT License
835 stars 85 forks source link

pagedjs-cli hangs or doesn't render all pages of html content #106

Open manuel-koch opened 2 years ago

manuel-koch commented 2 years ago

I have installed it using npm install -g pagedjs-cli pagedjs and tried to convert the attached html into a pdf. It should contain 10 sections/pages with each a dummy picture and a qr code image embedded as data-url. framed_image.html.zip

I see two issues ( depending on how I start the command line tool ):

  1. Starting it from within a python interpreter it creates just a subset of the html content to pdf. framed_image.pagedjs.pdf
subprocess.check_call(
    " ".join(
        [
            "/Users/manuelkoch/.nvm/versions/node/v18.7.0/bin/node",
            "/Users/manuelkoch/.nvm/versions/node/v18.7.0/bin/pagedjs-cli",
            "--page-size",
            "A4",
            "-i",
            out_html_path.as_posix(),
            "-o",
            out_pagedjs_pdf_path.as_posix(),
        ]
    ),
    shell=True,
)
  1. Starting it in an interactive shell I can see a browser popup opening ( don't know which browser it is ) and closing automatically. Afterwards the cli hangs and I have to quit it using Ctrl-C
$ pagedjs-cli --debug --page-size A4 framed_image.html -o framed_image.pagedjs.pdf
✔ Processed
✔ Loaded
✔ Rendering 4 pages took 114.5 milliseconds.
◴ Generating^C

If I open the HTML in a browser (MacOS, Chrome Version 105.0.5195.125 (Offizieller Build) (x86_64)) and print it to pdf, it looks ok though. framed_image.chrome.pdf

$ node --version
v18.7.0
$ npm --version
8.15.0
nzakas commented 2 years ago

I ran into the same issue and eventually just put together my own solution: https://github.com/humanwhocodes/print-ready

It doesn't have as many features as pagedjs-cli, but it got me past the point where I was just waiting forever.