Spire.PDF is a professional PDF library applied to creating, writing, editing, handling and reading PDF files without any external dependencies. Get free and professional technical support for Spire.PDF for .NET, Java, Android, C++, Python.

Thu Mar 30, 2023 11:57 am

While converting Html string to pdf using vb.net windows application (version 2022) getting an error for more than 30 pages. System.OutOfMemoryException: 'Out of memory.'

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")

SwethaKalva
 
Posts: 9
Joined: Thu Mar 30, 2023 11:46 am

Fri Mar 31, 2023 8:59 am

Hi,

Thank you for your message.
I simulated some html files to test your code, but I didn't reproduce the problem of 'Out of memory'. To help us conduct further investigations, please share the following information with us. Thank you.
1.The html file you entered can be uploaded here or emailed( support@e-iceblue.com )Provided to us.
2. Your system information (such as Win10, 64 bit) and regional settings (such as China, China).

Best Regards,
Herman
E-iceblue support team
User avatar

Herman.Yan
 
Posts: 115
Joined: Wed Mar 08, 2023 2:00 am

Fri Mar 31, 2023 9:14 am

Thank you for the reply. I would check once again from my end and if any issues i would return back with my query.

SwethaKalva
 
Posts: 9
Joined: Thu Mar 30, 2023 11:46 am

Mon Apr 03, 2023 1:14 am

Hi

Thank you for your message.
If you find any problems during the inspection, please feel free to consult

Best Regards,
Herman
E-iceblue support team
Last edited by Herman.Yan on Mon Apr 03, 2023 8:17 am, edited 1 time in total.
User avatar

Herman.Yan
 
Posts: 115
Joined: Wed Mar 08, 2023 2:00 am

Mon Apr 03, 2023 5:22 am

Hi Herman,

My pages issue resolved but problem is that when the html string is converting to PDF some of the data is getting cutoff at the end of the line specially when the data is in the HTML table tags. Is it possible to add the header for each page of the HTML string while converting to pdf using vb.net.

regards,
swetha.

SwethaKalva
 
Posts: 9
Joined: Thu Mar 30, 2023 11:46 am

Mon Apr 03, 2023 9:14 am

Hello,

Thanks for your message.
Spire.PDF does not support adding header to each page when converting HTML to PDF. However, you can refer to this tutorial (Add Header to Existing PDF in C#/VB.NET) to add the header on the converted PDF file. Regarding the missing issue, I first suggest that you try to use the QT way to convert it. If your issues still exists, please provide us with your HTML document for further analysis. You can upload it here or provide to us by email (support@e-iceblue.com)

Best Regards,
Herman
E-iceblue support team
User avatar

Herman.Yan
 
Posts: 115
Joined: Wed Mar 08, 2023 2:00 am

Return to Spire.PDF