I am developing an extension for Google Chrome and I'm wanting to generate a PDF with a HTML content stored in a variable of the plugin. I thought about using the same system that the browser uses to generate PDF pages, is it possible? How? Note: I do not want to use a system hosted on a server for it ...
Asked
Active
Viewed 2,717 times
2
-
Maybe [**this**](http://stackoverflow.com/questions/742271/generating-pdf-files-with-javascript) will help. – blex Jul 15 '14 at 19:34
1 Answers
2
In fact, you don't even need an extension to create a PDF. You can use usual JavaScript in a web page (either with a JS library or not)
You can just use base64 encoding to simply load this URL with the PDF data as DATA:
window.location.href="data:application/pdf;base64,DATA"
Otherwise, as blex mentioned, you can use a library like jsPDF to create something more easily; for example:
((new jsPDF()).text(20, 20, 'Hello world.')).save('Test.pdf');
Does that satisfy your need?