0
我試圖用VB.NET和iTextSharp將網頁轉換爲PDF。我嘗試了許多不同的例子,似乎沒有任何工作(至少對我來說)。這是我得到的最接近的,但XMLWorkerHelper總是拋出異常Invalid nested tag head found, expected closing tag script
,無論分析哪個網頁。找到無效的嵌套標籤頭
Dim webClient As New System.Net.WebClient
Dim result As String = webClient.DownloadString("http://google.com")
Dim doc As New Document(PageSize.A4)
Dim writer As PdfWriter = PdfWriter.GetInstance(doc, New System.IO.FileStream("c:\test.pdf", System.IO.FileMode.Create))
Dim sr As New System.IO.StringReader(result)
Try
XMLWorkerHelper.GetInstance().ParseXHtml(writer, doc, sr)
Catch ex As Exception
End Try
我使用iTextSharp的5.4.2.0和.NET Framework 4
感謝