PDF generation with GotenbergNovember 4, 2023
Gotenberg is a Docker-based stateless API for PDF generation from HTML and Markdown files.
To get started, configure Docker compose and run the
docker-compose up command.
version: '3.8'services:gotenberg:image: gotenberg/gotenberg:7ports:- 3000:3000
API is available on http://localhost:3000 address.
Run the following commands to generate PDFs
from the given URLcurl \--request POST 'http://localhost:3000/forms/chromium/convert/url' \--form 'url="https://sparksuite.github.io/simple-html-invoice-template/"' \--form 'pdfFormat="PDF/A-1a"' \-o curl-url-response.pdf
from the given HTML filecurl \--request POST 'http://localhost:3000/forms/chromium/convert/html' \--form 'files=@"./index.html"' \--form 'pdfFormat="PDF/A-1a"' \-o curl-html-response.pdf
PDF/A-1a format is used for the long-term preservation of electronic documents, ensuring that documents can be accessed and read even as technology changes.
The demo with the mentioned examples is available here. It also contains examples using Fetch API and Axios package.