C# PDF to TIFF Conversion fails because of high Memory Usage

The PDF To TIFF conversion in the Aspose.PDF API (v23.1.1.0) is performing the conversion in memory before writing to the output stream.
This limits the size of the documents we can convert and write to file. A PDF file with 150 pages of 10MB uses 2GB to 3GB+ Memory.

Please do let us know if you need more info.

Hi! We have similar issues with the Aspose.PDF(v23.1.1.0).
Could you please assist on this?

@Manikandan.Murugan

Have you tried using 23.4 version of the API? Please share your sample PDF and code snippet with us. We will test the scenario in our environment and address it accordingly.

We will try 23.4 version of the API and update.

@Manikandan.Murugan

Sure, please take your time to test with the latest version and let us know by sharing sample code and file in case you still face any issues.

The memory issue appears to be fixed in 23.4. I processed a 700 page PDF without issues.

v23.4 is missing the Aspose.Pdf.XpsLoadOptions. Could you please the alternative options for the same?

@Manikandan.Murugan

Please try to use it with complete namespace like Aspose.Pdf.XpsLoadOptions.

@jhillflorida

It is nice to know that things have started working after upgrading to the latest version.

image.png (4.2 KB)
We are using the complete name.
Aspose.Pdf.XpsLoadOptions options = new Aspose.Pdf.XpsLoadOptions();
Error: The type or namespace name ‘XpsLoadOptions’ does not exist in the namespace ‘Aspose.Pdf’ (are you missing an assembly reference?)

@Manikandan.Murugan

We could not notice this issue at our end. XpsLoadOptions class is accessible. Can you please share a sample console application so that we could observe this issue and address it accordingly?

Hi!

With the v23.4 we can only see 10%-20% reduction in the Memory usage compared to 23.1.
Could you please suggest other solutions or will there be any improvement in the future releases?

Thanks

@Manikandan.Murugan

23.5 version is just rolled out and you can try it as well. Furthermore, we need your sample document to test it and observe memory consumption in our environment so that we can further comment on the situation and share our feedback.

Hi Team,

We have the files that caused the issue are ready to be shared. Please let me know how I can share the files securely to you as I cannot share them here!

@Manikandan.Murugan

We have sent you a private message and you can share your files in reply to that.

We have shared the sample files as instructed. Please purge/destroy them once tested.

@Manikandan.Murugan

We have downloaded the files. As requested before, can you please share the sample code snippet that you are using so that we can test accordingly.

Thanks!

I have shared the code snippet.

@Manikandan.Murugan

We used 23.7 version of the API and the following code snippet to test the scenario in our environment. We could not notice the OOM Exception. Can you please make sure that you are using the latest version? Also, please let us know about your complete environment details i.e. OS Name and Version, Application Type, RAM Size, etc.

It is also possible that the exception is being thrown due to other Aspose API that is being used. Please try to create a separate console application and test at your end using only Aspose.PDF and let us know in case you find any issues.

Aspose.Pdf.Document _document = new Aspose.Pdf.Document(dataDir + "1.pdf");
TiffSettings options = new TiffSettings();
//options.Compression = CompressionType.CCITT4;
Resolution resolutionObj = new Resolution(200);
options.Shape = ShapeType.None;
options.CoordinateType = PageCoordinateType.MediaBox;
options.Brightness = 0.5F;
TiffDevice tiffDevice = new TiffDevice(resolutionObj, options);
RenderingOptions RenderingOption = new RenderingOptions();
RenderingOption.IgnoreResourceFontErrors = true;


tiffDevice.RenderingOptions = RenderingOption;
using (FileStream imageStream = new FileStream(dataDir + DateTime.Now.Millisecond + @".tif", FileMode.Create))
{
    tiffDevice.Process(_document, imageStream);
    imageStream.Close();
}

Thanks Team,

We will verify and update.

Hi Team,
We only see about 3-5% reduction in the memory usage with the latest Aspose.PDF library as suggested.

OS: Windows Server 2016
RAM: 8GB
Processor Cores: 4
Type: Windows Forms Application
Framework: .NET 4.7