Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C# ASP.NET HTML PDF
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 21-Jan-13 22:13pm
CodeBlack4.4K
Edited 21-Jan-13 22:15pm
v2
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

iTextSharp[^] is a powerful utility that can help you generate a pdf.
  Permalink  
Comments
Sergey Alexandrovich Kryukov at 24-Jan-13 23:27pm
   
Best suggestion so far, а 5.
—SA
Abhinav S at 24-Jan-13 23:32pm
   
Thank you SA.
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

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
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 3

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..
 
  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();
 
        }
  Permalink  
v2
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 4

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...
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 5

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[^]
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 6

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. Frown | :(
 
Otherwise everything works fine with that control Smile | :)
  Permalink  
v2

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



Advertise | Privacy | Mobile
Web03 | 2.8.141022.2 | Last Updated 24 Jan 2013
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