Generating PDF documents from templates is a common task in software development. Recent developments have made HTML a suitable solution for typesetting and PDF generation.
Using HTML for templates provides several benefits: HTML is widely known, well-documented, and easily managed through version control systems like git.
The following projects explore PDF generation using open-source libraries.
In these projects, mustache is used as the template language due to its simple syntax and the widespread availability of the mustache template engine. The mustache syntax supports variables, conditionals, repeatable sections, and the inclusion of other templates.
Browsers provide the following CSS styles for typesetting.
lang HTML attributeVarious open-source libraries are available for template creation, testing, and rendering. These libraries are used in the projects described above.
An open-source library for paginating HTML content for print. This library is created for designing books with HTML.
https://pagedjs.org
https://github.com/pagedjs/pagedjs
https://ashok-khanna.medium.com/beautiful-pdfs-from-html-9a7a3c565404
https://www.adamhyde.net/some-pagedjs-info
License: See project, MIT license at time of writing
An open-source JavaScript library for rendering mustache templates.
https://github.com/janl/mustache.js
Template language
License: See project, MIT License at time of writing
An open-source NuGet package for rendering mustache templates.
https://github.com/StubbleOrg/Stubble
Template language
License: See project, MIT License at time of writing
An open-source library that provides control over Chromium, WebKit and Firefox. It is used for automated testing and PDF generation. Playwright is maintained by Microsoft.
https://playwright.dev
License: See project, Apache License 2.0 at time of writing
An open-source Node.js library that provides control over Chrome or Chromium. It is used for automated testing and PDF generation. Puppeteer is maintained by the Chrome DevTools team.
https://pptr.dev
https://github.com/puppeteer/puppeteer
License: See project, Apache License 2.0 at time of writing
A text editor for the web specialized in editing code.
https://codemirror.net
https://github.com/codemirror/dev
License: See project, MIT License at time of writing
An open-source WYSIWYG editor that allows users to create formatted HTML content. This project is funded through sales of a cloud version and advanced plugins.
https://www.tiny.cloud/docs/tinymce/latest
https://www.npmjs.com/package/tinymce
License: See project
Version 6 has an MIT license.
Version 7 has a GPLv2 license.