We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Making all fields uneditable

Hi,

I need to be able to do the following: read in a pdf document, populate all the fields and then display this file in a separate browser window and make sure these fields cannot be edited by the user.

Here is what I'm doing:

form.FillField("form1[0].#subform[0].TextField1[1]", "7788");

form.SetFieldAttribute("form1[0].#subform[0].TextField1[1]", FieldFlag.READ_ONLY);

The populating works fine. However, I'm getting a message that form.SetFieldAttribute is obsolete. I checked your online documentation and the section about making a field read-only uses the form.SetFieldAttribute() function.

I'm already using the form object to read in the pdf, edit all the fields and then send the document to memory stream. Do I also need to use the FormEditor class? Is there any way to make the whole document uneditable as a whole withouth having to go through each and every field? On your website you say that FormEditor only works for AcroForm fields. Is this still true? How do I find out whether my pdf belongs to AcroForm or XfaForm? If it is XfaForm, what do I need to do them to lock all the fields?

thanks

Hi,

We need to update the online documentation for Change Form Field Attributes section, as its still referring to Form.SerFieldAttribute which is obsolete, please check SetFieldAttribute as its marked as obsolete. Sorry for causing the confusion.


If you need to make the form fields over Pdf document as un-editable, please use Form.FlattenAllFields and if you need to make any particular form field as un-editable, please use Form.FlattenField.


You can also use FormEditor.SetFieldAttribute to make the fields Read-Only.


Beside this, Aspose.Pdf.Kit offers the capability to make the whole Pdf file as read only, either its a Pdf form or general type. PdfFileSecurity allows you to set access privileges over Pdf file, also Supports AcroForm. For more related information, please visit Set Privileges on PDF Document