

"invoiceName": "Pasta - Fusili Tri - Coloured", "invoiceName": "Carbonated Water - Peach", The JSON data I am going with has a structure like this: [
NODEJS PDFKIT HTML TO PDF GENERATOR
For generating this data I have used an awesome tool called It is an online data generator tool. You can get the mocked JSON stub data from here. Second, in the same folder, create a new file called data.json and have some mocked data in it. This will initialize an empty project for you. In your terminal type in the following: npm init -y This will help you understand this tutorial. You don’t need to, but you can also watch an introductory video (my first ever made) that talks about the basics in reading, writing, and deleting a file in NodeJS.
NODEJS PDFKIT HTML TO PDF PDF
Creating a PDF file of that HTML file generated using Google puppeteer.Learning about writing a file using fs.writeFileSync.Learning about deleting a file by using fs.unlinkSync.Learning about checking if a file exists or not using fs.statSync.Creating an HTML table with a little bit of styling with generated data in it, using an automated node script.Generating stub data (for invoices) using an online tool.So to again give a brief overview, things we will cover: In the process we’ll learn about puppeteer.launch() and understand a bit about page() & pdf().
NODEJS PDFKIT HTML TO PDF HOW TO
We’ll look at how to generate a nice PDF file based on our generated HTML table file. You can even do form submissions via your NodeJS server.Īgain puppeteer is a huge tool, so we will cover just a small but a very cool feature of puppeteer. Like getting a website’s screenshots, crawling websites, and generating pre-render content for single page applications.

So it’s basically a tool that lets you do all the cool browser related things on server. It can also be configured to use full (non-headless) Chrome or Chromium. So what is puppeteer? Well as per the docs, they say: Puppeteer is a Node library which provides a high-level API to control headless Chrome or Chromium over the DevTools Protocol.
