puppeeter pdf desktop

Puppeteer PDF Desktop

As a blogger, I often have to create PDF versions of my articles for people who prefer to read offline, or to simply save the article for future reference. For this purpose, I have been using Puppeteer PDF Desktop, which is a tool that allows me to convert my HTML files to PDF with ease.

What is Puppeteer PDF Desktop?

Puppeteer PDF Desktop is a Node.js library that uses Chromium (an open-source browser) to generate PDF files from HTML. It provides an easy-to-use interface to generate PDFs with page headers and footers, margins, and many other options. Puppeteer PDF Desktop can also be used to take screenshots of web pages or generate images of PDF pages.

How to use Puppeteer PDF Desktop?

Using Puppeteer PDF Desktop is quite easy, and anyone with basic knowledge of HTML and JavaScript can get started. Here is a step-by-step guide to using Puppeteer PDF Desktop:

  1. Install Puppeteer PDF Desktop by running the following command:
npm install puppeteer-pdf-desktop
  1. Create an HTML file that you want to convert to PDF.
  2. Create a new JavaScript file and require Puppeteer PDF Desktop:
const pptr = require('puppeteer-pdf-desktop');
  1. Use Puppeteer PDF Desktop to generate a PDF file:
pptr('', '', options);

The options parameter is an object that allows you to customize the PDF file. Here are some of the options that you can use:

  • headerTemplate: HTML string for the header of each page.
  • footerTemplate: HTML string for the footer of each page.
  • margin: Size of margin around the page.
  • landscape: Whether to generate the PDF in landscape mode.
  • format: Size of the PDF page.
  • And many more...

Once you have set the options, simply run the above command and a PDF file will be generated at the specified location.


Puppeteer PDF Desktop is a great tool for anyone who needs to generate PDF files from HTML. It is easy to use, and provides many options for customization. I have found it to be very useful in my blogging journey, and I hope you will find it useful too!

Subscribe to The Poor Coder | Algorithm Solutions

Don’t miss out on the latest issues. Sign up now to get access to the library of members-only issues.
[email protected]