Avoid hidden fields of PDF form in export

Hi,

We have a PDF form with some labels and input controls along with some HIDDEN fields. In our application we display a PDF form and provide options to export or print the form. Now, while exporting a READ-ONLY PDF should be exported not the PDF form. This means, the exported PDF should look like the printed copy of the PDF form and it should not display the hidden fields of the PDF.

We have tried DoConvert of PdfConverter.

PdfConverter pc = new PdfConverter();
pc.BindPdf(fileStream);
pc.DoConvert();
for (int i = 0; i < pc.PageCount; i++)
{
System.IO.Stream mstream = new MemoryStream();
pc.GetNextImage(mstream);
Aspose.Pdf.Generator.Section sec1 = new Aspose.Pdf.Generator.Section(pdf1);
Aspose.Pdf.Generator.Image image10 = new Aspose.Pdf.Generator.Image(sec1);
.
.
.
.
.
.
.
}

This did not work of us. It exported the HIDDEN fields.
Any solution ?

Hi Dev,


Thanks for your inquiry. To make PDF file read only you can use the Flatten() method of Document class as following. It makes the form fields un-editable/in-accessible, simply removes the form fields and places their values as text string over the PDF file. Hopefully it will help you accomplish the task.

Document doc = new Document(“Form.pdf”);<o:p></o:p>

doc.Flatten();

doc.Save("Form_Flattened.pdf");

Best Regards,

Thank you for your reply.


I tried it out, it does remove the editable fields and places their values as text. But with this, it also brings the HIDDEN fields from the PDF form.

Aspose.Pdf.Document doc = new Document(fileStream1);
doc.Save(@“D:\file1.pdf”); //Editable form without HIDDEN fields
doc.Flatten();
doc.Save(@“D:\file2.pdf”); //Read only form with HIDDEN fields
Our requirement is to have a Read-only form without HIDDEN fields.
Any solution ?

Hi Dev,


Thanks for your feedback. Please share your sample PDF document, so we will test it at our end and will provide more information accordingly. Moreover, can you please also confirm the Aspose.Pdf API version that you are using?

We are sorry for the inconvenience caused.

Best Regards,