user2138736
user2138736

Reputation:

How do I make text field to be hidden?

I'd like to create a text field with iTextSharp that is not visible. Here's code I'm using to create a textfield:

TextField field = new iTextSharp.text.pdf.TextField(writer, new iTextSharp.text.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());

Upvotes: 1

Views: 3119

Answers (2)

Bruno Lowagie
Bruno Lowagie

Reputation: 77606

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 a SetVisibility() method or a Visibility property.

Using a render mode as suggested by another person in answer to this question applies to content written to a content stream, XObject or appearance. You are asking to hide a field, and that's something completely different.

Upvotes: 1

Rachel Gallen
Rachel Gallen

Reputation: 28593

You could use TEXT_RENDER_MODE_INVISIBLE but Ctrl+A will still select it - you have been warned!

Upvotes: 0

Related Questions