Generating PDF for reports, forms, invoices, and other data is a common use case for any web application. In a web application, We can generate pdf using various approaches:

Using browser print function: It is an easy option when you want to print a complete web page as a pdf. You can also customize pdf up to some limits. limitation of this approach is we don’t have strong control on format and design of pdf. Generating PDF using Backend application or third-party reporting tools and download it on client-side: You have more control over pdf formatting and design and you can process large amounts of data. Though this type of pdf generation approach required a separate API call for generating the pdf.

We can solve the limitations of both ways by generating pdf at client side. We can format and design pdf as per our requirement without calling separate API.

Following are the two popular open-source javascript libraries available for client-side pdf generation.

In this article, I will show you how to export a pdf file in angular 8 using pdfmake.