Click here to Skip to main content
Rate this: bad
Please Sign up or sign in to vote.
See more: Javascript GimmeCode
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 23-Dec-10 23:33pm
Edited 27-Dec-10 2:14am
Smithers-Jones at 24-Dec-10 5:37am
Sandeep Mewara at 24-Dec-10 11:00am
Any effort?
Hiren Solanki at 27-Dec-10 8:14am
Removed excessive white space from question and some grammar fixing.

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>");
yaprig at 29-Dec-10 2:38am
thnx Hiren
Hiren Solanki at 27-Dec-10 8:13am
Combined both of your answer.

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

  Print Answers RSS
0 OriginalGriff 383
1 Richard Deeming 180
2 Sergey Alexandrovich Kryukov 171
3 Yogesh Kumar Tyagi 165
4 ChauhanAjay 156
0 Sergey Alexandrovich Kryukov 6,252
1 OriginalGriff 5,498
2 CPallini 2,473
3 Richard MacCutchan 1,627
4 Abhinav S 1,530

Advertise | Privacy | Mobile
Web01 | 2.8.140814.1 | Last Updated 27 Dec 2010
Copyright © CodeProject, 1999-2014
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