Last active
July 5, 2021 11:41
-
-
Save aspose-com-kb/fd802d086f312257b732aba7a68378b2 to your computer and use it in GitHub Desktop.
Flatten All of the PDF Form Fields in C#. The details of this gist can be found in this topic https://kb.aspose.com/pdf/net/how-to-flatten-pdf-form-fields-in-csharp/.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
//Add Aspose.Pdf for .NET package reference | |
//Use following namespaces to flatten PDF form Fields | |
using Aspose.Pdf; | |
using Aspose.Pdf.Facades; | |
namespace FlattenPDFFormFields | |
{ | |
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
//Set Aspose license before flattening PDF form fields | |
//with the help of Aspose.Pdf for .NET | |
Aspose.Pdf.License AsposePDFLicense = new Aspose.Pdf.License(); | |
AsposePDFLicense.SetLicense(@"c:\asposelicense\license.lic"); | |
//create an object of Form class to initiate form field flattening | |
Form PDFFormToBeFlattened = new Form(); | |
//Bind the PDF file which contains the form fields to be flattened | |
PDFFormToBeFlattened.BindPdf("SamplePDFFormwithFields.pdf"); | |
//Use FlattenAllFields method to flatten all of the fields in the | |
//PDF form loaded above | |
PDFFormToBeFlattened.FlattenAllFields(); | |
//Save output PDF file with form fields flattened using Save method | |
//of Form object | |
PDFFormToBeFlattened.Save("OutputPDFwithFlattenedFormFields.pdf"); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment