Package com.lowagie.text.pdf

Examples of com.lowagie.text.pdf.TextField


            ColumnText.showTextAligned(cb, LwgElement.ALIGN_LEFT, p2, 50, 550, 0);
            cb.endLayer();
            cb.beginLayer(l3);
            ColumnText.showTextAligned(cb, LwgElement.ALIGN_LEFT, p3, 50, 500, 0);
            cb.endLayer();
            TextField ff = new TextField(writer, new LwgRectangle(200, 600, 300, 620), "field1");
            ff.setBorderColor(Color.blue);
            ff.setBorderStyle(PdfBorderDictionary.STYLE_SOLID);
            ff.setBorderWidth(TextField.BORDER_WIDTH_THIN);
            ff.setText("I'm a form field");
            PdfFormField form = ff.getTextField();
            form.setLayer(l4);
            writer.addAnnotation(form);
            LwgImage img = LwgImage.getInstance("pngnow.png");
            img.setLayer(l4);
            img.setAbsolutePosition(200, 550);
View Full Code Here


    /** Creates a new event. This constructor will be used if you need to position fields with a Cell Event.
     * @throws DocumentException
     * @throws IOException*/
    public FieldPositioningEvents(PdfWriter writer, String text) throws IOException, DocumentException {
      this.fieldWriter = writer;
      TextField tf = new TextField(writer, new LwgRectangle(0, 0), text);
    tf.setFontSize(14);
    cellField = tf.getTextField();
  }  
View Full Code Here

    /** Creates a new event. This constructor will be used if you need to position fields with a Cell Event.
     * @throws DocumentException
     * @throws IOException*/
    public FieldPositioningEvents(PdfWriter writer, PdfFormField parent, String text) throws IOException, DocumentException {
      this.parent = parent;
      TextField tf = new TextField(writer, new LwgRectangle(0, 0), text);
    tf.setFontSize(14);
    cellField = tf.getTextField();
 
View Full Code Here

  public void onGenericTag(PdfWriter writer, LwgDocument document,
      LwgRectangle rect, String text) {
    rect.setBottom(rect.getBottom() - 3);
    PdfFormField field = (PdfFormField) genericChunkFields.get(text);
    if (field == null) {
      TextField tf = new TextField(writer, new LwgRectangle(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 {
View Full Code Here

    }

    @Override
    public void cellLayout(PdfPCell cell, Rectangle rectangle, PdfContentByte[] canvases) {
        PdfWriter writer = canvases[0].getPdfWriter();
        TextField text = new TextField(writer, rectangle, String.format("text_" + UUID.randomUUID().toString()));
        text.setBorderStyle(PdfBorderDictionary.STYLE_INSET);
        text.setText(value);
        text.setFontSize(FONTSIZE);
        text.setAlignment(Element.ALIGN_LEFT);
        try {
            PdfFormField field = text.getTextField();
            if(locked) {
                field.setFieldFlags(BaseField.READ_ONLY);
            }
            writer.addAnnotation(field);
        } catch (IOException ioe) {
View Full Code Here

    }

    @Override
    public void cellLayout(PdfPCell cell, Rectangle rectangle, PdfContentByte[] canvases) {
        PdfWriter writer = canvases[0].getPdfWriter();
        TextField text = new TextField(writer, rectangle, String.format("choice_" + UUID.randomUUID().toString()));
        text.setBorderStyle(PdfBorderDictionary.STYLE_INSET);
        text.setChoices(values);
        text.setFontSize(ITextInputText.FONTSIZE);
        text.setChoiceExports(text.getChoices());
        for(int i = 0; value != null && i < values.length; i++) {
            if(values[i].equals(value)) {
                text.setChoiceSelection(i);
                break;
            }
        }
        try {
            PdfFormField comboField = text.getComboField();
            if(locked) {
                comboField.setFieldFlags(BaseField.READ_ONLY);
            }
            writer.addAnnotation(comboField);
        } catch (IOException ex) {
View Full Code Here

    }

    @Override
    public void cellLayout(PdfPCell cell, Rectangle rectangle, PdfContentByte[] canvases) {
        PdfWriter writer = canvases[0].getPdfWriter();
        TextField text = new TextField(writer, rectangle, String.format("choice_" + UUID.randomUUID().toString()));
        text.setBorderStyle(PdfBorderDictionary.STYLE_INSET);
        text.setFontSize(ITextInputText.FONTSIZE);
        text.setOptions(TextField.MULTISELECT);
        text.setChoices(values);
        ArrayList<Integer> choiceSelections = new ArrayList<>();
        if (selectedValues != null) {
            for (int i = 0; i < values.length; i++) {
                for (int i2 = 0; i2 < selectedValues.length; i2++) {
                    if (values[i].equals(selectedValues[i2])) {
                        choiceSelections.add(i);
                        break;
                    }
                }
            }
        }
        text.setChoiceSelections(choiceSelections);
        try {
            PdfFormField listField = text.getListField();
            if(locked) {
                listField.setFieldFlags(BaseField.READ_ONLY);
            }
            writer.addAnnotation(listField);
        } catch (IOException ex) {
View Full Code Here

            outertable.setWidths(outer);
            LwgPdfPTable innertable = new LwgPdfPTable(2);
            float[] inner = {35, 65};
            innertable.setWidths(inner);
            LwgPdfPCell cell;
            TextField text;
            innertable.add(new Paragraph("name:", f));
            cell = new LwgPdfPCell();
            text = new TextField(writer, new LwgRectangle(0, 0), "name");
            text.setOptions(TextField.MULTILINE);
            text.setFontSize(8);
            PdfFormField name = text.getTextField();
            cell.setCellEvent(new StudentCardForm(name));
            innertable.add(cell);
            innertable.add(new Paragraph("date of birth:", f));
            cell = new LwgPdfPCell();
            text = new TextField(writer, new LwgRectangle(0, 0), "birthday");
            text.setOptions(TextField.MULTILINE);
            text.setFontSize(8);
            PdfFormField birthdate = text.getTextField();
            cell.setCellEvent(new StudentCardForm(birthdate));
            innertable.add(cell);
            innertable.add(new Paragraph("Study Program:", f));
            cell = new LwgPdfPCell();
            text = new TextField(writer, new LwgRectangle(0, 0), "studyprogram");
            text.setOptions(TextField.MULTILINE);
            text.setFontSize(8);
            PdfFormField studyprogram = text.getTextField();
            studyprogram.setFieldName("studyprogram");
            cell.setCellEvent(new StudentCardForm(studyprogram));
            innertable.add(cell);
            innertable.add(new Paragraph("option:", f));
            cell = new LwgPdfPCell();
            text = new TextField(writer, new LwgRectangle(0, 0), "option");
            text.setOptions(TextField.MULTILINE);
            text.setFontSize(8);
            PdfFormField option = text.getTextField();
            option.setFieldName("option");
            cell.setCellEvent(new StudentCardForm(option));
            innertable.add(cell);
            outertable.add(innertable);
            cell = new LwgPdfPCell();
View Full Code Here

           
            // step 3: we open the document
            document.open();
           
            // step 4:
            TextField tf = new TextField(writer, new LwgRectangle(100, 300, 100 + 100, 300 + 50), "Dickens");
            tf.setBackgroundColor(Color.RED);
            tf.setBorderColor(Color.BLUE);
            tf.setBorderWidth(2);
            tf.setBorderStyle(PdfBorderDictionary.STYLE_BEVELED);
            tf.setText("It was the best of times, it was the worst of times, it was the age of wisdom...");
            tf.setAlignment(LwgElement.ALIGN_CENTER);
            tf.setOptions(TextField.MULTILINE | TextField.REQUIRED);
            tf.setRotation(90);
            PdfFormField field = tf.getTextField();
            writer.addAnnotation(field);
           
            tf = new TextField(writer, new LwgRectangle(250, 300, 250 + 100, 300 + 20), "Combos");
            tf.setBackgroundColor(Color.RED);
            tf.setBorderColor(Color.BLUE);
            tf.setBorderWidth(2);
            tf.setFontSize(10);
            tf.setBorderStyle(PdfBorderDictionary.STYLE_INSET);
            tf.setVisibility(TextField.VISIBLE_BUT_DOES_NOT_PRINT);
            tf.setChoices(new String[]{"First", "Second"});
            tf.setChoiceExports(new String[]{"value1", "value2"});
            tf.setRotation(90);
            field = tf.getComboField();
            writer.addAnnotation(field);
           
            tf = new TextField(writer, new LwgRectangle(400, 300, 400 + 100, 300 + 50), "Lists");
            tf.setBackgroundColor(Color.YELLOW);
            tf.setBorderColor(Color.RED);
            tf.setBorderWidth(2);
            tf.setBorderStyle(PdfBorderDictionary.STYLE_DASHED);
            tf.setFontSize(10);
            tf.setChoices(new String[]{"a", "b", "c", "d", "e", "f", "g", "h"});
            tf.setRotation(90);
            tf.setChoiceSelection(4);
            field = tf.getListField();
            writer.addAnnotation(field);
           
        }
        catch(DocumentException de) {
            System.err.println(de.getMessage());
View Full Code Here

   * @see com.lowagie.text.pdf.PdfPCellEvent#cellLayout(com.lowagie.text.pdf.PdfPCell,
   *      com.lowagie.text.LwgRectangle, com.lowagie.text.pdf.PdfContentByte[])
   */
  public void cellLayout(LwgPdfPCell cell, LwgRectangle position,
      PdfContentByte[] canvases) {
    TextField tf = new TextField(writer, position, fieldname);
    tf.setFontSize(12);
    try {
      PdfFormField field = tf.getTextField();
      writer.addAnnotation(field);
    } catch (IOException e) {
      e.printStackTrace();
    } catch (DocumentException e) {
      e.printStackTrace();
View Full Code Here

TOP

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

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.