Click here to Skip to main content
13,346,966 members (64,660 online)
Rate this:
Please Sign up or sign in to vote.
See more:
I have a html report and i want to convert into pdf format using java script.

Indeed Java script code for converting html file into pdf.

Posted 24-Dec-10 0:33am
Updated 27-Dec-10 3:14am
Smithers-Jones 24-Dec-10 5:37am
Sandeep Mewara 24-Dec-10 11:00am
Any effort?
Hiren Solanki 27-Dec-10 8:14am
Removed excessive white space from question and some grammar fixing.
Member 12087416 26-Oct-15 6:55am
How we export a html form to pdf using only pure javascript..NOt OTHER languages.I don't wanted to add any plugins/libraries to my code

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 2

Try this..!!!!!

// Example javascript script to convert the
// web page to a PDF file

var conv = new ActiveXObject("pdfServMachine.converter");
conv.convert("", "c:\\google.pdf", false);
WScript.Echo("finished conversion");

or try this..if u dnt want javascript

here is a code snippet to convert a local html file to pdf.
URL url = new File("test.html").toURI().toURL(); WebClient webClient = new WebClient(); HtmlPage page = webClient.getPage(url); OutputStream os = null; try{ os = new FileOutputStream("test.pdf"); ITextRenderer renderer = new ITextRenderer(); renderer.setDocument(page,url.toString()); renderer.layout(); renderer.createPDF(os); } finally{ if(os != null) os.close();

or try this will work....

Client Side - Minimum Code:
(NOT RECOMMENDED) security of reading / writing on client can prohibit client side generation

html = new html$()
pdf = new pdf$();

html.parse("<B> Hello World</B>");


Server Side - Minimum ASP Code:

<%@ language="javascript%">

<script SRC="collinsPdf.js" language="JavaScript" runat="Server"></script>

<script SRC="collinsHtml.js" language="JavaScript" runat="Server"></script>


   html = new html$();

   pdf = new pdf$();

   html.parse("The Date is: <b><i>" + new Date() + "</i></B>");



Hiren Solanki 27-Dec-10 8:13am
Combined both of your answer.
yaprig 29-Dec-10 2:38am
thnx Hiren
Member 12087416 26-Oct-15 6:49am
useless answer .What he can asked what u can tell .He clearly mentioned using javascript .But again u can explain in some other languages.From what useful to anyone.Nothing Please give answer related or directly if possible otherwise don't give any answers this is my request mainly to @@@@@yapring.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy |
Web03 | 2.8.180111.1 | Last Updated 27 Dec 2010
Copyright © CodeProject, 1999-2018
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100