I’m using Aspose.PDF to create a PDF from a directory of JPG files. When the total size of the JPG files is up to 200 MB or so, the file is create properly. However, if I add in 250MB of JPG files, the Aspose.Pdf.Generator.Pdf.Save() routine saves a file with zero bytes.
Hi there,
We are sorry for the inconvenience caused. While testing the scenario with the latest version of Aspose.Pdf for .NET 9.3.0, we have managed to reproduce the reported issue and logged it in our bug tracking system as PDFNEWNET-37074 for further investigation and resolution. We will notify you via this thread as soon as it is resolved.
Please feel free to contact us for any further assistance.
Best Regards,
Hi there,
Thanks for your patience. We have investigated the issue and recommend using a new DOM approach and the File property of the Image class instead of ImageStream. This will help you accomplish your requirement without any issues. Please check the following code snippet for reference.
string curdir = "E:/Data/Images";
Document doc122 = new Document();
string[] files = Directory.GetFiles(curdir, ".");
if (files.Length == 0)
{
Console.WriteLine("No files found!");
return;
}
for (int ifile = 0; ifile < files.Length; ifile++)
{
Console.WriteLine("Adding image " + ifile + " out of " + files.Length);
Page page = doc122.Pages.Add();
// Set margins so image will fit, etc.
page.PageInfo.Margin.Bottom = 0;
page.PageInfo.Margin.Top = 0;
page.PageInfo.Margin.Left = 0;
page.PageInfo.Margin.Right = 0;
Aspose.Pdf.Image image = new Aspose.Pdf.Image();
page.Paragraphs.Add(image);
image.File = files[ifile];
}
doc122.Save(curdir + "newfileDOM.pdf");
Console.WriteLine("Done!");
Please feel free to contact us for any further assistance.
Best Regards,
The issues you have found earlier (filed as PDFNEWNET-37074) have been fixed in Aspose.Pdf for .NET 9.6.0.