As we are using licensed version of Spire.PDF 9.3.4
my code :
- Code: Select all
Dim doc As PdfDocument = New PdfDocument()
Dim setting As PdfPageSettings = New PdfPageSettings()
setting.Size = PdfPageSize.A4 'New SizeF(612, 781)
setting.Margins = New Spire.Pdf.Graphics.PdfMargins(20)
Dim htmlLayoutFormat As PdfHtmlLayoutFormat = New PdfHtmlLayoutFormat()
htmlLayoutFormat.Layout = PdfLayoutType.Paginate
htmlLayoutFormat.IsWaiting = True
Dim htmlString As String = File.ReadAllText("C:\CustPDF\Katha-O-Kahini (Book Sellers)(200431153) as on 30 March 2023.html")
Dim thread As Thread = New Thread(Sub()
doc.LoadFromHTML(htmlString, True, setting, htmlLayoutFormat) 'Error at this point.
End Sub)
thread.SetApartmentState(ApartmentState.STA)
thread.Start()
thread.Join()
doc.SaveToFile("C:\CustPDF\Katha-O-Kahini (Book Sellers)(200431153) as on 30 March 2023.pdf")