Does anyone know of a component (open source or 3rd party) that would allow you to export a fully rendered HTML page to PDF in c#? We have a page that has its DOM modified with jquery but the methods we have tried (ABCpdf.NET, WebClient, etc) don't register any DOM changes from javascript in the PDF. We need to programmatically export that rendered HTML (post-jquery) to PDF on the fly.
Asked
Active
Viewed 2,674 times
3
-
2What ever client side DOM manipulation you do, you still need to post back the modified DOM/HTML back to the server for the PDF export process to kick in right? Have you considered iTextSharp? Is it mainly formatted text you're exposrting or you have lots of graphics? – Anas Karkoukli Sep 30 '11 at 16:54
-
The PDF generation is a completely separate process - it's not related to the current page. I am simply passing the URL of the page I want to consume as a parameter to the PDF generation process - the trick is that I need the PDF generator to render the page as a user would see (post-javascript with all of the DOM changes visible). – Rob Lauer Sep 30 '11 at 17:35
3 Answers
3

rick schott
- 21,012
- 5
- 52
- 81
-
2@Robbo You can have javascript modify the dom before creating the pdf - you'll need to set some parameters (like `PdfConverter.ScriptsEnabled = true`). It uses the version of IE installed on the server. See also the [FAQ](http://www.html-to-pdf.net/FAQ.aspx) (somewhere in the middle...) – marapet Sep 30 '11 at 19:07
1
I was looking for something similar many months ago and as far as I can remember, it's not possible with any free third-party controls. There are paid ones available. The closest you can get is iTextSharp. It will allow you to export the contents of specific html tads and user controls but it's a bit of a pain to deal with

splatto
- 3,159
- 6
- 36
- 69
0
I'm never tried is but there's an open source solution called wkhtmltopdf that renders a PDF from HTML/JavaScript/CSS using the WebKit engine. This post talks a little bit about using it. If it works I'd like to know because I've heard this request a couple of times here.

Community
- 1
- 1

Chris Haas
- 53,986
- 12
- 141
- 274