shakil-shahan / html-to-pdf-puppeteer

Using Google Puppeteer to convert HTML template to PDF on server

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

html-to-pdf-puppeteer

Its has always been a challenge for many developers to generate PDF from html on server side. There are scenarios like where we need to generate a PDF invoice for a customer, save it on server as well as email them the PDF.

I am using a simple HTML invoice template to demonstrate how we can use puppeteer and node js to create a pdf of it on server.

STEPS TO RUN ABOVE CODE

  • First clone the repository using git clone command
  • Run npm install in the project root directory.
  • Wait for dependencies to install, they may take some time depending on your internet speed.
  • Run node index.js command in your terminal.

You will see a file name invoice.pdf in you project root folder, that is the converted file from html to pdf.

About

Using Google Puppeteer to convert HTML template to PDF on server


Languages

Language:HTML 74.5%Language:JavaScript 25.5%