Click here to Skip to main content
13,297,799 members (53,551 online)
Rate this:
 
Please Sign up or sign in to vote.
See more:
convert html page with html table tag option to pdf in asp.net

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 24-Feb-13 22:03pm
Updated 26-Feb-13 2:54am
v3
Comments
Manfred R. 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
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

NEED TO DOWNLOAD iTextSharp dll. it is a free tool.

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


 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();
 
        }
  Permalink  
v2
Comments
Edo Tzumer 25-Feb-13 3:58am
   
5+
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 4

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

Solution 3

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”);
}
}
}
  Permalink  

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

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy |
Web04 | 2.8.171207.1 | Last Updated 9 Apr 2013
Copyright © CodeProject, 1999-2017
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