We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Flatten PDF document using Aspose.PDF for .NET - Flatten() throws object reference exception

When using attached pdf in conjunction with any other pdf file(s), Flatten() throws object reference exception. Why can't Aspose.Pdf handle flattening of that particular pdf?

Please let us know if you can provide a fix for this issue.

For reference, we are using Aspose.Pdf version 10.8 and here is our source code.

var finalDoc = new Aspose.Pdf.Document();

foreach (var fileInfo in fileInfos)
var file = fileInfo.FullName;
if (isEmailSign)
if (File.Exists(file + ".unsecure"))
File.Move(file + ".unsecure", file);
var tmpDoc = new Aspose.Pdf.Document(file);


Hi Tim,

Thanks for contacting support.

I have tested the scenario using Aspose.Pdf for .NET 11.2.0 and I am unable to notice any issue. As per my observations, the resultant file is properly being generated. Can you please try using following code snippet and share your findings.

Hi Tim,

We are sorry for the delayed response. I have tested the scenario with Aspose.Pdf for .NET 11.2.0 and unable to notice the exception. Please download and try latest version of Aspose.Pdf for .NET, it will resolve the issue.

Please feel free to contact us for any further assistance.

Best Regards,