Click here to Skip to main content
15,922,166 members
Please Sign up or sign in to vote.
3.00/5 (2 votes)
See more:
convert html page with html table tag option to pdf in asp.net

CSS
The html text which i want to convert to pdf is as follows







<img src="http://localhost:56814/Quotation/images/head.jpg" style="width: 100%" />


 









To
Quote No
00005
The
nj
Quote Date
26/04/2012
PK
Inquiry Date
09/09/2010
bhatt
Kind Attentions
123
AHMEDABAD
333333
Phone
787878787
GUJARAT
PK




Dear Sir/Madam


Thank you for your inquiry, we wish to quote our lowest for the following items.





ItemPrice/UnitRemarksImage




1.

make
PN061549845
SAFTY


Belt


Compliance:NA


Rs.
381
/
Nos.
Markand <img id="grdItemList_ctl02_imgItem" src="http://localhost:56814/Quotation/images/default.jpg" style="height:70px;width:70px;border-width:0px;" />







Payment Terms
Validity
Sales Tax
Delivery Schedule
Freight
7 Days
VAT 15%
30 days

Days
Paid





In case of any futher queries please feel free to contact us by E-mail or Phone.
Thanking you and looking forward to the opportunity to serve your esteemed Organisation.



<img src="http://localhost:56814/Quotation/images/logo.jpg" />



Posted
Updated 26-Feb-13 1:54am
v3
Comments
Manfred Rudolf Bihy 25-Feb-13 3:05am    
Is there a question here?
I can't seem to spot it.
And just in case you didn't know yet, google is your friend!
Shubh Agrahari 25-Feb-13 3:14am    
with table width....not sound clear...explain it

Maybe you will be interested in this solution:
http://eleriumsoft.com/PDF_NET/HTML2PDF/Examples/Create_PDF_using_HTML_string.aspx[^]
But it is not free.
 
Share this answer
 
namespace htmltopdf
{
class Program
{
[STAThread]
static void Main(string[] args)
{
//Create a pdf document.
PdfDocument doc = new PdfDocument();
String url = “Http://apple.com/”;
doc.LoadFromHTML(url, false, true, true);
//Save pdf file.
doc.SaveToFile(“webpageaspdf.pdf”);
doc.Close();
//Launching the Pdf file.
System.Diagnostics.Process.Start(“webpageaspdf.pdf”);
}
}
}
 
Share this answer
 
NEED TO DOWNLOAD iTextSharp dll. it is a free tool.

http://sourceforge.net/projects/itextsharp/files/latest/download[^]


C#
public void HTMLToPdf(string HTML, string FilePath)
       {

           Document document = new Document();

           PdfWriter.GetInstance(document, new FileStream(Request.PhysicalApplicationPath + "\Test.pdf", FileMode.Create));
           document.Open();

           iTextSharp.text.html.simpleparser.StyleSheet styles = new iTextSharp.text.html.simpleparser.StyleSheet();
           iTextSharp.text.html.simpleparser.HTMLWorker hw = new iTextSharp.text.html.simpleparser.HTMLWorker(document);
           //styles.LoadTagStyle(".barcode", "font-size", "50px");
           //styles.LoadTagStyle(".barcode", "font-family", "3 of 9 Barcode");
           //styles.LoadTagStyle(".barcode", "color", "Green");
           hw.Parse(new StringReader(HTML));
           document.Close();
           ShowPdf("Test.pdf");
       }
       private void ShowPdf(string s)
       {
           Response.ClearContent();
           Response.ClearHeaders();
           Response.AddHeader("Content-Disposition", "inline;filename=" + s);
           Response.ContentType = "application/pdf";
           Response.WriteFile(s);
           Response.Flush();
           Response.Clear();

       }
 
Share this answer
 
v2
Comments
Joezer BH 25-Feb-13 3:58am    
5+

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