Converting multi-layer PDF to JPG Image using Aspose.PDF for .NET - process hangs and throws error

Hi, we are receiving multi layered pdfs from our customers and we want to convert these to jpg’s. The conversion process just hangs and then errors. We have tried this on different versions including the latest v21.1, and also on your live demo site and always experience the same error. Can you investigate this please and I can supply example files as required. Thanks

@Mikea76

Could you please share your sample PDF document with us so that we can test the scenario in our environment and address it accordingly.

Apologies, I responded to the email as well.
Here is the file Test Conversion PDF.pdf (7.5 MB)
Thanks

@Mikea76

We tested the scenario in our environment using Aspose.PDF for .NET 21.1 and following code snippet:

Convert PDF to JPG

var fs = new FileStream(dataDir + "Test Conversion PDF.pdf", FileMode.Open);
Document pdfDocument = new Document(fs);
foreach (Page page in pdfDocument.Pages)
{
 using (FileStream imageStream = new FileStream(dataDir + "image" + page.Number + ".jpg", FileMode.Create))
 {
  Resolution resolution = new Resolution(300);
  JpegDevice jpegDeviceLarge = new JpegDevice(resolution, 100);
  jpegDeviceLarge.RenderingOptions.InterpolationHighQuality = true;
  jpegDeviceLarge.RenderingOptions.UseNewImagingEngine = true;
  jpegDeviceLarge.Process(page, imageStream);
 }
}

We were unable to notice any issue. Above code generated attached output image file.

image1.jpg (2.6 MB)

Could you please share a sample console application which is able to replicate the issue in our environment as well. We will again test the scenario and address it accordingly.

Thanks for your response.
We have proven that the scenario works as expected when compiled and executed as 64bit. It is when compiled as 32Bit that the out of memory exception occurs (‘System.OutOfMemoryException’ in Aspose.PDF.dll) and it fails to convert.
Could you try this within the above scenario and provide a response as to how this could be addressed?
Thanks

@Mikea76

Usually, it is recommended to use x64 mode of debugging while dealing with large size PDFs or the PDFs with complex structure as they need to access more memory in order to get correctly handled. With x64 mode, your program has access to full installed memory and that is the reason that you are not facing any issue in this mode. The program has very limited access to memory in x86 or 32-bit mode of debugging which causes OutOfMemoryException.

We will however further investigate the scenario and determine the possibility to convert this file under 32-bit mode. Would you kindly share the complete stack trace information of the exception with us. We will further proceed to log the ticket accordingly.

Thanks for the response and please find below the Stack Trace

System.OutOfMemoryException: Exception of type ‘System.OutOfMemoryException’ was thrown.
at System.Collections.Generic.List1.set_Capacity(Int32 value) at System.Collections.Generic.List1.EnsureCapacity(Int32 min)
at System.Collections.Generic.List`1.Add(T item)
at #=zBpwQv4kqNuLWVhg1HEhtnz7_CAO$G4ntLYb2oNMy3jJW.#=zX7Tf3QdJuloq(#=zaFrGza58Ln7_lV1IeXXChjx4nFvpdz$Jyw== #=ziXxl_S8=, #=zQZCGyYR2NZTey$qN_cb11JoSYrvKMTinh_TLtsZ3mvRb #=zfxtPRAypyZYf9wmWfw==, Boolean #=zpHDc2PeTsjQm, Boolean #=z3fWlk28mf06B)
at #=zBpwQv4kqNuLWVhg1HEhtnz7_CAO$G4ntLYb2oNMy3jJW.#=zInOmkls=(#=z2Dl9O39kx1DDITklJ8uoxODUL73b #=zKaVF8Yg=, #=zOrqnFYPnIgXaCzlc9qItrbJNiWsxpfTmZQ== #=zuJ_P5xg=, #=zW1YAYkz5bcj2nQoDh_ydVwJTyulyuYqLkeKSDhE= #=zADP_9nc=, #=zLNXFkb4EpseBcwMvmTIfntQEOyWJzMiOqMTQeb5ZSewr& #=zUFbvZ0U=)
at #=zb1I0Zf4u2TAstjzbagZUm5TRW5td.#=zqG2kzy0=(#=zLNXFkb4EpseBcwMvmTIfntQEOyWJzMiOqMTQeb5ZSewr& #=zUFbvZ0U=)
at #=zb1I0Zf4u2TAstjzbagZUm5TRW5td.#=zqG2kzy0=()
at Aspose.Pdf.Devices.ImageDevice.#=zqG2kzy0=(Page #=zuJ_P5xg=)
at Aspose.Pdf.Devices.JpegDevice.Process(Page page, Stream output)

@Mikea76

We have logged an investigation ticket as PDFNET-49316 in our issue tracking system for this case. We will look into its details and let you know as soon as the ticket is resolved. Please be patient and spare us some time.

Hi, can you let me know if there has been any progress with this ticket? PDFNET-49316
thanks

@Mikea76

The ticket has recently been logged in our issue tracking system and is not yet investigated. It will be analyzed and fixed on a first come first serve basis as per the policy of normal support model. We will surely let you know as soon as we have some certain news about its resolution. Please give us some time.

We are sorry for the inconvenience.

Hi, this is really starting to raise concerns within our customer base and we would welcome any urgent update(s) on the following ticket? PDFNET-49316.
Thanks

@Mikea76

We are afraid that the earlier logged ticket has not been yet investigated due to other issues logged prior to it. However, we have recorded your concerns and will surely consider them during its analysis. We will inform you as soon as some significant progress is made towards its resolution. We highly appreciate your patience in this matter.

We apologize for the inconvenience.