Ejemplo n.º 1
0
 /**
  * @param field
  * @param name
  * @param llx
  * @param lly
  * @param urx
  * @param ury
  */
 public void SetSignatureParams(PdfFormField field, String name, float llx, float lly, float urx, float ury)
 {
     field.SetWidget(new Rectangle(llx, lly, urx, ury), PdfAnnotation.HIGHLIGHT_INVERT);
     field.FieldName = name;
     field.Flags     = PdfAnnotation.FLAGS_PRINT;
     field.SetPage();
     field.MKBorderColor     = Color.BLACK;
     field.MKBackgroundColor = Color.WHITE;
 }
Ejemplo n.º 2
0
 public void SetTextFieldParams(PdfFormField field, string text, string name, float llx, float lly, float urx, float ury)
 {
     field.SetWidget(new Rectangle(llx, lly, urx, ury), PdfAnnotation.HIGHLIGHT_INVERT);
     field.ValueAsString        = text;
     field.DefaultValueAsString = text;
     field.FieldName            = name;
     field.Flags = PdfAnnotation.FLAGS_PRINT;
     field.SetPage();
 }
Ejemplo n.º 3
0
 public void SetChoiceParams(PdfFormField field, string name, string defaultValue, float llx, float lly, float urx, float ury)
 {
     field.SetWidget(new Rectangle(llx, lly, urx, ury), PdfAnnotation.HIGHLIGHT_INVERT);
     if (defaultValue != null)
     {
         field.ValueAsString        = defaultValue;
         field.DefaultValueAsString = defaultValue;
     }
     field.FieldName = name;
     field.Flags     = PdfAnnotation.FLAGS_PRINT;
     field.SetPage();
     field.BorderStyle = new PdfBorderDictionary(2, PdfBorderDictionary.STYLE_SOLID);
 }
Ejemplo n.º 4
0
 public void SetCheckBoxParams(PdfFormField field, string name, string value, bool status, float llx, float lly, float urx, float ury)
 {
     field.SetWidget(new Rectangle(llx, lly, urx, ury), PdfAnnotation.HIGHLIGHT_TOGGLE);
     field.FieldName = name;
     if (status)
     {
         field.ValueAsName     = value;
         field.AppearanceState = value;
     }
     else
     {
         field.ValueAsName     = "Off";
         field.AppearanceState = "Off";
     }
     field.Flags = PdfAnnotation.FLAGS_PRINT;
     field.SetPage();
     field.BorderStyle = new PdfBorderDictionary(1, PdfBorderDictionary.STYLE_SOLID);
 }
Ejemplo n.º 5
0
        public PdfFormField AddRadioButton(PdfFormField radiogroup, string value, float llx, float lly, float urx, float ury)
        {
            PdfFormField radio = PdfFormField.CreateEmpty(writer);

            radio.SetWidget(new Rectangle(llx, lly, urx, ury), PdfAnnotation.HIGHLIGHT_TOGGLE);
            string name = ((PdfName)radiogroup.Get(PdfName.V)).ToString().Substring(1);

            if (name.Equals(value))
            {
                radio.AppearanceState = value;
            }
            else
            {
                radio.AppearanceState = "Off";
            }
            DrawRadioAppearences(radio, value, llx, lly, urx, ury);
            radiogroup.AddKid(radio);
            return(radio);
        }
Ejemplo n.º 6
0
 public void SetTextFieldParams(PdfFormField field, string text, string name, float llx, float lly, float urx, float ury)
 {
     field.SetWidget(new Rectangle(llx, lly, urx, ury), PdfAnnotation.HIGHLIGHT_INVERT);
     field.ValueAsString = text;
     field.DefaultValueAsString = text;
     field.FieldName = name;
     field.Flags = PdfAnnotation.FLAGS_PRINT;
     field.SetPage();
 }
Ejemplo n.º 7
0
 /**
  * @param field
  * @param name
  * @param llx
  * @param lly
  * @param urx
  * @param ury
  */
 public void SetSignatureParams(PdfFormField field, String name, float llx, float lly, float urx, float ury)
 {
     field.SetWidget(new Rectangle(llx, lly, urx, ury), PdfAnnotation.HIGHLIGHT_INVERT);
     field.FieldName = name;
     field.Flags = PdfAnnotation.FLAGS_PRINT;
     field.SetPage();
     field.MKBorderColor = Color.BLACK;
     field.MKBackgroundColor = Color.WHITE;
 }
Ejemplo n.º 8
0
 public void SetChoiceParams(PdfFormField field, string name, string defaultValue, float llx, float lly, float urx, float ury)
 {
     field.SetWidget(new Rectangle(llx, lly, urx, ury), PdfAnnotation.HIGHLIGHT_INVERT);
     if (defaultValue != null) {
     field.ValueAsString = defaultValue;
     field.DefaultValueAsString = defaultValue;
     }
     field.FieldName = name;
     field.Flags = PdfAnnotation.FLAGS_PRINT;
     field.SetPage();
     field.BorderStyle = new PdfBorderDictionary(2, PdfBorderDictionary.STYLE_SOLID);
 }
Ejemplo n.º 9
0
 public void SetCheckBoxParams(PdfFormField field, string name, string value, bool status, float llx, float lly, float urx, float ury)
 {
     field.SetWidget(new Rectangle(llx, lly, urx, ury), PdfAnnotation.HIGHLIGHT_TOGGLE);
     field.FieldName = name;
     if (status) {
     field.ValueAsName = value;
     field.AppearanceState = value;
     }
     else {
     field.ValueAsName = "Off";
     field.AppearanceState = "Off";
     }
     field.Flags = PdfAnnotation.FLAGS_PRINT;
     field.SetPage();
     field.BorderStyle = new PdfBorderDictionary(1, PdfBorderDictionary.STYLE_SOLID);
 }
Ejemplo n.º 10
0
        protected PdfFormField GetChoiceField(bool isList)
        {
            options &= (~MULTILINE) & (~COMB);
            String[] uchoices = choices;
            if (uchoices == null)
            {
                uchoices = new String[0];
            }
            int topChoice = choiceSelection;

            if (topChoice >= uchoices.Length)
            {
                topChoice = uchoices.Length - 1;
            }
            if (text == null)
            {
                text = "";               //fixed by Kazuya Ujihara (ujihara.jp)
            }
            if (topChoice >= 0)
            {
                text = uchoices[topChoice];
            }
            if (topChoice < 0)
            {
                topChoice = 0;
            }
            PdfFormField field = null;

            String[,] mix = null;
            if (choiceExports == null)
            {
                if (isList)
                {
                    field = PdfFormField.CreateList(writer, uchoices, topChoice);
                }
                else
                {
                    field = PdfFormField.CreateCombo(writer, (options & EDIT) != 0, uchoices, topChoice);
                }
            }
            else
            {
                mix = new String[uchoices.Length, 2];
                for (int k = 0; k < mix.GetLength(0); ++k)
                {
                    mix[k, 0] = mix[k, 1] = uchoices[k];
                }
                int top = Math.Min(uchoices.Length, choiceExports.Length);
                for (int k = 0; k < top; ++k)
                {
                    if (choiceExports[k] != null)
                    {
                        mix[k, 0] = choiceExports[k];
                    }
                }
                if (isList)
                {
                    field = PdfFormField.CreateList(writer, mix, topChoice);
                }
                else
                {
                    field = PdfFormField.CreateCombo(writer, (options & EDIT) != 0, mix, topChoice);
                }
            }
            field.SetWidget(box, PdfAnnotation.HIGHLIGHT_INVERT);
            if (rotation != 0)
            {
                field.MKRotation = rotation;
            }
            if (fieldName != null)
            {
                field.FieldName = fieldName;
                if (uchoices.Length > 0)
                {
                    if (mix != null)
                    {
                        field.ValueAsString        = mix[topChoice, 0];
                        field.DefaultValueAsString = mix[topChoice, 0];
                    }
                    else
                    {
                        field.ValueAsString        = text;
                        field.DefaultValueAsString = text;
                    }
                }
                if ((options & READ_ONLY) != 0)
                {
                    field.SetFieldFlags(PdfFormField.FF_READ_ONLY);
                }
                if ((options & REQUIRED) != 0)
                {
                    field.SetFieldFlags(PdfFormField.FF_REQUIRED);
                }
                if ((options & DO_NOT_SPELL_CHECK) != 0)
                {
                    field.SetFieldFlags(PdfFormField.FF_DONOTSPELLCHECK);
                }
            }
            field.BorderStyle = new PdfBorderDictionary(borderWidth, borderStyle, new PdfDashPattern(3));
            PdfAppearance tp;

            if (isList)
            {
                tp = GetListAppearance();
                if (topFirst > 0)
                {
                    field.Put(PdfName.TI, new PdfNumber(topFirst));
                }
            }
            else
            {
                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);
        }
Ejemplo n.º 11
0
        /** 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);
        }
Ejemplo n.º 12
0
        /**
         * Gets a radio or check field.
         * @param isRadio <CODE>true</CODE> to get a radio field, <CODE>false</CODE> to get
         * a check field
         * @throws IOException on error
         * @throws DocumentException on error
         * @return the field
         */
        protected PdfFormField GetField(bool isRadio)
        {
            PdfFormField field = null;

            if (isRadio)
            {
                field = PdfFormField.CreateEmpty(writer);
            }
            else
            {
                field = PdfFormField.CreateCheckBox(writer);
            }
            field.SetWidget(box, PdfAnnotation.HIGHLIGHT_INVERT);
            if (!isRadio)
            {
                field.FieldName = fieldName;
                if ((options & READ_ONLY) != 0)
                {
                    field.SetFieldFlags(PdfFormField.FF_READ_ONLY);
                }
                if ((options & REQUIRED) != 0)
                {
                    field.SetFieldFlags(PdfFormField.FF_REQUIRED);
                }
                field.ValueAsName = vchecked ? onValue : "Off";
            }
            if (text != null)
            {
                field.MKNormalCaption = text;
            }
            if (rotation != 0)
            {
                field.MKRotation = rotation;
            }
            field.BorderStyle = new PdfBorderDictionary(borderWidth, borderStyle, new PdfDashPattern(3));
            PdfAppearance tpon  = GetAppearance(isRadio, true);
            PdfAppearance tpoff = GetAppearance(isRadio, false);

            field.SetAppearance(PdfAnnotation.APPEARANCE_NORMAL, onValue, tpon);
            field.SetAppearance(PdfAnnotation.APPEARANCE_NORMAL, "Off", tpoff);
            field.AppearanceState = vchecked ? onValue : "Off";
            PdfAppearance da = (PdfAppearance)tpon.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);
        }