The code is supposed to grab one or more links, grab the contents of that link(s) and load them into pdf. For the most part, it works.
The issue we are having currently is that sometimes document or documents are loaded correctly into the PDF; sometimes, the same document that loaded correctly a minute ago will either load blank into pdf or the image portion of the document is not loaded.
I thought that by adding Response.Clear(), the original load will flush out and document is ready to load again. That hasn’t been the case so far.
Protected Sub btnGetCheck_Click(ByVal sender As Object, ByVal e As EventArgs)
Dim doc As New PdfDocument()
Dim baseLink As String = _
"http://default.html?mode=print&ino=pan&s=g"
For Each r As GridViewRow In dsParcels.Rows
If CType(r.Cells(0).FindControl("link"), CheckBox).Checked Then
Dim url As String = baseURL & "&gen=" & r.Cells(1).Text
HtmlToPdf.ConvertUrl(url, doc)
' Setup HttpResponse headers
Response.Clear()
Response.ClearHeaders()
Response.ContentType = "application/pdf"
End If
Next
doc.Save(Response.OutputStream)
Response.Flush()
Response.End()
End Sub
Can anyone suggest what’s going wrong?
Kenny, you add your documents one-by-one, but every time you call
Response.Clear()which resets response buffer (removing the already generated PDFs).