Hi Jéan Labuschagne,
We suspect that the input document you are using is enabled with extended functionalities, we cannot edit the PDF document with extended feature enabled, so the error message throws when flatten the PDF document.
As a work around we can remove this extended functionalities by using below code snippet,
Code snippet:
// Create Pdf Document.
PdfDocument doc = new PdfDocument();
//Load the existing Document.
PdfLoadedDocument ldoc = new PdfLoadedDocument(@"../../Data/input.pdf");
// Import the loaded Document.
doc.ImportPageRange(ldoc, 0, ldoc.Pages.Count - 1);
PdfForm form = doc.Form;
form.Flatten = true;
doc.Save("output.pdf");
doc.Close(true);
Process.Start("output.pdf"); |
Please try this in your side, if the issue is not resolved, please send us the input document which is helpful to proceed further in this.
Regards,
Sathya