Aspose.pdf SaveAsTiff Problem with more then 1000 Pages

Hii Aspose Team

In our Application we convert the pdf in Tiff and save it.

In our tests we monitored followed issue:

If the pdf has more then 1000 Pages, the pdfConverter.SaveAsTIFF(filepath, tiffSettings) method occurs following exception. up to 1000 pages is everything ok and works fine.

System.Runtime.InteropServices.ExternalException (0x80004005): A generic error occurred in GDI+. at System.Drawing.Image.SaveAdd(Image image, EncoderParameters encoderParams) at #=z9q8xEPHRKjXP2gWUkdFasqh9lD6h9juyDlRWpOQmo3j_fSpNKA==.#=zK6vdKsI=(Bitmap #=zGIg6ARU=) at Aspose.Pdf.Devices.TiffDevice.Process(Document document, Int32 fromPage, Int32 toPage, Stream output)

Have you any idea?

if you want, we can deliver a sample application

Best regards from Zürich
Murat / kanlab

public string SaveAsTiff(string inputFile, string outputFolder)
{
    if (!File.Exists(inputFile))
        throw new FileNotFoundException($"Die Datei {inputFile} konnte nicht gefunden werden");

    //create
    var pdfConverter = new Aspose.Pdf.Facades.PdfConverter();
    // create Resolution object with 300 as an argument
    var resolution = new Resolution(240);
    // specify the resolution value for PdfConverter object - default is 150
    pdfConverter.Resolution = resolution;
    // bind the source PDF file
    pdfConverter.BindPdf(inputFile);
    // start the conversion process
    pdfConverter.DoConvert();
    //create TiffSettings object, set Compression and ColorDepth
    var tiffSettings = new TiffSettings { Compression = CompressionType.None };

    var guid = Guid.NewGuid().ToString();
    var filepath = Path.Combine(outputFolder, $"{Path.GetFileNameWithoutExtension(guid)}.tiff");

    pdfConverter.SaveAsTIFF(filepath, tiffSettings);
    pdfConverter.Close();
    return filepath;
}

@kanlab

Could you please make sure to use the latest version of the API i.e. Aspose.PDF for .NET 21.3. In case issue still persists, please share a sample console application with sample PDF document with us. We will test the scenario in our environment and address it accordingly. You can please add your files in .zip format and share with us. If file size exceeds 10MB, you can upload it to Google Drive or Dropbox and share the link with us.

Thank you for your answer.

In Nuget manager I have only version 21.2 (include prerelease)

if I can install the latest I will test it

Thank you and brest regards
Murat / kanlab

Hii
I was able to update to version 21.3 and I have still this error

I will create sample application and send you but this will take a few day or maybe week

Best regards
Murat / kanlab

@kanlab

Please take your time while preparing the sample application and share it with us. We will further proceed to assist you accordingly. Please also make sure that you keep the Debug Mode as x64 while testing the scenario.

Hi Asad.Ali

I uploaded a Test Project to github GitHub - M2xAy/AsposeSampleProjectGdiError

you have to copy your own License but I think this is not problem for you :wink:

Best regards
Murat from KanLab Zürich

@kanlab

We were able to reproduce the issue in our environment and have logged it as PDFNET-49671 in our issue tracking system for the sake of further investigation. We will look into its details and keep you posted with the status of its rectification. Please be patient and spare us some time.

We apologize for the inconvenience.

1 Like

Dear Apsose Team

This issue is urgent its not 1000 page its from 200 pages

please fix it

@kanlab

We have recorded your concerns and will surely take care of them during issue investigation and resolution. The issue is however logged recently and will be analyzed/investigated on a first come first serve basis. We will surely inform you as soon as we make some certain progress towards its resolution. Please spare us some time.

We are sorry for the inconvenience.

Hi Asad
is the bug with 1000 Pages fixed?
Best regards
Murat from kanlab

@kanlab

Regretfully, the earlier logged ticket could not get fully investigated yet. However, we have recorded your concerns and will surely consider them during issue analysis. We will inform you as soon as we have some significant updates regarding its resolution. Please spare us some time.

We apologize for the inconvenience.

Hi Asad
This issue is not a low prio issue, we can not convert pdf that has more then 1000 pages, now this ticket is open since 10 Months. Please set the prio of this ticket higher

Thank you
Best regards

@kanlab

Please note that the issues in free/normal support model are logged and investigated on first come first serve basis and they posses normal priority level. We offer paid/priority support option as well where you can report an issue that needs to be resolved on urgent basis and such issues posses the highest priority level. Nevertheless, we have recorded your concerns and escalated the issue to the next level of the priority. We will surely inform you as soon as we have some news about its resolution. Please spare us some time.

We are sorry for the inconvenience.

@kanlab

System.Drawing, Filesystem, Streams have many limitations. You are not using compression and you want to get a very large TIFF file with a resolution of 1984 x 2806 and 1089 pages, the file images size would be 24,250,305,024 bytes = 22.58 GB.

You can enable compression:

var tiffSettings = new TiffSettings { Compression = CompressionType.LZW };

An exception should not occur, and the file will be about 0.046 GB, which is 490 times less.

i have also faced something similar

@garnerfor

Please check our last response in this thread and use suggested option to prevent the issue. Please share your sample files and code snippet in case you still face any issues.

The issues you have found earlier (filed as PDFNET-49671) have been fixed in Aspose.PDF for .NET 22.11.