Package com.lowagie.text.pdf

Examples of com.lowagie.text.pdf.PdfFormField


        acroForm.addCalculationOrder(formField);
    }
   
    public void addAnnotation(PdfAnnotation annot) {
        if (annot.isForm()) {
            PdfFormField field = (PdfFormField)annot;
            if (field.getParent() == null)
                addFormFieldRaw(field);
        }
        else
            annotations.add(annot);
    }
View Full Code Here


                if (!dic.isUsed()) {
                    HashMap templates = dic.getTemplates();
                    if (templates != null)
                        acroForm.addFieldTemplates(templates);
                }
                PdfFormField field = (PdfFormField)dic;
                if (field.getParent() == null)
                    acroForm.addDocumentField(field.getIndirectReference());
            }
            if (dic.isAnnotation()) {
                array.add(dic.getIndirectReference());
                if (!dic.isUsed()) {
                    PdfRectangle rect = (PdfRectangle)dic.get(PdfName.RECT);
View Full Code Here

   * @see com.lowagie.text.pdf.PdfPageEvent#onGenericTag(com.lowagie.text.pdf.PdfWriter, com.lowagie.text.Document, com.lowagie.text.Rectangle, java.lang.String)
   */
  public void onGenericTag(PdfWriter writer, Document document,
      Rectangle rect, String text) {
    rect.setBottom(rect.getBottom() - 3);
    PdfFormField field = (PdfFormField) genericChunkFields.get(text);
    if (field == null) {
      TextField tf = new TextField(writer, new Rectangle(rect.getLeft(padding), rect.getBottom(padding), rect.getRight(padding), rect.getTop(padding)), text);
      tf.setFontSize(14);
      try {
        field = tf.getTextField();
      } catch (Exception e) {
        throw new ExceptionConverter(e);
      }
    }
    else {
      field.put(PdfName.RECT,  new PdfRectangle(rect.getLeft(padding), rect.getBottom(padding), rect.getRight(padding), rect.getTop(padding)));
    }
    if (parent == null)
      writer.addAnnotation(field);
    else
      parent.addKid(field);
View Full Code Here

        acroForm.addCalculationOrder(formField);
    }
   
    public void addAnnotation(PdfAnnotation annot) {
        if (annot.isForm()) {
            PdfFormField field = (PdfFormField)annot;
            if (field.getParent() == null)
                addFormFieldRaw(field);
        }
        else
            annotations.add(annot);
    }
View Full Code Here

                if (!dic.isUsed()) {
                    HashMap templates = dic.getTemplates();
                    if (templates != null)
                        acroForm.addFieldTemplates(templates);
                }
                PdfFormField field = (PdfFormField)dic;
                if (field.getParent() == null)
                    acroForm.addDocumentField(field.getIndirectReference());
            }
            if (dic.isAnnotation()) {
                array.add(dic.getIndirectReference());
                if (!dic.isUsed()) {
                    PdfRectangle rect = (PdfRectangle)dic.get(PdfName.RECT);
View Full Code Here

        PdfWriter writer = outputDevice.getWriter();
       
        String[][] options = getPDFOptions();
        int selectedIndex = getSelectedIndex();
       
        PdfFormField field;
       
        /*
         * Comment out for now.  We need to draw an appropriate appearance for
         * this to work correctly.
         */
        /*
        if (isMultiple(box.getElement())) {
            field = PdfFormField.createList(writer, options, selectedIndex); 
        } else {
            field = PdfFormField.createCombo(writer, false, options, selectedIndex);   
        }
        */
       
        field = PdfFormField.createCombo(writer, false, options, selectedIndex);   
       
        field.setWidget(outputDevice.createLocalTargetArea(c, box), PdfAnnotation.HIGHLIGHT_INVERT);
        field.setFieldName(getFieldName(outputDevice, box.getElement()));
        if (options.length > 0) {
            field.setValueAsString(options[selectedIndex][0]);
        }
       
        createAppearance(c, outputDevice, box, field);

        if (isReadOnly(box.getElement())) {
            field.setFieldFlags(PdfFormField.FF_READ_ONLY);
        }      
       
        /*
        if (isMultiple(box.getElement())) {
            field.setFieldFlags(PdfFormField.FF_MULTISELECT);
View Full Code Here

    public void paint(RenderingContext c, ITextOutputDevice outputDevice, BlockBox box) {
        PdfWriter writer = outputDevice.getWriter();

        Element elem = box.getElement();
        PdfFormField field = PdfFormField.createTextField(
                writer, false, false, getMaxLength(elem));
        Rectangle targetArea = outputDevice.createLocalTargetArea(c, box);
        field.setWidget(
                targetArea,
                PdfAnnotation.HIGHLIGHT_INVERT);       
        field.setFieldName(getFieldName(outputDevice, elem));
        field.setBorderStyle(new PdfBorderDictionary(0.0f, 0));

        String value = getValue(elem);
       
        field.setDefaultValueAsString(value);
        field.setValueAsString(value);
       
        createAppearance(c, outputDevice, box, field, value);

        if (isReadOnly(elem)) {
            field.setFieldFlags(PdfFormField.FF_READ_ONLY);
        }

        writer.addAnnotation(field);
    }
View Full Code Here

  public void paint(RenderingContext c, ITextOutputDevice outputDevice, BlockBox box) {
    PdfContentByte cb = outputDevice.getCurrentPage();

    PdfWriter writer = outputDevice.getWriter();

    PdfFormField field = PdfFormField.createCheckBox(writer);

    Element e = box.getElement();
    String onValue = getValue(e);
    boolean checked = isChecked(e);

    float width = outputDevice.getDeviceLength(getWidth());
    float height = outputDevice.getDeviceLength(getHeight());

    FSColor color = box.getStyle().getColor();
    FSColor darker = box.getEffBackgroundColor(c).darkenColor();
    createAppearances(cb, field, onValue, width, height, true, color, darker);
    createAppearances(cb, field, onValue, width, height, false, color, darker);

    field.setWidget(outputDevice.createLocalTargetArea(c, box),
        PdfAnnotation.HIGHLIGHT_INVERT);
    field.setFieldName(getFieldName(outputDevice, e));

    field.setBorderStyle(new PdfBorderDictionary(0.0f, 0));

    field.setValueAsName(checked ? onValue : OFF_STATE);
    field.setAppearanceState(checked ? onValue : OFF_STATE);

    if (isReadOnly(e)) {
      field.setFieldFlags(PdfFormField.FF_READ_ONLY);
    }

    writer.addAnnotation(field);
  }
View Full Code Here

   * @see com.lowagie.text.pdf.PdfPageEvent#onGenericTag(com.lowagie.text.pdf.PdfWriter, com.lowagie.text.Document, com.lowagie.text.Rectangle, java.lang.String)
   */
  public void onGenericTag(PdfWriter writer, Document document,
      Rectangle rect, String text) {
    rect.setBottom(rect.getBottom() - 3);
    PdfFormField field = (PdfFormField) genericChunkFields.get(text);
    if (field == null) {
      TextField tf = new TextField(writer, new Rectangle(rect.getLeft(padding), rect.getBottom(padding), rect.getRight(padding), rect.getTop(padding)), text);
      tf.setFontSize(14);
      try {
        field = tf.getTextField();
      } catch (Exception e) {
        throw new ExceptionConverter(e);
      }
    }
    else {
      field.put(PdfName.RECT,  new PdfRectangle(rect.getLeft(padding), rect.getBottom(padding), rect.getRight(padding), rect.getTop(padding)));
    }
    if (parent == null)
      writer.addAnnotation(field);
    else
      parent.addKid(field);
View Full Code Here

            innertable.addCell(new Paragraph("name:", f));
            cell = new PdfPCell();
            text = new TextField(writer, new Rectangle(0, 0), "name");
            text.setOptions(TextField.MULTILINE);
            text.setFontSize(8);
            PdfFormField name = text.getTextField();
            cell.setCellEvent(new StudentCardForm(name));
            innertable.addCell(cell);
            innertable.addCell(new Paragraph("date of birth:", f));
            cell = new PdfPCell();
            text = new TextField(writer, new Rectangle(0, 0), "birthday");
            text.setOptions(TextField.MULTILINE);
            text.setFontSize(8);
            PdfFormField birthdate = text.getTextField();
            cell.setCellEvent(new StudentCardForm(birthdate));
            innertable.addCell(cell);
            innertable.addCell(new Paragraph("Study Program:", f));
            cell = new PdfPCell();
            text = new TextField(writer, new Rectangle(0, 0), "studyprogram");
            text.setOptions(TextField.MULTILINE);
            text.setFontSize(8);
            PdfFormField studyprogram = text.getTextField();
            studyprogram.setFieldName("studyprogram");
            cell.setCellEvent(new StudentCardForm(studyprogram));
            innertable.addCell(cell);
            innertable.addCell(new Paragraph("option:", f));
            cell = new PdfPCell();
            text = new TextField(writer, new Rectangle(0, 0), "option");
            text.setOptions(TextField.MULTILINE);
            text.setFontSize(8);
            PdfFormField option = text.getTextField();
            option.setFieldName("option");
            cell.setCellEvent(new StudentCardForm(option));
            innertable.addCell(cell);
            outertable.addCell(innertable);
            cell = new PdfPCell();
      cell.setBackgroundColor(new Color(0xFF, 0xDE, 0xAD));
            PdfFormField picture = PdfFormField.createPushButton(writer);
            picture.setFieldName("picture");
            cell.setCellEvent(new StudentCardForm(picture));
            outertable.addCell(cell);
            cell = new PdfPCell();
      cell.setBackgroundColor(Color.WHITE);
            PdfFormField barcode = PdfFormField.createPushButton(writer);
            barcode.setFieldName("barcode");
            cell.setCellEvent(new StudentCardForm(barcode));
            outertable.addCell(cell);
            outertable.writeSelectedRows(0, -1, 20, 100, writer.getDirectContent());
            writer.addAnnotation(name);
            writer.addAnnotation(birthdate);
View Full Code Here

TOP

Related Classes of com.lowagie.text.pdf.PdfFormField

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.