How to add a hidden text field?

I'd like to create a text field with iTextSharp that is not visible.

6th November 2015
admin-marketing

Here's code I'm using to create a text field:

 

TextField field = new TextField(writer, new Rectangle(x, y - h, x + w, y), name);
field.BackgroundColor = new BaseColor(bgcolor[0], bgcolor[1], bgcolor[2]);
field.BorderColor = new BaseColor(
    bordercolor[0], bordercolor[1], bordercolor[2]);
field.BorderWidth = border;
field.BorderStyle = PdfBorderDictionary.STYLE_SOLID;
field.Text = text;
writer.AddAnnotation(field.GetTextField());

 

Posted on StackOverflow on May 21, 2013 

In Java, the TextField class has a method named setVisibility() inherited from its parent, the BaseField class. Possible values are:

  • BaseField.VISIBLE,
  • BaseField.HIDDEN,
  • BaseField.VISIBLE_BUT_DOES_NOT_PRINT, and
  • BaseField.HIDDEN_BUT_PRINTABLE.

As you're using iTextSharp, you should look for the Visibility property.

field.Visibility = BaseField.HIDDEN;


Contact

Still have questions? 

We're happy to answer your questions. Reach out to us and we'll get back to you shortly.

Contact us
Stay updated

Join 11,000+ subscribers and become an iText PDF expert by staying up to date with our new products, updates, tips, technical solutions and happenings.

Subscribe Now