Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Set all PDF Fields to ReadOnly

Tags:

c#

itext

In iTextSharp is there a way to set ALL fields on a form to read only? Currently I'm setting each one individually which is a pain like...

formFields.SetFieldProperty( "Applicant.Phone", "setfflags", PdfFormField.FF_READ_ONLY, null );
formFields.SetFieldProperty( "Applicant.SSN", "setfflags", PdfFormField.FF_READ_ONLY, null );

etc.

like image 241
Jared Avatar asked Sep 12 '25 18:09

Jared


1 Answers

Can't you do something like this:

foreach (DictionaryEntry de in pdfReader.AcroFields.Fields)
{
  formFields.SetFieldProperty(de.Key.ToString(), 
                             "setfflags", 
                              PdfFormField.FF_READ_ONLY, 
                              null);
}
like image 51
Tom Studee Avatar answered Sep 14 '25 10:09

Tom Studee