public PdfFormField AddMultiLineTextField(string name, string text, BaseFont font, float fontSize, float llx, float lly, float urx, float ury) { PdfFormField field = PdfFormField.CreateTextField(writer, PdfFormField.MULTILINE, PdfFormField.PLAINTEXT, 0); SetTextFieldParams(field, text, name, llx, lly, urx, ury); DrawMultiLineOfText(field, text, font, fontSize, llx, lly, urx, ury); AddFormField(field); return(field); }
public PdfFormField AddSingleLinePasswordField(string name, string text, BaseFont font, float fontSize, float llx, float lly, float urx, float ury) { PdfFormField field = PdfFormField.CreateTextField(writer, PdfFormField.SINGLELINE, PdfFormField.PASSWORD, 0); SetTextFieldParams(field, text, name, llx, lly, urx, ury); DrawSingleLineOfText(field, text, font, fontSize, llx, lly, urx, ury); AddFormField(field); return(field); }
/** Gets a new text field. * @throws IOException on error * @throws DocumentException on error * @return a new text field */ public PdfFormField GetTextField() { if (maxCharacterLength <= 0) { options &= ~COMB; } if ((options & COMB) != 0) { options &= ~MULTILINE; } PdfFormField field = PdfFormField.CreateTextField(writer, false, false, maxCharacterLength); field.SetWidget(box, PdfAnnotation.HIGHLIGHT_INVERT); switch (alignment) { case Element.ALIGN_CENTER: field.Quadding = PdfFormField.Q_CENTER; break; case Element.ALIGN_RIGHT: field.Quadding = PdfFormField.Q_RIGHT; break; } if (rotation != 0) { field.MKRotation = rotation; } if (fieldName != null) { field.FieldName = fieldName; if (!"".Equals(text)) { field.ValueAsString = text; } if (defaultText != null) { field.DefaultValueAsString = defaultText; } if ((options & READ_ONLY) != 0) { field.SetFieldFlags(PdfFormField.FF_READ_ONLY); } if ((options & REQUIRED) != 0) { field.SetFieldFlags(PdfFormField.FF_REQUIRED); } if ((options & MULTILINE) != 0) { field.SetFieldFlags(PdfFormField.FF_MULTILINE); } if ((options & DO_NOT_SCROLL) != 0) { field.SetFieldFlags(PdfFormField.FF_DONOTSCROLL); } if ((options & PASSWORD) != 0) { field.SetFieldFlags(PdfFormField.FF_PASSWORD); } if ((options & FILE_SELECTION) != 0) { field.SetFieldFlags(PdfFormField.FF_FILESELECT); } if ((options & DO_NOT_SPELL_CHECK) != 0) { field.SetFieldFlags(PdfFormField.FF_DONOTSPELLCHECK); } if ((options & COMB) != 0) { field.SetFieldFlags(PdfFormField.FF_COMB); } } field.BorderStyle = new PdfBorderDictionary(borderWidth, borderStyle, new PdfDashPattern(3)); PdfAppearance tp = GetAppearance(); field.SetAppearance(PdfAnnotation.APPEARANCE_NORMAL, tp); PdfAppearance da = (PdfAppearance)tp.Duplicate; da.SetFontAndSize(RealFont, fontSize); if (textColor == null) { da.SetGrayFill(0); } else { da.SetColorFill(textColor); } field.DefaultAppearanceString = da; if (borderColor != null) { field.MKBorderColor = borderColor; } if (backgroundColor != null) { field.MKBackgroundColor = backgroundColor; } switch (visibility) { case HIDDEN: field.Flags = PdfAnnotation.FLAGS_PRINT | PdfAnnotation.FLAGS_HIDDEN; break; case VISIBLE_BUT_DOES_NOT_PRINT: break; case HIDDEN_BUT_PRINTABLE: field.Flags = PdfAnnotation.FLAGS_PRINT | PdfAnnotation.FLAGS_NOVIEW; break; default: field.Flags = PdfAnnotation.FLAGS_PRINT; break; } return(field); }