Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Directly convert .aspx to .pdf [closed]

A project I am working on requires me to build a report that is output in both HTML (.aspx) and as a PDF. Is there a solution available that allows me to feed the output of an .aspx page to a PDF generation utility? Full support of HTML and CSS would be ideal.

Thanks!

like image 953
JCdowney Avatar asked Aug 03 '09 01:08

JCdowney


2 Answers

wkhtmltopdf will do it.... USAGE:

wkhtmltopdf http://www.google.com google.pdf

That is it. You can go to any web page... even aspx. css is supported better than any other utility as it uses the webkit html rendering engine (Safari, Chrome). Enjoy

There is a single .exe (7 mb) that can be used from .Net simply by using Process.Start Make sure that you copy the exe into your project directory or you have to specify the full path. ex:

static void HtmlToPdf(string website,string destinationFile)
    {
        ProcessStartInfo startInfo = new ProcessStartInfo();
        startInfo.FileName = "wkhtmltopdf.exe";
        startInfo.Arguments = website+" "+destinationFile;
        Process.Start(startInfo);
    }  

I think SSL is supported but I do not think that 2-way SSL would work at the moment. It is hands down the best single stop HTML -> PDF tool I have seen.

like image 99
jle Avatar answered Oct 22 '22 06:10

jle


iTextSharp can do HTML to PDF, but only basic HTML and CSS not full support.

Some articles on sending HTML to iTextSharp:

http://somewebguy.wordpress.com/2009/05/08/itextsharp-simplify-your-html-to-pdf-creation/

http://aspdotnetcodebook.blogspot.com/2008/07/how-to-export-content-of-gridview-to.html

http://geekswithblogs.net/casualjim/archive/2005/11/13/59943.aspx#393262

like image 27
Matthew Lock Avatar answered Oct 22 '22 05:10

Matthew Lock