Free Support Forum - aspose.com

FormEditor.SetFieldAttribute not working after 3.5.0.0

Hi,


I tried to set a PDF form field to ReadOnly using FormEditor.SetFieldAttribute method, but it is not working after I upgrade pdf.kit from 3.4.0.0 to 3.5.0.0.
I don’t want to flatten fields, just change field attribute to ReadOnly.

Regards,

Hi Yosuke,

In order to set a field’s attribute you first need to save the file in which you add a field. Then you have to reopen the file using FormEditor class and apply the field attribute. I have tested using Aspose.Pdf.Kit for .NET 3.6.0.0 with the following code:


//Open the document and create a FormEditor object

FormEditor formEditor = new FormEditor(“input.pdf”, “output.pdf”);

//add a text field

formEditor.AddField(FieldType.Text, “text1”, 1, 200, 550, 300, 575);

//Close the document

formEditor.Save();


//fill the field with some value

Aspose.Pdf.Kit.Form form = new Aspose.Pdf.Kit.Form(“output.pdf”, “output2.pdf”);

form.FillField(“text1”, “some sample text”);

form.Save();



formEditor = new FormEditor(“output2.pdf”, “output3.pdf”);

//set field attribute - PropertyFlag enumeration contains 4 options

formEditor.SetFieldAttribute(“text1”, PropertyFlag.ReadOnly);

//Close the document

formEditor.Save();


You can download the latest version from this link and use the above snippet to try at your end. If problem persists then please share the PDF file and the code snippet you're having problem with.

If you have any other questions, please do let us know.
Regards,

Hi,


I tested sample code you provided, but still in stuck with setteing readonly attribute using pdf.kit 3.5 or above. (3.4 works as I intended though)

I attached sample project, so can you investigate what is wrong with my code or pdf?

regards,

Hi Yosuke,

I have logged this issue as PDFKITNET-10495 in our issue tracking system. Our team will be looking into the matter and you’ll be updated via this forum as the issue is resolved.

We’re sorry for the inconvenience.
Regards,

The issues you have found earlier (filed as 10495) have been fixed in this update.


This message was posted using Notification2Forum from Downloads module by aspose.notifier.