0

Using Foxit .NET SDK in an application to flatten a PDF. When I open the document using Phantom PDF document appears to be flattened. When the document is opened using Adobe Reader, the document appears not to be flattened and the form fields accessible. This is the code I'm currently using:

                // Code added to "Flatten" the PDFs
            SignatureFieldFlatteningOptions sFFO = new SignatureFieldFlatteningOptions();

            sFFO = SignatureFieldFlatteningOptions.Retain;

            FormFlatteningOptions fFO = new FormFlatteningOptions();

            fFO.DigitalSignatures = sFFO;

            mergeDocument.FormFlattening = fFO;

            mergeDocument.CompressionLevel = 9;

            byte[] pdfModifiedOutput = mergeDocument.Draw();

Is there something I should be doing differently? Has anyone else seen this problem?

crmauch
  • 21
  • 4
  • Is your form an AcroForm form, a XFA form, or a hybrid? – mkl Mar 22 '18 at 22:51
  • Actually don't know. Opened a PDF I had created previously (MS Word document saved as a PDF). In Phantom PDF clicked on the Form Tab, and added objects such as text boxes, dropdown lists, check boxes, etc. and saved the document. Since the form objects were added by Phantom I would assume the document is an AcroForm, but how would I tell which I had? I understand that Foxit products would not be able to flatten XFA Forms. But if the document is AcroForm it should have been flattened and if it was XFA wouldn't think that it would have flattened at all? – crmauch Mar 26 '18 at 12:38
  • I don't know the Foxit .NET SDK but if you shared source and result files, I could try and analyze them to determine what exactly happened. E.g. your options appear to ask the SDK to not flatten signature fields. But existing signature fields may enforce a certain state of other form fields which may be why the SDK doesn't flatten certain other fields either. – mkl Mar 26 '18 at 12:59

2 Answers2

0

Well, I found out that the problem is that I didn't have the true nature of the problem described to me. Turns out that users are using the "Typewriter" feature of Foxit PhantomPDF. The comments added by the typewriter remain editable and movable after the file has been "flattened". Any reason why this is and how I could get these "fields" to flatten?

crmauch
  • 13
  • 5
  • *"Any reason why this is"* - considering the property name `FormFlattening` you arranged the flattening of (AcroForm) form fields. "Typewriter" free text annotations are not form fields and, therefore, not subject to form flattening. *"and how I could get these "fields" to flatten"* - look for a *annotation flattening* functionality. – mkl Apr 04 '18 at 20:12
0

The SDK you are using is "Foxit PDF SDK for .NET." What I recommend instead is "Foxit PDF SDK for Windows (.NET API)," I am aware that the naming is very similar, however, the API for these two are different. Make a request for the "Foxit PDF SDK for Windows (.NET API)", you will receive a evaluation package(.zip file). In the evaluation package, you can find the flattening project at "examples\simple_demo\pdfflatten\pdfflatten.cs" The line of code that will flatten both annotation and form fields is page.Flatten(true, (int)PDFPage.FlattenOptions.e_FlattenAll);

Huy Tran
  • 1
  • 3