Click here to Skip to main content
15,885,546 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

I am developing an application to export all the html conetents to pdf.
I found few third party libraries like itextsharp and all.
But none of them work 100%.

So can any one help me to achieve this export HTML to PDF functionality ?
It should support css, images and everything.
Posted
Updated 21-Jan-13 22:15pm
v2

Hi,

I found one very nice third party control called pdfcrowd. Which is the best control i found till Now.

Only bad thing is that it is paid version. :(

Otherwise everything works fine with that control :)
 
Share this answer
 
v2
I suffer the same before. It indeed really hard to find a pdf library that can export all webpage content to PDF especially there are some special content such as advertizing or dynamic images.These special content always a tough thing. Untill I know this C# PDF library[^]. It only uses three lines of code to convert webpage of html,htm,aspx which contains dynamic advertizing quickly. Whatever for the code and for the effect, I think it is best on this function.So I suggest it to you here.You also can come here to see why it is such popular ansd how to convert html to PDF:
Save Webpage as PDF[^]
 
Share this answer
 
my company used htmltopdf by syncfusion essentials...

but clearest way is to create your own pdf, it will be easier to adapt the content to the page and you will have a lot more control on the result.

i know it's harder but i think that the amount of time needed is more or less the same...
 
Share this answer
 
Hi,

Whatever you want first Google it. In google they are so many links related to this..

Please check this links...

Html to PDF conversion using c#[^]
http://www.dotnetfunda.com/forums/thread3134-html-table-export-to-pdf-using-csharp.aspx[^]
http://stackoverflow.com/questions/564650/convert-html-to-pdf-in-net[^]

this might be helpfull to you....


If you want code related this please check with this..

C#
protected void btnExportToPDF_Onclick(object sender, EventArgs e)
      {
          Response.ClearContent();
          Response.ContentType = "application/pdf";
          Response.AddHeader("content-disposition", "attachment;filename=ExportPDF.pdf");
          Response.Cache.SetCacheability(HttpCacheability.NoCache);
          StringWriter sw = new StringWriter();
          HtmlTextWriter hw = new HtmlTextWriter(sw);

          Table3.RenderControl(hw);
          lblMessbody.RenderControl(hw);
          StringReader sr = new StringReader(sw.ToString());
          Document pdfDoc = new Document(PageSize.A4, 10f, 10f, 100f, 0f);
          HTMLWorker htmlparser = new HTMLWorker(pdfDoc);
          PdfWriter.GetInstance(pdfDoc, Response.OutputStream);
          pdfDoc.Open();
          htmlparser.Parse(sr);
          pdfDoc.Close();
          Response.Write(pdfDoc);
          Response.End();

      }
 
Share this answer
 
v2
iTextSharp[^] is a powerful utility that can help you generate a pdf.
 
Share this answer
 
Comments
Sergey Alexandrovich Kryukov 24-Jan-13 23:27pm    
Best suggestion so far, а 5.
—SA
Abhinav S 24-Jan-13 23:32pm    
Thank you SA.
Hi,

You can review the following URL

http://www.codeproject.com/KB/cs/pdfizer.aspx

And if you are willing to use the premium service then you can also review these

EOpdf or Asppdf.net

Or you can review the followings as well

All in One Export Data in ASP.NET[^]


Generate PDF documents from a HTML page using ASP.NET[^]


http://csharpdotnetfreak.blogspot.in/2008/12/export-gridview-to-pdf-using-itextsharp.html[^]


Please let me know if that helps.

Happy Programming
 
Share this answer
 

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900