Please give a brief summary of your issue:
(Think of this as an email subject)
Bad allocation when using pdftron in Azure
Please describe your issue and provide steps to reproduce it:
(The more descriptive your answer, the faster we are able to help you)
I have taken some code to test pdf creation from a template (PDFTron) and everything works fine locally. When I push the code to an App Service running in Azure I get the following exception
pdftron.Common.PDFNetException
Exception:
Message: document layout failed: bad allocation
Conditional expression:
Version : 9.2.0-91be0af529
Platform : Windows
Architecture : AMD64
Filename : FlowToPDFConversion.cpp
Function : PDF::DocxConversion::Convert()
Linenumber : 189
As it says bad allocation I was suspecting a memory issue, but I checked the App Service and there is plenty of memory available and when I run the code locally I see no issues in huge memory usage either.
This is the code I’m using:
var templateParams = new
{
Title = $"Hello world"
};
using var doc = new PDFDoc();
var templateOptions = new OfficeToPDFOptions();
templateOptions.SetTemplateParamsJson(JsonSerializer.Serialize(templateParams));
pdftron.PDF.Convert.OfficeToPDF(doc, "DownloadTemplate.docx", templateOptions);
doc.Save(outputStream, pdftron.SDF.SDFDoc.SaveOptions.e_linearized);
Can someone help me figure out what’s going wrong?
After trying with latest PDFNet 9.3, we are still facing issue with azure service, in local the microsoft document file converts within seconds to PDF/XOD. however we deploy same code to azure app service (azure functions). we are seeing same issue with above errors or takes lot of time to respond(around 2/3 hours) with the same file. Which is like a small document file of 1.8 mb.
This only affects font substitution server side, when you are doing the conversion. In this mode PDFNet will no longer use the fonts registered with Windows OS.
Instead, for decent initial font coverage, please follow this guide, and download the Self serve font package.