Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Create PDF document from HTML using JavaScript [closed]

Tags:

javascript

pdf

I want to create a PDF document from HTML in JavaScript. I tried using the library jsPDF but all the HTML formatting are not supported in it. Is there any other library that I can use to create the PDF?

like image 739
Vishnu Avatar asked Feb 08 '13 10:02

Vishnu


People also ask

How do I export my HTML page as PDF using JavaScript?

Generate PDF using JavaScriptSpecify the content in text() method of jsPDF object. Use the addPage() method to add new page to PDF. Use the save() method to generate and download PDF file.

Can JavaScript generate PDF?

We can start by introducing jsPDF, jsPDF is an open-source library for generating pdf using only JavaScript. It simply creates a pdf page and applies your formatting to the page. Note that we can change the presentation of the data inside the downloaded PDF file by editing the orientation and format.


2 Answers

I've just written a library called jsPDF (Give you the link below) which generates PDFs using Javascript alone. It's still very young, and I'll be adding features and bug fixes soon. Also got a few ideas for workarounds in browsers that do not support Data URIs. It's licensed under a liberal MIT license.

I came across this question before I started writing it and thought I'd come back and let you know :)

http://code.google.com/p/jspdf/

http://hayageek.com/generate-pdf-with-javascript/ //Try this link with step by step process

like image 189
chandru Avatar answered Oct 12 '22 23:10

chandru


You can create the html page as you like to have PDF then from javascript you can call print function of the browser which eventually exports a webpage to a pdf or in printable form

like image 36
Prateek Chandan Avatar answered Oct 12 '22 22:10

Prateek Chandan