1

Since "ages" we use RML to create PDF files.

But somehow this feels outdated.

I am looking for a modern way to create PDF files.

I think it would be great to have something which is built upon Chromium so that I can use modern HTML to create the layout.

Required features:

  • Input should be HTML
  • Support for tables which span multiple pages (second page should show the table heading again)
  • Output should be PDF
  • open source
  • Creating should be possible via command-line on a linux server.
  • Hermetic: There should be no need for a third party service.

PS: Please don't tell me to use Latex. I want a syntax which is well-known to most developers.

3
  • Are you asking a question? Other than "tables which span multiple pages" the Chromium engine satisfy your requirements. Note that mapping infiniti HTML plane to fixed physical PDF pages is one of the hardest parts of the HTML to PDF process, regardless of the implementation chosen.
    – Ryan
    Commented Dec 6, 2021 at 16:41
  • @Ryan yes, I am asking a question. I updated the list of features: Creating should be possible via command-line. What is not clear for you? Please tell me.
    – guettli
    Commented Dec 6, 2021 at 20:11
  • 1
    I suppose my confusion is whether you are aware of this or not: developers.google.com/web/updates/2017/04/headless-chrome Which seems to satisfy all your requirements (if I understand your meaning behind hermetic).
    – Ryan
    Commented Dec 7, 2021 at 17:28

2 Answers 2

1
+100

Yeah, well you can do that from command line:

google-chrome --headless --disable-gpu --print-to-pdf=file1.pdf http://www.example.com/

Same thing for Chromium browser:

chromium-browser --headless --disable-gpu --print-to-pdf=file1.pdf http://www.example.com/
1

You can use Paged.js:

Paged.js is a free and open-source library that paginates any HTML content to produce beautiful print-ready PDF. The library fragments the content, reads your CSS print declarations and presents a paginated preview in your browser that you can save as PDF.

By paginating content in the browser, Paged.js shows a preview of the PDF output in web browsers. This allows designers to use browsers dev tools (eg. the inspection console built into most browsers) to make changes on the fly and control the rendering of the typesetting.

It’s also possible to use Paged.js within other tools and to extend rendering by adding plugins.

As Paged.js follows the W3C standards, it can easily be a part of a automated workflows thanks to the command line interface version (using an headless browser) that can generate a PDF from scriptable automated commands.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.