
In this tutorial, we will see how to generate a PDF using Node.js to handle the logic, a view template engine called Handlebars to design and style the report and finally, use a headless browser called puppeteer to print PDFs of the view generated.

Take too much to draw the design of the report since we are doing it in imperative.It doesn't give the freedom to customize the design.CSS styling is the most crucial part if you want a nice report.When it comes to generating a summary that will be exported in PDF format, many libraries help to achieve this task, but there can be limited in features like: You should find Puppeteer executes successfully, provided proper Chrome flags are used.Generating PDF files from a web application is one of the most tedious tasks nowadays. Chrome will write into /tmp instead.Īdd your JavaScript to your container with a COPY instruction. disable-dev-shm-usage – This flag is necessary to avoid running into issues with Docker’s default low shared memory space of 64MB.If you’re uncomfortable with this, you’ll need to manually configure working Chrome sandboxing, which is a more involved process. It’s vital you ensure your Docker containers are strongly isolated from your host. Using these flags could allow malicious web content to escape the browser process and compromise the host.

no-sandbox and disable-setuid-sandbox – These disable Chrome’s sandboxing, a step which is required when running as the root user (the default in a Docker container).

Setting this flag explicitly instructs Chrome not to try and use GPU-based rendering. disable-gpu – The GPU isn’t usually available inside a Docker container, unless you’ve specially configured the host.
