We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy.
Unfortunately, activation email could not send to your email. Please try again.

How do I flatten a PDF Form

Thread ID:





91401 Nov 16,2009 05:28 PM Nov 29,2017 05:20 AM Windows Forms 5
Tags: PDF
Ron Alan Sawyer
Asked On November 16, 2009 05:28 PM

I am being dense I guess, but I just do not see how to flatten a PDF form. Can you tell me?

Divya G [Syncfusion]
Replied On November 19, 2009 02:41 AM

Hi Ronald,

Thank you for using Syncfusion products.
Regarding Issue : How do flatten a PDF Form

Here is a sample code for your reference.

PdfLoadedDocument doc = new PdfLoadedDocument(@"..\..\data\401k.pdf");
PdfLoadedForm form = doc.Form;
form.Flatten = true;

Please take a look into it and let me know if you have any queries.


Ron Alan Sawyer
Replied On November 19, 2009 06:01 AM

Thank you for your response. That is exactly how I would have expected it to work. However, when I place the line of code form.Flatten = true; into my code, I receive an error on the line doc.Save("Sample.pdf");

The error says that "value cannot be null" parameter name: text.

If I comment out form.Flatten = true, the code works and the PDF is saved.

I will try to create a small application that shows this later this morning and update you with it at that time.

Divya G [Syncfusion]
Replied On November 25, 2009 07:22 AM

Hi Ronald,
Did you flatten the PDF form? Let me know the status and if you have any queries.

Jéan Labuschagne
Replied On November 29, 2017 01:03 AM


I have tried the method you provided, it saves the new file successfully but when I try and open it i get an error. I have attached a screenshot of this error. 

Thank you for your assistance,
kind regards Jéan

Attachment: ErrorImage_67f9741f.rar

Sathya Ponnusamy [Syncfusion]
Replied On November 29, 2017 05:20 AM

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; 

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. 



This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.