Good morning,
Hi Rendu,
I have attached the file again. It seems to only throw the exception when saving to a memory stream. If I save to a file it works fine.
Hi Rendu,
I have attached the entire solution as a .zip.
Hi Rendu,
Thanks for sharing your source project. I have tested it over Win 7 64 bit, 8 MB RAM and Aspose.Pdf for .NET 10.9.0 and unable to notice OutOfMemoryException. Please use the latest version of Aspose.Pdf for .NET if you are using some old one. Moreover, you may optimize the resultant PDF document file size using the following code in the ImagetoPdf
method.
//Global.log.Debug("[ConvertImagesToPdf] - Saving created Pdf document to memory stream");
MemoryStream ms = new MemoryStream();
byte[] outputDocument = null;
doc.Save(ms);
doc = new Document(ms);
//
// Optimze the file size by removing
// unused objects
doc.Optimize();
doc.OptimizeResources(new Document.OptimizationOptions()
{
AllowReusePageContent = true,
LinkDuplicateStreams = true,
RemoveUnusedObjects = true,
RemoveUnusedStreams = true,
CompressImages = true,
ImageQuality = 80
});
ms = new MemoryStream();
doc.Save(ms);
outputDocument = ms.ToArray();
We are sorry for the inconvenience caused.
Best Regards,