Hello Team,
I have used iTextSharp to convert HTML to PDF using below code
Dim doc As New Document(PageSize.A4, 80, 50, 30, 65)
Dim strFileName As String =
HttpContext.Current.Server.MapPath("~/files/golf/test123.pdf")
Dim writer As PdfWriter = PdfWriter.GetInstance(doc, New
FileStream(strFileName, FileMode.Create))
doc.Open()
Dim strURL As String = "http://ace:2959/admin/testpdf.html"
Dim uri As New Uri(strURL)
Dim req As HttpWebRequest = DirectCast(WebRequest.Create(uri), HttpWebRequest)
req.UserAgent = "Get Content"
Dim resp As WebResponse = req.GetResponse()
Dim stream As Stream = resp.GetResponseStream()
Dim sr As New StreamReader(stream)
Dim html As String = sr.ReadToEnd()
Dim lt As ArrayList =
iTextSharp.text.html.simpleparser.HTMLWorker.ParseToList(New
StringReader(html), Nothing)
Dim ct As New ColumnText(writer.DirectContent)
ct.SetSimpleColumn(50, 50, PageSize.A4.Width - 50, PageSize.A4.Height - 50)
For k As Integer = 0 To lt.Count - 1
doc.Add(DirectCast(lt(k), IElement))
Next
doc.Close()
Problem:
I can get PDF generated from HTML but formating is not as it looks like in HTML.
It dosen't support images width & height in html table.
I want to convert full formatted HTML structure in generating PDF.
Can anyone help me to solve my problem?
I am awaiting for a solution.
Thanks in advance.
Regards,
Darshak
------------------------------------------------------------------------------
ThinkGeek and WIRED's GeekDad team up for the Ultimate
GeekDad Father's Day Giveaway. ONE MASSIVE PRIZE to the
lucky parental unit. See the prize list and enter to win:
http://p.sf.net/sfu/thinkgeek-promo
_______________________________________________
iText-questions mailing list
iText-questions@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/itext-questions
Buy the iText book: http://www.itextpdf.com/book/
Check the site with examples before you ask questions:
http://www.1t3xt.info/examples/
You can also search the keywords list: http://1t3xt.info/tutorials/keywords/