How do I make text field to be hidden?

六眼飞鱼酱① 提交于 2021-02-10 20:41:54

问题


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());

回答1:


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.




回答2:


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



来源:https://stackoverflow.com/questions/16665562/how-do-i-make-text-field-to-be-hidden

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!