Free Support Forum - aspose.com

Convert PDF file to TIFF using C# with Aspose.PDF - Outofmemory exception occurs

Hi Aspose,

We are converting attached PDF file into TIFF images while converting it will giving me Out of memory exception.

Please find attached sample source code which we used for conversion.

We are using Aspose.Pdf file version 17.6.0.0 and product version 17.6

Please advise.

70531 Attachment.zip (554.6 KB)

@serversupport

We have checked the code snippet that you shared and noticed that you were using GifDevice to generate TIFF images. Please note that TiffDevice is offered by Aspose.PDF in order to generate TIFF images.

We tested the scenario using following code snippet with Aspose.PDF for .NET 20.1 and were unable to notice any issue. Would you kindly try using following code snippet with latest version of the API and in case you still face any issue, please let us know. For your kind reference, output TIFF images are also attached.

using (FileStream imageStream = new FileStream(dataDir + page.Number.ToString("000") + ".tiff", FileMode.Create))
{
  TiffSettings tiffSettings = new TiffSettings()
  {
    Compression = CompressionType.LZW,
    Depth = ColorDepth.Format8bpp
  };
  // Create TIFF device
  TiffDevice tiffDevice = new TiffDevice(resolution, tiffSettings)
  {
   RenderingOptions = new RenderingOptions
   {
    SystemFontsNativeRendering = true,
    UseNewImagingEngine = true
   }
 };

 // Convert a particular page and save the image to stream
 tiffDevice.Process(pdfDocument, page.Number, page.Number, imageStream);
 imageStream.Close();
}

outputtiff.zip (1.0 MB)