Example usage for com.lowagie.text.pdf TextField TextField

List of usage examples for com.lowagie.text.pdf TextField TextField

Introduction

In this page you can find the example usage for com.lowagie.text.pdf TextField TextField.

Prototype

public TextField(PdfWriter writer, Rectangle box, String fieldName) 

Source Link

Document

Creates a new TextField.

Usage

From source file:at.reppeitsolutions.formbuilder.components.pdf.itext.ITextInputText.java

License:Open Source License

@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);/*from w ww .j  av  a  2 s.  com*/
    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) {
        throw new ExceptionConverter(ioe);
    } catch (DocumentException de) {
        throw new ExceptionConverter(de);
    }
}

From source file:at.reppeitsolutions.formbuilder.components.pdf.itext.ITextListbox.java

License:Open Source License

@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);/*from  ww w .j a va  2 s  .  c  om*/
    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) {
        Logger.getLogger(ITextListbox.class.getName()).log(Level.SEVERE, null, ex);
    } catch (DocumentException ex) {
        Logger.getLogger(ITextListbox.class.getName()).log(Level.SEVERE, null, ex);
    }
}

From source file:at.reppeitsolutions.formbuilder.components.pdf.itext.ITextSelect.java

License:Open Source License

@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);// ww w.  ja v a  2 s  .  c  o  m
    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) {
        Logger.getLogger(ITextSelect.class.getName()).log(Level.SEVERE, null, ex);
    } catch (DocumentException ex) {
        Logger.getLogger(ITextSelect.class.getName()).log(Level.SEVERE, null, ex);
    }
}

From source file:classroom.filmfestival_c.Movies22.java

public static void main(String[] args) {
    // step 1//w  w w  . j  av  a2 s. c o m
    Document document = new Document(new Rectangle(WIDTH, HEIGHT));
    try {
        // step 2
        PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream(FORM));
        writer.setViewerPreferences(PdfWriter.PageLayoutSinglePage);
        // step 3
        document.open();
        // step 4
        PdfContentByte cb = writer.getDirectContent();

        // top part of the card
        cb.setColorFill(RED);
        cb.rectangle(0, mm2pt(57f), WIDTH, HEIGHT - mm2pt(57f));
        cb.fill();
        cb.setColorFill(BLACK);
        cb.rectangle(0, mm2pt(61), WIDTH, mm2pt(21f));
        cb.fill();
        cb.setColorFill(WHITE);

        Image kubrick = Image.getInstance(KUBRICK);
        kubrick.scaleToFit(WIDTH, mm2pt(21));
        kubrick.setAbsolutePosition(0, mm2pt(61));
        cb.addImage(kubrick);

        Image logo = Image.getInstance(LOGO);
        logo.scaleToFit(mm2pt(14), mm2pt(14));
        logo.setAbsolutePosition(mm2pt(37), mm2pt(65));
        cb.addImage(logo);

        cb.beginText();
        cb.setFontAndSize(FONT, 7);
        cb.showTextAligned(Element.ALIGN_CENTER, "Flanders International Film Festival-Ghent", WIDTH / 2,
                mm2pt(58.5f), 0);
        cb.endText();

        // bottom part of the card

        TextField filmfestival = new TextField(writer, new Rectangle(0, 0, WIDTH, mm2pt(9)), "filmfestival");
        filmfestival.setBackgroundColor(GRAY);
        filmfestival.setTextColor(WHITE);
        filmfestival.setText("www.filmfestival.be");
        filmfestival.setFontSize(14);
        filmfestival.setOptions(TextField.READ_ONLY);
        filmfestival.setAlignment(Element.ALIGN_CENTER);
        writer.addAnnotation(filmfestival.getTextField());

        cb.beginText();
        cb.moveText(mm2pt(1.5f), mm2pt(12));
        cb.setFontAndSize(FONT, 21);
        cb.setColorFill(RED);
        cb.showText("10");
        cb.setColorFill(BLUE);
        cb.showText("/");
        cb.setColorFill(RED);
        cb.showText("21");
        cb.setColorFill(BLUE);
        cb.showText("OCT");
        cb.setColorFill(GREEN);
        cb.showText("2006");
        cb.endText();
        cb.setColorStroke(BLUE);
        cb.moveTo(mm2pt(24.5f), mm2pt(29));
        cb.lineTo(mm2pt(24.5f), mm2pt(36));
        cb.moveTo(mm2pt(24.5f), mm2pt(48));
        cb.lineTo(mm2pt(24.5f), mm2pt(54));
        cb.stroke();

        // central part of the card
        PushbuttonField photo = new PushbuttonField(writer,
                new Rectangle(mm2pt(3), mm2pt(29), mm2pt(24), mm2pt(54)), "photo");
        PdfTemplate t1 = cb.createTemplate(mm2pt(21), mm2pt(25));
        t1.setColorFill(GRAY);
        t1.rectangle(0, 0, mm2pt(21), mm2pt(25));
        t1.fill();
        photo.setTemplate(t1);
        photo.setLayout(PushbuttonField.LAYOUT_ICON_ONLY);
        writer.addAnnotation(photo.getField());

        TextField type = new TextField(writer,
                new Rectangle(mm2pt(26), mm2pt(46), WIDTH - mm2pt(1.5f), mm2pt(54)), "type");
        type.setTextColor(GRAY);
        type.setText("TYPE");
        type.setFontSize(0);
        writer.addAnnotation(type.getTextField());

        TextField number = new TextField(writer,
                new Rectangle(mm2pt(26), mm2pt(44), WIDTH - mm2pt(1.5f), mm2pt(48)), "number");
        number.setText("N\u00b0 0000000");
        number.setFontSize(8);
        writer.addAnnotation(number.getTextField());

        TextField name = new TextField(writer,
                new Rectangle(mm2pt(26), mm2pt(28), WIDTH - mm2pt(1.5f), mm2pt(40)), "name");
        name.setText("Name");
        name.setFontSize(8);
        name.setOptions(TextField.MULTILINE);
        writer.addAnnotation(name.getTextField());

        PushbuttonField barcode = new PushbuttonField(writer,
                new Rectangle(mm2pt(3), mm2pt(23), WIDTH - mm2pt(3), mm2pt(28)), "barcode");
        PdfTemplate t2 = cb.createTemplate(WIDTH - mm2pt(6), mm2pt(5));
        t2.setColorFill(GRAY);
        t2.rectangle(0, 0, WIDTH - mm2pt(6), mm2pt(5));
        t2.fill();
        barcode.setTemplate(t2);
        barcode.setLayout(PushbuttonField.LAYOUT_ICON_ONLY);
        writer.addAnnotation(barcode.getField());

    } catch (DocumentException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    }

    // step 4
    document.close();
}

From source file:classroom.filmfestival_c.Movies25.java

public static void createTemplate() {
    // our template will be 35 x 50 mm
    Document document = new Document(
            new Rectangle(Utilities.millimetersToPoints(35), Utilities.millimetersToPoints(50)));
    try {/* ww w. ja  va 2s. c o  m*/
        // step 2
        PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream(TEMPLATE));
        writer.setViewerPreferences(PdfWriter.PageLayoutSinglePage);
        // step 3
        document.open();
        // step 4

        // space reserved for the film poster
        PushbuttonField foto = new PushbuttonField(writer,
                new Rectangle(Utilities.millimetersToPoints(0), Utilities.millimetersToPoints(25),
                        Utilities.millimetersToPoints(35), Utilities.millimetersToPoints(50)),
                POSTER);
        foto.setBackgroundColor(Color.BLUE);
        writer.addAnnotation(foto.getField());

        // space reserved for the text
        TextField tekst = new TextField(writer,
                new Rectangle(Utilities.millimetersToPoints(0), Utilities.millimetersToPoints(7),
                        Utilities.millimetersToPoints(35), Utilities.millimetersToPoints(25)),
                TEXT);
        tekst.setOptions(TextField.MULTILINE);
        writer.addAnnotation(tekst.getTextField());

        // space reserved for the year
        TextField prijs = new TextField(writer,
                new Rectangle(Utilities.millimetersToPoints(0), Utilities.millimetersToPoints(0),
                        Utilities.millimetersToPoints(35), Utilities.millimetersToPoints(7)),
                YEAR);
        prijs.setAlignment(Element.ALIGN_CENTER);
        prijs.setBackgroundColor(Color.BLUE);
        prijs.setTextColor(Color.WHITE);
        writer.addAnnotation(prijs.getTextField());
    } catch (IOException ioe) {
        ioe.printStackTrace();
    } catch (DocumentException e) {
        e.printStackTrace();
    }
    // step 5
    document.close();
}

From source file:classroom.newspaper_b.Newspaper11.java

public static void addTextField(PdfStamper stamper, Rectangle rect, String name, int pagenumber)
        throws IOException, DocumentException {
    TextField field = new TextField(stamper.getWriter(), rect, name);
    field.setAlignment(Element.ALIGN_CENTER);
    field.setOptions(TextField.MULTILINE);
    field.setText(MESSAGE);/*from w  w  w  .  j  a  va  2s  .  c o  m*/
    stamper.addAnnotation(field.getTextField(), pagenumber);
}

From source file:com.geek.tutorial.itext.acroform.ListFieldForm.java

License:Open Source License

public ListFieldForm() throws Exception {
    Document document = new Document();
    PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream("ListFieldForm.pdf"));
    document.open();/*from w  w  w . ja va  2 s .c  o m*/

    // Code 1
    String options[] = { "PS3", "XBOX 360", "Wii", "PSP", "NDS", "GBA" };

    // Code 2 create drop-down list
    PdfFormField dropDown = PdfFormField.createCombo(writer, true, options, 0);
    dropDown.setWidget(new Rectangle(50, 785, 120, 800), PdfAnnotation.HIGHLIGHT_INVERT);
    dropDown.setFieldName("dropDownList");
    dropDown.setValueAsString("PS3");
    dropDown.setMKBorderColor(Color.BLACK);
    writer.addAnnotation(dropDown);

    // Code 3 create scrollable list
    TextField scrollableList = new TextField(writer, new Rectangle(150, 740, 250, 800), "scrollableList");
    scrollableList.setBackgroundColor(Color.WHITE);
    scrollableList.setBorderColor(Color.BLUE);
    scrollableList.setBorderWidth(2);
    scrollableList.setBorderStyle(PdfBorderDictionary.STYLE_SOLID);
    scrollableList.setFontSize(10);
    scrollableList.setChoices(options);
    scrollableList.setChoiceSelection(0);
    writer.addAnnotation(scrollableList.getListField());

    // Code 4 add function and button for showing state 
    writer.addJavaScript(
            "function showState(){" + "app.alert('DropDown:'+ this.getField('dropDownList').value +'\\n'+"
                    + "'Scrollable List:'+this.getField('scrollableList').value);" + "}");
    PushbuttonField push = new PushbuttonField(writer, new Rectangle(70, 710, 140, 730), "pushAction");
    push.setBackgroundColor(Color.LIGHT_GRAY);
    push.setBorderColor(Color.GRAY);
    push.setText("Show State");
    push.setBorderStyle(PdfBorderDictionary.STYLE_BEVELED);
    push.setTextColor(Color.BLACK);
    PdfFormField pushbutton = push.getField();
    pushbutton.setAction(PdfAction.javaScript("showState()", writer));
    writer.addAnnotation(pushbutton);

    document.close();
}

From source file:com.geek.tutorial.itext.acroform.TextFieldForm.java

License:Open Source License

public TextFieldForm() throws Exception {
    Document document = new Document();
    PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream("TextFieldForm.pdf"));
    document.open();/*from   w w w .  jav a  2  s .  c  o m*/

    PdfPTable table = new PdfPTable(2);
    table.getDefaultCell().setPadding(5f); // Code 1, will only affect empty field
    table.setHorizontalAlignment(Element.ALIGN_LEFT);
    PdfPCell cell;

    // Code 2, add name TextField      
    table.addCell("Name");
    TextField nameField = new TextField(writer, new Rectangle(0, 0, 200, 10), "nameField");
    nameField.setBackgroundColor(Color.WHITE);
    nameField.setBorderColor(Color.BLACK);
    nameField.setBorderWidth(1);
    nameField.setBorderStyle(PdfBorderDictionary.STYLE_SOLID);
    nameField.setText("");
    nameField.setAlignment(Element.ALIGN_LEFT);
    nameField.setOptions(TextField.REQUIRED);
    cell = new PdfPCell();
    cell.setMinimumHeight(10);
    cell.setCellEvent(new FieldCell(nameField.getTextField(), 200, writer));
    table.addCell(cell);

    // force upper case javascript
    writer.addJavaScript("var nameField = this.getField('nameField');" + "nameField.setAction('Keystroke',"
            + "'forceUpperCase()');" + "" + "function forceUpperCase(){"
            + "if(!event.willCommit)event.change = " + "event.change.toUpperCase();" + "}");

    // Code 3, add empty row
    table.addCell("");
    table.addCell("");

    // Code 4, add age TextField
    table.addCell("Age");
    TextField ageComb = new TextField(writer, new Rectangle(0, 0, 30, 10), "ageField");
    ageComb.setBorderColor(Color.BLACK);
    ageComb.setBorderWidth(1);
    ageComb.setBorderStyle(PdfBorderDictionary.STYLE_SOLID);
    ageComb.setText("12");
    ageComb.setAlignment(Element.ALIGN_RIGHT);
    ageComb.setMaxCharacterLength(2);
    ageComb.setOptions(TextField.COMB | TextField.DO_NOT_SCROLL);
    cell = new PdfPCell();
    cell.setMinimumHeight(10);
    cell.setCellEvent(new FieldCell(ageComb.getTextField(), 30, writer));
    table.addCell(cell);

    // validate age javascript
    writer.addJavaScript("var ageField = this.getField('ageField');"
            + "ageField.setAction('Validate','checkAge()');" + "function checkAge(){" + "if(event.value < 12){"
            + "app.alert('Warning! Applicant\\'s age can not" + " be younger than 12.');" + "event.value = 12;"
            + "}}");

    // add empty row
    table.addCell("");
    table.addCell("");

    // Code 5, add age TextField
    table.addCell("Comment");
    TextField comment = new TextField(writer, new Rectangle(0, 0, 200, 100), "commentField");
    comment.setBorderColor(Color.BLACK);
    comment.setBorderWidth(1);
    comment.setBorderStyle(PdfBorderDictionary.STYLE_SOLID);
    comment.setText("");
    comment.setOptions(TextField.MULTILINE | TextField.DO_NOT_SCROLL);
    cell = new PdfPCell();
    cell.setMinimumHeight(100);
    cell.setCellEvent(new FieldCell(comment.getTextField(), 200, writer));
    table.addCell(cell);

    // check comment characters length javascript
    writer.addJavaScript("var commentField = " + "this.getField('commentField');" + "commentField"
            + ".setAction('Keystroke','checkLength()');" + "function checkLength(){"
            + "if(!event.willCommit && " + "event.value.length > 100){" + "app.alert('Warning! Comment can not "
            + "be more than 100 characters.');" + "event.change = '';" + "}}");

    // add empty row
    table.addCell("");
    table.addCell("");

    // Code 6, add submit button   
    PushbuttonField submitBtn = new PushbuttonField(writer, new Rectangle(0, 0, 35, 15), "submitPOST");
    submitBtn.setBackgroundColor(Color.GRAY);
    submitBtn.setBorderStyle(PdfBorderDictionary.STYLE_BEVELED);
    submitBtn.setText("POST");
    submitBtn.setOptions(PushbuttonField.VISIBLE_BUT_DOES_NOT_PRINT);
    PdfFormField submitField = submitBtn.getField();
    submitField.setAction(PdfAction.createSubmitForm("http://www.geek-tutorials.com/java/itext/submit.php",
            null, PdfAction.SUBMIT_HTML_FORMAT));
    cell = new PdfPCell();
    cell.setMinimumHeight(15);
    cell.setCellEvent(new FieldCell(submitField, 35, writer));
    table.addCell(cell);

    // Code 7, add reset button
    PushbuttonField resetBtn = new PushbuttonField(writer, new Rectangle(0, 0, 35, 15), "reset");
    resetBtn.setBackgroundColor(Color.GRAY);
    resetBtn.setBorderStyle(PdfBorderDictionary.STYLE_BEVELED);
    resetBtn.setText("RESET");
    resetBtn.setOptions(PushbuttonField.VISIBLE_BUT_DOES_NOT_PRINT);
    PdfFormField resetField = resetBtn.getField();
    resetField.setAction(PdfAction.createResetForm(null, 0));
    cell = new PdfPCell();
    cell.setMinimumHeight(15);
    cell.setCellEvent(new FieldCell(resetField, 35, writer));
    table.addCell(cell);

    document.add(table);
    document.close();
}

From source file:com.kahlon.guard.controller.example.SimpleBean.java

public void createPDF() {
    try { //catch better your exceptions, this is just an example
        FacesContext context = FacesContext.getCurrentInstance();
        Document document = new Document();
        String fileName = "PDFFile";
        String TEXT = FacesMessageUtil.getMessage("person.name") + "  --  "
                + "These are the protagonists in 'Hero', a movie by Zhang Yimou:\n"
                + "\u7121\u540d (Nameless), \u6b98\u528d (Broken Sword), "
                + "\u98db\u96ea (Flying Snow), \u5982\u6708 (Moon), "
                + "\u79e6\u738b (the King), and \u9577\u7a7a (Sky).";

        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        PdfWriter writer = PdfWriter.getInstance(document, baos);

        if (!document.isOpen()) {
            document.open();/*  w  w  w . j a  va2s  .  c  o m*/
        }

        writer.getAcroForm().setNeedAppearances(true);

        TextField text = new TextField(writer, new Rectangle(36, 806, 559, 780), "description");
        text.setOptions(TextField.MULTILINE);
        //text.setOptions(TextField.READ_ONLY);
        text.setText(TEXT);

        writer.addAnnotation(text.getTextField());

        //document.add(new Phrase(TEXT));

        //Keep modifying your pdf file (add pages and more)
        document.close();

        writePDFToResponse(context.getExternalContext(), baos, fileName);

        context.responseComplete();

    } catch (Exception e) {
        //e.printStackTrace();          
    }
}

From source file:corner.orm.tapestry.jasper.exporter.CornerPdfExporter.java

License:Apache License

/**
 * ?.????.//from  www  .j a va 2  s.  c o m
 * <p>:ColumnText?,
 * ?NO_MORE_COLUMN???,TextField??.
 * TextField?.
 * @see net.sf.jasperreports.engine.export.JRPdfExporter#exportText(net.sf.jasperreports.engine.JRPrintText)
 */
@Override
protected void exportText(JRPrintText text) throws DocumentException {

    JRStyledText styledText = getStyledText(text, false);

    if (styledText == null) {
        return;
    }

    int textLength = styledText.length();

    int x = text.getX() + getOffsetX();
    int y = text.getY() + getOffsetY();
    int width = text.getWidth();
    int height = text.getHeight();
    int topPadding = text.getTopPadding();
    int leftPadding = text.getLeftPadding();
    int bottomPadding = text.getBottomPadding();
    int rightPadding = text.getRightPadding();

    int xFillCorrection = 0;
    int yFillCorrection = 0;

    double angle = 0;

    switch (text.getRotation()) {
    case JRTextElement.ROTATION_LEFT: {
        y = text.getY() + getOffsetY() + text.getHeight();
        xFillCorrection = 1;
        width = text.getHeight();
        height = text.getWidth();
        int tmpPadding = topPadding;
        topPadding = leftPadding;
        leftPadding = bottomPadding;
        bottomPadding = rightPadding;
        rightPadding = tmpPadding;
        angle = Math.PI / 2;
        break;
    }
    case JRTextElement.ROTATION_RIGHT: {
        x = text.getX() + getOffsetX() + text.getWidth();
        yFillCorrection = -1;
        width = text.getHeight();
        height = text.getWidth();
        int tmpPadding = topPadding;
        topPadding = rightPadding;
        rightPadding = bottomPadding;
        bottomPadding = leftPadding;
        leftPadding = tmpPadding;
        angle = -Math.PI / 2;
        break;
    }
    case JRTextElement.ROTATION_UPSIDE_DOWN: {
        x = text.getX() + getOffsetX() + text.getWidth();
        y = text.getY() + getOffsetY() + text.getHeight();
        int tmpPadding = topPadding;
        topPadding = bottomPadding;
        bottomPadding = tmpPadding;
        tmpPadding = leftPadding;
        leftPadding = rightPadding;
        rightPadding = tmpPadding;
        angle = Math.PI;
        break;
    }
    case JRTextElement.ROTATION_NONE:
    default: {
    }
    }

    AffineTransform atrans = new AffineTransform();
    atrans.rotate(angle, x, jasperPrint.getPageHeight() - y);
    pdfContentByte.transform(atrans);

    if (text.getMode() == JRElement.MODE_OPAQUE) {
        Color backcolor = text.getBackcolor();
        pdfContentByte.setRGBColorStroke(backcolor.getRed(), backcolor.getGreen(), backcolor.getBlue());
        pdfContentByte.setRGBColorFill(backcolor.getRed(), backcolor.getGreen(), backcolor.getBlue());
        pdfContentByte.setLineWidth(1f);
        pdfContentByte.setLineDash(0f);
        pdfContentByte.rectangle(x + xFillCorrection, jasperPrint.getPageHeight() - y + yFillCorrection,
                width - 1, -height + 1);
        pdfContentByte.fillStroke();
    } else {
        /*
         * pdfContentByte.setRGBColorStroke( text.getForecolor().getRed(),
         * text.getForecolor().getGreen(), text.getForecolor().getBlue() );
         * pdfContentByte.setLineWidth(0.1f);
         * pdfContentByte.setLineDash(0f); pdfContentByte.rectangle(
         * text.getX() + offsetX, jasperPrint.getPageHeight() - text.getY() -
         * offsetY, text.getWidth(), - text.getHeight() );
         * pdfContentByte.stroke();
         */
    }

    if (textLength > 0) {
        int horizontalAlignment = Element.ALIGN_LEFT;
        switch (text.getHorizontalAlignment()) {
        case JRAlignment.HORIZONTAL_ALIGN_LEFT: {
            if (text.getRunDirection() == JRPrintText.RUN_DIRECTION_LTR) {
                horizontalAlignment = Element.ALIGN_LEFT;
            } else {
                horizontalAlignment = Element.ALIGN_RIGHT;
            }
            break;
        }
        case JRAlignment.HORIZONTAL_ALIGN_CENTER: {
            horizontalAlignment = Element.ALIGN_CENTER;
            break;
        }
        case JRAlignment.HORIZONTAL_ALIGN_RIGHT: {
            if (text.getRunDirection() == JRPrintText.RUN_DIRECTION_LTR) {
                horizontalAlignment = Element.ALIGN_RIGHT;
            } else {
                horizontalAlignment = Element.ALIGN_LEFT;
            }
            break;
        }
        case JRAlignment.HORIZONTAL_ALIGN_JUSTIFIED: {
            horizontalAlignment = Element.ALIGN_JUSTIFIED;
            break;
        }
        default: {
            horizontalAlignment = Element.ALIGN_LEFT;
        }
        }

        float verticalOffset = 0f;
        switch (text.getVerticalAlignment()) {
        case JRAlignment.VERTICAL_ALIGN_TOP: {
            verticalOffset = 0f;
            break;
        }
        case JRAlignment.VERTICAL_ALIGN_MIDDLE: {
            verticalOffset = (height - topPadding - bottomPadding - text.getTextHeight()) / 2f;
            break;
        }
        case JRAlignment.VERTICAL_ALIGN_BOTTOM: {
            verticalOffset = height - topPadding - bottomPadding - text.getTextHeight();
            break;
        }
        default: {
            verticalOffset = 0f;
        }
        }

        float llx = x + leftPadding;
        float lly = jasperPrint.getPageHeight() - y - topPadding - verticalOffset - text.getLeadingOffset();
        float urx = x + width - rightPadding;
        float ury = jasperPrint.getPageHeight() - y - height + bottomPadding;

        //?,???
        if (this.jasperMoveXY != null) {
            llx = x + leftPadding + jasperMoveXY.getX();
            lly = jasperPrint.getPageHeight() - y - topPadding - verticalOffset - text.getLeadingOffset()
                    - jasperMoveXY.getY();
            urx = x + width - rightPadding + jasperMoveXY.getX();
            ury = jasperPrint.getPageHeight() - y - height + bottomPadding - jasperMoveXY.getY();
        }

        boolean isOver = false;
        int status = ColumnText.START_COLUMN;
        Phrase phrase = getPhrase(styledText, text);

        ColumnText colText = new ColumnText(pdfContentByte);
        colText.setSimpleColumn(phrase, llx, lly, urx, ury, 0, // text.getLineSpacingFactor(),//
                // *
                // text.getFont().getSize(),
                horizontalAlignment);

        colText.setLeading(0, text.getLineSpacingFactor());// *
        // text.getFont().getSize());
        colText.setRunDirection(
                text.getRunDirection() == JRPrintText.RUN_DIRECTION_LTR ? PdfWriter.RUN_DIRECTION_LTR
                        : PdfWriter.RUN_DIRECTION_RTL);

        float yLine = colText.getYLine();

        // ColumnText
        while (colText.hasMoreText(status)) {
            status = colText.go(true);
            colText.setYLine(yLine);

            // ??,true
            if (status == ColumnText.NO_MORE_COLUMN) {
                isOver = true;
                break;
            }
        }

        // ,ColumnText
        if (!isOver) {
            colText.setText(phrase);
            status = ColumnText.START_COLUMN;

            while (colText.hasMoreText(status)) {
                status = colText.go();
                colText.setYLine(yLine);
            }

        } else {
            // TextField,??
            String key = text.getKey();// PdfTextid
            if (alreadyExistFields.contains(key)) { // ?
                key = createUniqueName();
            }
            alreadyExistFields.add(key);
            TextField tf = new TextField(pdfContentByte.getPdfWriter(), new Rectangle(llx, lly, urx, ury), key);
            tf.setAlignment(horizontalAlignment);
            tf.setText(text.getText());
            tf.setFont(PdfUtils.createSongLightBaseFont());

            // styledText ??,?
            if (!text.isStyledText()) {
                tf.setOptions(TextField.MULTILINE);
            }

            try {
                pdfContentByte.getPdfWriter().addAnnotation(tf.getTextField());
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }

    atrans = new AffineTransform();
    atrans.rotate(-angle, x, jasperPrint.getPageHeight() - y);
    pdfContentByte.transform(atrans);

    /*   */
    exportBox(text, text);
}