Thanks for sharing sample PDF document.
I have tested the scenario by flattening the shared document with following code snippet, while using Aspose.Pdf for .NET 17.9 and was unable to observe any exception/error while execution.
Aspose.Pdf.Document doc = new Aspose.Pdf.Document(dataDir + "mortgage_en_re_09-06-2017.pdf");
var fields = doc.Form.Fields;
foreach (var f in fields)
doc.Save(dataDir + @"mortgage_en_re_09-06-2017_flattened.pdf");
doc = new Aspose.Pdf.Document(dataDir + "mortgage_en_re_09-06-2017.pdf");
doc.Save(dataDir + @"mortgage_en_re_09-06-2017_flattened2.pdf");
You may please check in the shared code snippet, that I have used two different ways to flatten the document and both ways generated output without throwing any exception. For your reference, I have uploaded the output document to the same location, where source document is.
However, would you please share a sample code snippet, along with your environment details, so that we can test the scenario again in our environment and address it accordingly.