The code below works with one record in repeater, but fails if multiple records. It generates this error: "Exception Details: System.NullReferenceException: Object reference not set to an instance of an object." I'm using Visual Studio Community 2015 and it tells me that "HTMLWorker is obsolete", but don't know if that's the problem because it does export a PDF if only 1 record is in the repeater.
Source Error:
Line 373: PdfWriter.GetInstance(pdfDoc, Response.OutputStream)
Line 374: pdfDoc.Open()
Line 375: htmlparser.Parse(sr)
Line 376: pdfDoc.Close()
Line 377: Response.Write(pdfDoc)
------------------------------
Imports System.IO
Imports System.Data
Imports iTextSharp.text
Imports iTextSharp.text.pdf
Imports iTextSharp.text.html.simpleparser
Imports iTextSharp.tool.xml
Protected Sub saveAll_Click(sender As Object, e As EventArgs) Handles saveAll.Click
Response.ContentType = "application/pdf"
Response.AddHeader("content-disposition", "attachment;filename=Lectures.pdf")
Response.Cache.SetCacheability(HttpCacheability.NoCache)
Dim sw As New StringWriter()
Dim hw As New HtmlTextWriter(sw)
Panel1.RenderControl(hw)
Dim sr As New StringReader(sw.ToString())
Dim pdfDoc As New Document(PageSize.LETTER, 50.0F, 50.0F, 60.0F, 60.0F)
''''HTMLWorker obsolete?
Dim htmlparser As New HTMLWorker(pdfDoc)
PdfWriter.GetInstance(pdfDoc, Response.OutputStream)
pdfDoc.Open()
htmlparser.Parse(sr)
pdfDoc.Close()
Response.Write(pdfDoc)
Response.End()
End Sub
Thank you!