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. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How do I flatten a PDF Form

Thread ID:

Created:

Updated:

Platform:

Replies:

91401 Nov 16,2009 10:28 PM UTC Nov 29,2017 10:20 AM UTC WinForms 5
loading
Tags: PDF
Ron Alan Sawyer
Asked On November 16, 2009 10:28 PM UTC

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 07:41 AM UTC


Hi Ronald,

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

Here is a sample code for your reference.

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


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

Regards,
DivyaGovindaraju.

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

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 12:22 PM UTC

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

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

Hi 

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 10:20 AM UTC

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 


CONFIRMATION

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.

Warning Icon 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.Close Icon

;