Creating PDFs from documentations can be challenging especially when the tools don't have a built-in PDF export functionality. This article shows how to use Puppeteer to convert a website created with Starlight into a PDF document.
Identifying the starting page, navigating through the pages, extracting the headings and content from the page, and building a table of contents, adding page breaks and focusing on additional styles is the process using Puppeteer to convert the website.
Further, to make the PDF visually appealing the headers and footers were added to the templates with the help of Puppeteer's Page.pdf() method. Various things have to be kept in mind like defining the font-size CSS property, Using inline