Aspose.PDF 19.5 C# - NullReferenceException in Pdf.Document constructor

We are trying to convert PDF files to TIFF using Aspose.Pdf 19.5 but having issues handling all PDF files. The conversion code is as below:

        // Create PDF object
        using (var pdf = new Aspose.Pdf.Document(filePath))
        {
            tiffSettings = tiffSettings ?? new TiffSettings
            {
                Compression = CompressionType.LZW,
                Depth = ColorDepth.Default,
                SkipBlankPages = false
            };

            // Create Tiff Device object with settings and Resolution Object
            var tiffDevice = new TiffDevice(tiffSettings);

            // Save the pdf to a Tiff
            tiffDevice.Process(pdf, newFilePath);
        }

We get NullReferenceException in two places for various files:

  1. Within the constructor for Document
  2. Within the Process call for TiffDevice

Attached are an example of files causing a null reference for each case.

NullRef_Constructor_ex1.pdf (577.2 KB)
NullRef_Process_ex1.pdf (268 KB)

We’ve tried passing null tiffSettings, so that it uses the settings above, and also with same settings as above but with 8bpp color depth.

@mguthrie

Thanks for contacting support.

We have tested the scenario in our environment using following code snippet to initialize TiffDevice and API was able to generate output without any issue. For your kind reference, an output file is also attached.

TiffDevice tiffDevice = new TiffDevice(resolution, tiffSettings)
{
  RenderingOptions = new RenderingOptions
  {
    SystemFontsNativeRendering = true,
    UseNewImagingEngine = true
   }
};

Sample.zip (1.4 MB)

We were able to replicate this issue in our environment and logged it as PDFNET-46506 in our issue tracking system. We will further look into details of it and keep you informed with the status of it correction. Please be patient and spare us little time.

We are sorry for the inconvenience.

Thank you for your response. However, Process still did not work for me when specifying Resolution and RenderingOptions. What values did you use for Resolution and TiffSettings? What version did you use? (I am using the 19.5 nuget package.)

@mguthrie

We used the TiffSettings same as you shared in your first post and we used Resolution as following:

Resolution resolution = new Resolution(300);
// Create TiffSettings object
TiffSettings tiffSettings = new TiffSettings()
{
 Compression = CompressionType.LZW,
 Depth = ColorDepth.Default,
 SkipBlankPages = false
}; 

Also, we have tested the scenario with Aspose.PDF for .NET 19.5.

Thank you, Process is now working on my end as well.

I’ll await word on the fix for Document constructor.

@mguthrie

Thanks for the feedback.

We will surely let you know in case of further updates regarding logged issue.

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