l_pdfDoc.Flatten();
l_pdfDoc.Save(p_destinationFilePath);
l_pdfDoc.Dispose();
- Section 2: Text field <legal.RefPlanText> (value=“Related Plan Number:”) is defined as HIDDEN / Read Only but becomes visible when flattened. Should remain hidden after flattening.
- Section 4: There is a checkbox <terms.c> (value=CHECKED) defined as HIDDEN / Read Only which becomes visible after flattening. Should remain hidden.
- Sections 5, 6, 7: The interactive button <appendForm.E> (value=“Use Schedule”) is defined as “Visible but doesn’t print”. The expected behavior would be to have this button hidden or removed when flattened. (similar buttons that behave as expected include <agent_set_final>, <agent_import_profile>,<legal.insertNOPIDNUMBR>, <pickup_stc>, <appendForm.E7>,<appendForm.E2>, <appendForm.E4>
Bottom right corner of Page 1: There is a gray text field <formtag.c.0> which is defined as HIDDEN / Required. This field shows up as a gray box after flattening but should remain hidden.
- Page 2: The page index field <E2_1.Form_E2.form_E2.pageNum> and the total page count < E2_1.Form_E2.form_E2.numpages> in the top right corner are defined as Visible / Read Only but the become Hidden after flattening. Similar fields on the first page remain visible. In other tests, subsequent pages with similar field would also display correctly after flattening.
l_pdfDoc = new Aspose.Pdf.Document(p_sourceFilePath);
Aspose.Pdf.InteractiveFeatures.Forms.Field[] l_formFields = l_pdfDoc.Form.Fields;
foreach
(Aspose.Pdf.InteractiveFeatures.Forms.Field l_field in l_formFields)
{
if (l_field.GetType() == typeof(Aspose.Pdf.InteractiveFeatures.Forms.ButtonField) ||
l_field.Flags == Aspose.Pdf.InteractiveFeatures.Annotations.AnnotationFlags.Default)
{
try
{
if (l_field.GetType() == typeof(Aspose.Pdf.InteractiveFeatures.Forms.ButtonField))
l_pdfDoc.Form.Delete(l_field);
else
l_field.Flatten();
}
catch (Exception)
{
//continue loop
}
}
}
l_pdfDoc.Flatten();
l_pdfDoc.Save(p_destinationFilePath);
l_pdfDoc.Dispose();
l_pdfDoc = null;
Questions:
Is there another way to do this using aspose?
Considering some fields behave correctly after flattening and others with same attributes and definitions do not, could that mean the "flattening" function in Aspose is incomplete?
Thank you.