How to generate PDFs with Javascript

Question:

I have a Python program that reads a text file (.txt) and with a series of data from the file, generates a PDF with certain information. To read the .txt use regular expressions. In Javascript there is no problem, I can do it in a similar way to Python, but I cannot find any library that generates a PDF so that it can be downloaded by the user from the web.

Does anyone know if there is a Javascript library to generate a downloadable PDF.

Answer:

In SOen I have found this question very similar to yours, it mentions the jsPDF library, I have not tried it yet, but it promises to deliver PDF files with a code as simple as this:

var doc = new jsPDF();
doc.text(20, 20, 'Hello world.');
doc.save('Test.pdf'); 

I hope it has served you and welcome to SOes.

Scroll to Top