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.

Mon Oct 07, 2024 11:49 am

Recently migrated from .net core 6 to 8.
Also migrated the Spire.PDF to 10.2 from 8.6

After migration observe that memory conception on the deployed server is very high, many of the time getting OutOfMemory Exception from the Code. Basically I read the template PDF file and get the fields from FieldsWidgets and update the values, then save the file as PDF.

Given the code snippet for reference

string sourceTemplate = Path.Combine(Environment.CurrentDirectory, @"Templates\", templateFile);

var doc = new Spire.Pdf.PdfDocument();
doc.LoadFromFile(sourceTemplate);
PdfFormWidget formWidget = doc.Form as PdfFormWidget;
var fields = formWidget.FieldsWidget;
if (fields != null)
{
fields.SetValue("Customer first name", order.CustomerFirstName);
fields.SetValue("Customer last name", order.CustomerLastName);
}
doc.Form.IsFlatten = true;
using (MemoryStream stream = new MemoryStream())
{
doc.SaveToStream(stream);
doc.SaveToFile(tempFileName);
}

Do you have any input on this?

sudharsanm
 
Posts: 1
Joined: Mon Oct 07, 2024 11:21 am

Tue Oct 08, 2024 6:31 am

Hello,

Thanks for your inquiry.
Kindly note that we do not regularly update and maintain the free version. I tested our latest commercial version(Spire.PDF for .NET: 10.9.0) and found that its memory usage is similar to the version (Free Spire.PDF for .NET: 8.6), our commercial version includes more fixes and optimizations. So, we suggest you use the commercial version for testing first. If your problem still persists, please provide us with your input PDF document and complete code for investigation and analysis. You can upload here or send it to us via email( [email protected] ). Thank you in advance.

Sincerely,
Amin
E-iceblue support team
User avatar

Amin.Gan
 
Posts: 306
Joined: Mon Jul 15, 2024 5:40 am

Return to Spire.PDF

cron