Example usage for com.lowagie.text Element ALIGN_CENTER

List of usage examples for com.lowagie.text Element ALIGN_CENTER

Introduction

In this page you can find the example usage for com.lowagie.text Element ALIGN_CENTER.

Prototype

int ALIGN_CENTER

To view the source code for com.lowagie.text Element ALIGN_CENTER.

Click Source Link

Document

A possible value for paragraph alignment.

Usage

From source file:net.sf.jasperreports.engine.export.JRPdfExporter.java

License:LGPL

/**
 *
 *//*from  w ww .j a v a  2  s  .  c o  m*/
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.getLineBox().getTopPadding().intValue();
    int leftPadding = text.getLineBox().getLeftPadding().intValue();
    int bottomPadding = text.getLineBox().getBottomPadding().intValue();
    int rightPadding = text.getLineBox().getRightPadding().intValue();

    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.setRGBColorFill(backcolor.getRed(), backcolor.getGreen(), backcolor.getBlue());
        pdfContentByte.rectangle(x + xFillCorrection, jasperPrint.getPageHeight() - y + yFillCorrection, width,
                -height);
        pdfContentByte.fill();
    }

    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;
        }
        }

        ColumnText colText = new ColumnText(pdfContentByte);
        colText.setSimpleColumn(getPhrase(styledText, text), x + leftPadding,
                jasperPrint.getPageHeight() - y - topPadding - verticalOffset - text.getLeadingOffset(),
                //+ text.getLineSpacingFactor() * text.getFont().getSize(),
                x + width - rightPadding, jasperPrint.getPageHeight() - y - height + bottomPadding, 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);

        colText.go();
    }

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

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

From source file:nl.dykema.jxmlnote.report.pdf.PdfParagraph.java

License:Open Source License

protected int getAlign(XMLNoteParStyle st) {
    String align = st.align();/* w ww. ja  va2 s  .  co  m*/
    if (align.equals(XMLNoteParStyle.ALIGN_LEFT)) {
        return Element.ALIGN_LEFT;
    } else if (align.equals(XMLNoteParStyle.ALIGN_RIGHT)) {
        return Element.ALIGN_RIGHT;
    } else if (align.equals(XMLNoteParStyle.ALIGN_CENTER)) {
        return Element.ALIGN_CENTER;
    } else if (align.equals(XMLNoteParStyle.ALIGN_CENTER)) {
        return Element.ALIGN_JUSTIFIED;
    } else {
        return Element.ALIGN_LEFT;
    }
}

From source file:nl.dykema.jxmlnote.report.pdf.PdfParagraph.java

License:Open Source License

public Paragraph setAlignment(Report.Align a) {
    int align = Element.ALIGN_LEFT;
    if (a.equals(Report.Align.RIGHT)) {
        align = Element.ALIGN_RIGHT;
    } else if (a.equals(Report.Align.CENTER)) {
        align = Element.ALIGN_CENTER;
    } else if (a.equals(Report.Align.JUSTIFY)) {
        align = Element.ALIGN_JUSTIFIED;
    }/* w w  w  .j  av a  2  s . c o m*/
    super.setAlignment(align);
    return this;
}

From source file:nl.dykema.jxmlnote.report.pdf.PdfReport.java

License:Open Source License

public int getPdfAlign(Report.Align a) {
    if (a.equals(Align.LEFT)) {
        return Element.ALIGN_LEFT;
    } else if (a.equals(Align.RIGHT)) {
        return Element.ALIGN_RIGHT;
    } else if (a.equals(Align.CENTER)) {
        return Element.ALIGN_CENTER;
    } else if (a.equals(Align.JUSTIFY)) {
        return Element.ALIGN_JUSTIFIED;
    } else {//from w  w  w. j  a  v a2 s.co  m
        return Element.ALIGN_LEFT;
    }
}

From source file:nl.dykema.jxmlnote.report.pdf.PdfReport.java

License:Open Source License

public int getAlign(AttributeSet s) {
    if (StyleConstants.getAlignment(s) == StyleConstants.ALIGN_LEFT) {
        return Element.ALIGN_LEFT;
    } else if (StyleConstants.getAlignment(s) == StyleConstants.ALIGN_CENTER) {
        return Element.ALIGN_CENTER;
    } else if (StyleConstants.getAlignment(s) == StyleConstants.ALIGN_RIGHT) {
        return Element.ALIGN_RIGHT;
    } else if (StyleConstants.getAlignment(s) == StyleConstants.ALIGN_JUSTIFIED) {
        return Element.ALIGN_JUSTIFIED;
    } else {// www  . j a va  2s  . co m
        return Element.ALIGN_LEFT;
    }
}

From source file:nl.knaw.dans.common.lang.pdf.PdfPageLayouter.java

License:Apache License

public void onEndPage(final PdfWriter writer, final Document document) {
    final float bottom = document.bottom();
    final float centerX = getCenterX(document);
    final PdfContentByte canvas = writer.getDirectContent();
    final int rotation = 0;

    final PdfPTable table = new PdfPTable(5);
    table.setTotalWidth(PAGE_NUMBER_TABLE_WIDTH);
    table.getDefaultCell().setHorizontalAlignment(Element.ALIGN_CENTER);
    table.getDefaultCell().setBorder(0);

    table.addCell(TO_FIRST);//from   w ww  .j  a v a 2s .c o m
    table.addCell(TO_PREV);
    table.addCell(new Phrase(new Chunk("" + document.getPageNumber(), FONT)));
    table.addCell(TO_NEXT);
    table.addCell(TO_LAST);

    table.writeSelectedRows(0, -1, centerX - (table.getTotalWidth() / 2), bottom - FOOTER_POSITION, canvas);
    if (footerPhrase == null)
        return;
    showTextAligned(canvas, Element.ALIGN_CENTER, new Phrase(footerPhrase), centerX, bottom - FOOTER_POSITION,
            rotation);
}

From source file:open.dolphin.client.AuditController.java

License:Open Source License

private void makePDF() {

    //- ?/*from ww w  .ja v  a  2 s.  co m*/
    Document doc = new Document(PageSize.A4, 20.0F, 20.0F, 40.0F, 40.0F);

    try {
        SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss");
        String fileName = "_" + sdf.format(new java.util.Date()) + ".pdf";

        //()??
        FileOutputStream fos = new FileOutputStream(outputDir.getText() + fileName);
        PdfWriter pdfwriter = PdfWriter.getInstance(doc, fos);
        Font font_header = new Font(BaseFont.createFont("HeiseiKakuGo-W5", "UniJIS-UCS2-H", false), 15.0F, 1);
        Font font_g11 = new Font(BaseFont.createFont("HeiseiKakuGo-W5", "UniJIS-UCS2-H", false), 11.0F);
        Font font_g10 = new Font(BaseFont.createFont("HeiseiKakuGo-W5", "UniJIS-UCS2-H", false), 10.0F);
        //- ?
        Font font_m8 = new Font(BaseFont.createFont("HeiseiMin-W3", "UniJIS-UCS2-HW-H", false), 8.0F);
        Font font_underline_11 = new Font(BaseFont.createFont("HeiseiKakuGo-W5", "UniJIS-UCS2-H", false), 11.0F,
                4);
        Font font_red_11 = new Font(BaseFont.createFont("HeiseiKakuGo-W5", "UniJIS-UCS2-H", false), 11.0F);
        font_red_11.setColor(new Color(255, 0, 0));
        Font font_empty = new Font(BaseFont.createFont("HeiseiKakuGo-W5", "UniJIS-UCS2-H", false), 9.0F);
        font_empty.setColor(new Color(255, 255, 255));

        Paragraph para_NF = new Paragraph(5, "\r\n",
                new Font(BaseFont.createFont("HeiseiKakuGo-W5", "UniJIS-UCS2-H", false), 13, Font.NORMAL));
        para_NF.setAlignment(Element.ALIGN_CENTER);

        // ??
        String author = Project.getProjectStub().getUserModel().getCommonName();
        doc.addAuthor(author);
        doc.addSubject("");

        HeaderFooter header = new HeaderFooter(new Phrase("", font_header),
                false);
        header.setAlignment(1);
        doc.setHeader(header);

        HeaderFooter footer = new HeaderFooter(new Phrase("--"), new Phrase("--"));
        footer.setAlignment(1);
        footer.setBorder(0);
        doc.setFooter(footer);

        doc.open();

        SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy''MM''dd'' HH''mm''");
        String today = sdf1.format(new java.util.Date());
        Paragraph para_0 = new Paragraph("?" + today, font_g11);
        para_0.setAlignment(2);
        doc.add(para_0);
        Paragraph para_1 = new Paragraph("?" + author, font_g11);
        para_1.setAlignment(2);
        doc.add(para_1);
        doc.add(new Paragraph(""));
        // 
        doc.add(para_NF);
        doc.add(para_NF);

        for (int cnt = 0; cnt < outputList.size(); cnt++) {

            InnerBean bean = outputList.get(cnt);
            Person person = bean.getPerson();

            Paragraph para_2 = new Paragraph("ID" + person.idProperty().get(), font_underline_11);
            para_2.setAlignment(0);
            doc.add(para_2);
            Paragraph para_3 = new Paragraph("???" + person.nameProperty().get(),
                    font_underline_11);
            para_3.setAlignment(0);
            doc.add(para_3);
            Paragraph para_4 = new Paragraph("" + person.nameKanaProperty().get(),
                    font_underline_11);
            para_4.setAlignment(0);
            doc.add(para_4);
            Paragraph para_5 = new Paragraph("" + person.sexProperty().get(), font_underline_11);
            para_5.setAlignment(0);
            doc.add(para_5);
            Paragraph para_6 = new Paragraph("" + person.birthdayProperty().get(),
                    font_underline_11);
            para_6.setAlignment(0);
            doc.add(para_6);

            Table karteHistoryTable = new Table(5);
            karteHistoryTable.setWidth(100.0F);
            int[] uriage_table_width = { 25, 20, 30, 20, 25 };
            karteHistoryTable.setWidths(uriage_table_width);
            //karteHistoryTable.setDefaultHorizontalAlignment(1);
            //karteHistoryTable.setDefaultVerticalAlignment(5);
            karteHistoryTable.setPadding(3.0F);
            karteHistoryTable.setSpacing(0.0F);
            karteHistoryTable.setBorderColor(new Color(0, 0, 0));

            Cell cell_01 = new Cell(new Phrase("?", font_g10));
            cell_01.setGrayFill(0.8F);
            cell_01.setHorizontalAlignment(Element.ALIGN_CENTER);
            Cell cell_11 = new Cell(new Phrase("?", font_g10));
            cell_11.setGrayFill(0.8F);
            cell_11.setHorizontalAlignment(Element.ALIGN_CENTER);
            Cell cell_21 = new Cell(new Phrase("", font_g10));
            cell_21.setGrayFill(0.8F);
            cell_21.setHorizontalAlignment(Element.ALIGN_CENTER);
            Cell cell_31 = new Cell(new Phrase("", font_g10));
            cell_31.setGrayFill(0.8F);
            cell_31.setHorizontalAlignment(Element.ALIGN_CENTER);
            Cell cell_41 = new Cell(new Phrase("", font_g10));
            cell_41.setGrayFill(0.8F);
            cell_41.setHorizontalAlignment(Element.ALIGN_CENTER);

            karteHistoryTable.addCell(cell_01);
            karteHistoryTable.addCell(cell_11);
            karteHistoryTable.addCell(cell_21);
            karteHistoryTable.addCell(cell_31);
            karteHistoryTable.addCell(cell_41);

            List<KarteBean> list = bean.getResult();
            KarteBean karteInfo = list.get(0);
            List<DocInfoModel> docInfoList = karteInfo.getDocInfoList();

            //- ???
            int stepCount = 22;
            int tempCount = 0;
            int pageCount = 0;

            String firstKarteMaker = null;
            String karteMakeDate = null;
            if (docInfoList != null) {
                for (int i = 0; i < docInfoList.size(); ++i) {
                    DocInfoModel docInfo = docInfoList.get(i);
                    Cell cell = new Cell(new Phrase(docInfo.getFirstConfirmDateTime(), font_m8));
                    if (karteMakeDate == null || !karteMakeDate.equals(docInfo.getFirstConfirmDateTime())) {
                        karteMakeDate = docInfo.getFirstConfirmDateTime();
                        firstKarteMaker = docInfo.getPurpose();
                    }
                    cell.setHorizontalAlignment(0);
                    cell.setHorizontalAlignment(Element.ALIGN_CENTER);
                    karteHistoryTable.addCell(cell);
                    cell = new Cell(new Phrase(firstKarteMaker, font_m8));
                    cell.setHorizontalAlignment(0);
                    cell.setHorizontalAlignment(Element.ALIGN_CENTER);
                    karteHistoryTable.addCell(cell);
                    //- 
                    String addTitle = docInfo.getTitle();
                    addTitle = addTitle.replace("\r\n", "");
                    addTitle = addTitle.replace("\n", "");
                    cell = new Cell(new Phrase(addTitle, font_m8));
                    cell.setHorizontalAlignment(0);
                    karteHistoryTable.addCell(cell);
                    cell = new Cell(new Phrase(docInfo.getPurpose(), font_m8));
                    cell.setHorizontalAlignment(0);
                    cell.setHorizontalAlignment(Element.ALIGN_CENTER);
                    karteHistoryTable.addCell(cell);
                    cell = new Cell(new Phrase(docInfo.getConfirmDateTime(), font_m8));
                    cell.setHorizontalAlignment(0);
                    cell.setHorizontalAlignment(Element.ALIGN_CENTER);
                    karteHistoryTable.addCell(cell);

                    if (stepCount == tempCount) {
                        if (pageCount == 0) {
                            stepCount += 5;
                            pageCount++;
                        }
                        tempCount = 0;
                        doc.add(karteHistoryTable);
                        doc.newPage();
                        karteHistoryTable.deleteAllRows();
                        karteHistoryTable.addCell(cell_01);
                        karteHistoryTable.addCell(cell_11);
                        karteHistoryTable.addCell(cell_21);
                        karteHistoryTable.addCell(cell_31);
                        karteHistoryTable.addCell(cell_41);
                    } else {
                        tempCount++;
                    }
                }

                //                    Cell Empty_Cell = new Cell(new Phrase("empty", font_empty));
                //                    for (int i = docInfoList.size(); i < docInfoList.size() + 4; ++i) {
                //                        for (int j = 0; j < 4; ++j) {
                //                            karteHistoryTable.addCell(Empty_Cell);
                //                        }
                //                    }
                //
                //            Cell cell_goukei = new Cell(new Phrase("?", font_g10));
                //            cell_goukei.setGrayFill(0.8F);
                //            cell_goukei.setColspan(3);
                //            karteHistoryTable.addCell(cell_goukei);
                //            Cell cell_sum = new Cell(new Phrase("136,900", font_m10));
                //            cell_sum.setHorizontalAlignment(2);
                //            karteHistoryTable.addCell(cell_sum);
                doc.add(karteHistoryTable);
                doc.newPage();

            } else {
                // 
                doc.add(para_NF);

                Paragraph noData = new Paragraph("??", font_m8);
                noData.setAlignment(0);
                doc.add(noData);
                doc.newPage();
            }
        }
    } catch (DocumentException | IOException e) {
        Logger.getLogger(AuditController.class.getName()).log(Level.SEVERE, null, e);
    } finally {
        doc.close();
    }
}

From source file:open.dolphin.hiro.PrescriptionPDFMaker.java

/**
 * ??
 * 
 * @param pcell
 */
private void setAlignCenter(PdfPCell pcell) {
    pcell.setHorizontalAlignment(Element.ALIGN_CENTER);
}

From source file:org.activityinfo.server.report.renderer.itext.ItextMapRenderer.java

License:Open Source License

private void renderLegend(MapReportElement element, Document doc) throws DocumentException, IOException {

    Table table = new Table(2);
    table.setBorderWidth(1);//from  w w w.j a v  a  2  s. com
    table.setWidth(100f);
    table.setBorderColor(new Color(100, 100, 100));
    table.setPadding(5);
    table.setSpacing(0);
    table.setCellsFitPage(true);
    table.setTableFitsPage(true);
    table.setWidths(new int[] { 1, 3 });

    Cell cell = new Cell(I18N.CONSTANTS.legend());
    cell.setHeader(true);
    cell.setColspan(2);
    table.addCell(cell);
    table.endHeaders();

    for (MapLayerLegend legend : element.getContent().getLegends()) {

        Cell symbolCell = new Cell();
        symbolCell.setHorizontalAlignment(Element.ALIGN_CENTER);
        symbolCell.setVerticalAlignment(Element.ALIGN_MIDDLE);

        Image symbol = createLegendSymbol(legend, imageCreator);
        symbolCell.addElement(symbol);

        Cell descriptionCell = new Cell();
        addLegendDescription(element, legend.getDefinition(), descriptionCell);

        table.addCell(symbolCell);
        table.addCell(descriptionCell);
    }
    doc.add(table);
}

From source file:org.apache.poi.xwpf.converter.internal.itext.stylable.StylableParagraph.java

License:Open Source License

public void applyStyles(XWPFParagraph p, Style style) {

    if (style != null) {
        // first process values from "style"
        // will be overridden by in-line values if available...
        StyleParagraphProperties paragraphProperties = style.getParagraphProperties();

        if (paragraphProperties != null) {
            FontInfos fontInfos = paragraphProperties.getFontInfos();
            if (fontInfos != null) {
                Font font = XWPFFontRegistry.getRegistry().getFont(fontInfos.getFontFamily(),
                        fontInfos.getFontEncoding(), fontInfos.getFontSize(), fontInfos.getFontStyle(),
                        fontInfos.getFontColor());
                setFont(font);/*  w  w w .j  av a 2  s. c  o m*/
            }
            // Alignment
            int alignment = paragraphProperties.getAlignment();
            if (alignment != Element.ALIGN_UNDEFINED) {
                setAlignment(alignment);
            }

            Float lineHeight = paragraphProperties.getLineHeight();
            if (lineHeight != null) {
                // super.getPdfPCell().setMinimumHeight(lineHeight);
                // FIXME : Is it correct???
                setLeading(lineHeight * super.getTotalLeading());
            }
            // System.err.println("IndentationRight "+paragraphProperties.getIndentationRight());
            setIndentationRight(paragraphProperties.getIndentationRight());
            setIndentationLeft(paragraphProperties.getIndentationLeft());
            setFirstLineIndent(paragraphProperties.getIndentationFirstLine());
            // StyleBorder borderBottom= paragraphProperties.getBorderBottom();

        }

    }

    ParagraphAlignment paragraphAlignment = p.getAlignment();

    // text-align

    if (paragraphAlignment != null) {
        int alignment = Element.ALIGN_UNDEFINED;
        switch (paragraphAlignment) {
        case LEFT:
            alignment = Element.ALIGN_LEFT;
            break;
        case RIGHT:
            alignment = Element.ALIGN_RIGHT;
            break;
        case CENTER:
            alignment = Element.ALIGN_CENTER;
            break;
        case BOTH:
            alignment = Element.ALIGN_JUSTIFIED;
            break;
        default:
            break;
        }

        setAlignment(alignment);
    }

    int indentationLeft = p.getIndentationLeft();
    if (indentationLeft > 0) {
        setIndentationLeft(indentationLeft);
    }

    // text-indent
    int indentationFirstLine = p.getIndentationFirstLine();
    if (indentationFirstLine > 0) {
        setFirstLineIndent(indentationFirstLine);
    }

    int indentationRight = p.getIndentationRight();

    if (indentationRight > 0) {
        setIndentationRight(indentationRight);
    }
    // verticalAlignment DOES not exists in StyleParagraphProperties iText
    // TextAlignment textAlignment = p.getVerticalAlignment();

    int left = p.getIndentationLeft();
    int right = p.getIndentationRight();

    if (right > 0) {
        setIndentationRight(dxa2points(right));
    }

    if (left > 0) {
        setIndentationLeft(dxa2points(left));
    }

    int firstLineIndent = p.getIndentationFirstLine();
    if (firstLineIndent > 0) {
        setFirstLineIndent(dxa2points(firstLineIndent));
    }

    int spacingBefore = p.getSpacingBefore();
    if (spacingBefore > 0) {
        setSpacingBefore(dxa2points(spacingBefore));
    }
    if (p.getSpacingAfter() >= 0) {
        setSpacingAfter(dxa2points(p.getSpacingAfter()));

    } else {
        // XXX Seems to be a default :
        setSpacingAfter(10f);
    }

    if (p.getCTP().getPPr() != null) {
        if (p.getCTP().getPPr().getSpacing() != null) {

            if (p.getCTP().getPPr().getSpacing().getLine() != null) {

                // XXX PLQ : why 240 ???
                float leading = (p.getCTP().getPPr().getSpacing().getLine().floatValue() / 240);
                setMultipliedLeading(leading);
            }

        }
    }

    ParagraphAlignment alignment = p.getAlignment();
    switch (alignment) {
    case LEFT:
        setAlignment(Element.ALIGN_LEFT);
        break;
    case RIGHT:
        setAlignment(Element.ALIGN_RIGHT);
        break;

    case CENTER:
        setAlignment(Element.ALIGN_CENTER);
        break;

    case BOTH:
        setAlignment(Element.ALIGN_JUSTIFIED);
        break;

    default:
        break;
    }

}