EDN Admin
Well-known member
I have the following code that works almost right. It will generate the PDF, but the GridView is not there. I can see the other text on the PDF.
<span style="font-size:small <span style="font-size:small
<pre class="prettyprint lang-vb Dim form As New HtmlForm()
form.Controls.Add(GridView1)
Dim sw As New StringWriter()
Dim hTextWriter As New HtmlTextWriter(sw)
form.Controls(0).RenderControl(hTextWriter)
Dim html As String = sw.ToString()
Dim Doc As New iTextSharp.text.Document()
Save Doc as PDF to Server
PdfWriter.GetInstance(Doc, New FileStream("\tserveruploadsexpenseAtest.pdf", FileMode.Create))
Doc.Open()
Adds Info to the Doc that is open to write.
Dim c As New Chunk("Export GridView to PDF Using iTextSharp " & vbLf, FontFactory.GetFont("Verdana", 15))
Dim p As New Paragraph()
p.Alignment = Element.ALIGN_CENTER
p.Add(c)
Dim chunk1 As New Chunk("By TESt, test@yahoo.com " & vbLf, FontFactory.GetFont("Verdana", 8))
Dim p1 As New Paragraph()
p1.Alignment = Element.ALIGN_RIGHT
p1.Add(chunk1)
Doc.Add(p)
Doc.Add(p1)
Now i m reading the html string created above through xmlTextReader and htmlParser to parse html elements
Dim xmlReader As New System.Xml.XmlTextReader(New StringReader(html))
iTextSharp.text.html.simpleparser.HTMLWorker.Parse(Doc, xmlReader)
iTextSharp.text.html.simpleparser.HTMLWorker.ParseToList(New StringReader(html), Nothing)
Doc.Close()[/code]
<br/>
Can anyone help.
View the full article
<span style="font-size:small <span style="font-size:small
<pre class="prettyprint lang-vb Dim form As New HtmlForm()
form.Controls.Add(GridView1)
Dim sw As New StringWriter()
Dim hTextWriter As New HtmlTextWriter(sw)
form.Controls(0).RenderControl(hTextWriter)
Dim html As String = sw.ToString()
Dim Doc As New iTextSharp.text.Document()
Save Doc as PDF to Server
PdfWriter.GetInstance(Doc, New FileStream("\tserveruploadsexpenseAtest.pdf", FileMode.Create))
Doc.Open()
Adds Info to the Doc that is open to write.
Dim c As New Chunk("Export GridView to PDF Using iTextSharp " & vbLf, FontFactory.GetFont("Verdana", 15))
Dim p As New Paragraph()
p.Alignment = Element.ALIGN_CENTER
p.Add(c)
Dim chunk1 As New Chunk("By TESt, test@yahoo.com " & vbLf, FontFactory.GetFont("Verdana", 8))
Dim p1 As New Paragraph()
p1.Alignment = Element.ALIGN_RIGHT
p1.Add(chunk1)
Doc.Add(p)
Doc.Add(p1)
Now i m reading the html string created above through xmlTextReader and htmlParser to parse html elements
Dim xmlReader As New System.Xml.XmlTextReader(New StringReader(html))
iTextSharp.text.html.simpleparser.HTMLWorker.Parse(Doc, xmlReader)
iTextSharp.text.html.simpleparser.HTMLWorker.ParseToList(New StringReader(html), Nothing)
Doc.Close()[/code]
<br/>
Can anyone help.
View the full article