Free Support Forum -

Latest Aspose.PDF nuget package throwing errors on some pdf

Hi Aspose Support,

We are using latest Aspose.PDF nuget package i.e. 21.3.0 released on March 21, 2021 to flatten the PDFs but its throwing an error on some pdf with this exception message “Object reference not set to an instance of an object”

Here is the sample code snippet

SampleInputFile.pdf (58.3 KB)

   public static void FlattenPdf(string pdfFilePath)




            if (string.IsNullOrWhiteSpace(pdfFilePath))




            using var document = new Document(pdfFilePath);





        catch (Exception ex)


            throw ex;



Stack trace of error:

at Aspose.Pdf.Page.#=zNvIePhg=(Boolean #=zR$IgorztICpHAjrGLw==)

at Aspose.Pdf.Document.#=zTmx6GwQ=()

at Aspose.Pdf.Document.Flatten(FlattenSettings flattenSettings)

at Aspose.Pdf.Document.Flatten()


I have been able to reproduce the issue shared and a ticket with ID PDFNET-49733 has been created to further investigate and resolve the issue. This thread has been linked with the issue so that you may be notified once the issue will be fixed.