Click here to Skip to main content
12,355,960 members (71,456 online)
Rate this:
 
Please Sign up or sign in to vote.
See more: ASP.NET
Dear All

I am using below code for converting html to pdf
below code running fine on one form but same is not running on another form
in "strhtml" i am passing my html text..
Even i hard code some html string then also it is not going anything fine
please help....
Dim cliid As String = Request("fromaccid")
Dim doc As New Document()
Dim UrlDirectory As [String] = Request.Url.GetLeftPart(UriPartial.Path)
UrlDirectory = UrlDirectory.Substring(0, UrlDirectory.LastIndexOf("/") + 1)
Response.Write(UrlDirectory)
Dim getcurrtime As String() = Split(DateTime.Now.TimeOfDay.ToString, ".")
Dim dt As String = ClsDate.GetFormatedDate(ClsApplvl.Getserverdt(), "DD/MM/YYYY")
PdfWriter.GetInstance(doc, New FileStream(Server.MapPath("../TRANSACTIONPDF/" & cliid & " " & dt & ".pdf"), FileMode.Create))
'iTextSharp.text.html.simpleparser.StyleSheet.
doc.Open()
Dim htmlText As [String] = strhtml
 
Dim htmlarraylist As List(Of IElement) = iTextSharp.text.html.simpleparser.HTMLWorker.ParseToList(New StringReader(htmlText), Nothing)
Dim font As iTextSharp.text.Font = FontFactory.GetFont("Times-Roman", 10, 1, iTextSharp.text.BaseColor.GRAY)
 

 
For k As Integer = 0 To htmlarraylist.Count - 1
  Dim x As IElement = DirectCast(htmlarraylist(k), IElement)
  Response.Write(x.Type.ToString() + "#<br>")
Next
 
Dim mypara = New Paragraph()
mypara.InsertRange(0, htmlarraylist)
mypara.Font = font
doc.Add(mypara)
doc.Close()</br>
Posted 28-Sep-12 2:42am
Edited 28-Sep-12 2:51am
Tim Corey110.9K
v2
Comments
Deepak Jena 28-Sep-12 13:52pm
   
As you have mentioned "below code running fine on one form but same is not running on another form" ,
Try debugging and trace exceptions , if any !!

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 | Mobile
Web02 | 2.8.160621.1 | Last Updated 28 Sep 2012
Copyright © CodeProject, 1999-2016
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