Example usage for com.lowagie.text Paragraph setIndentationLeft

List of usage examples for com.lowagie.text Paragraph setIndentationLeft

Introduction

In this page you can find the example usage for com.lowagie.text Paragraph setIndentationLeft.

Prototype

public void setIndentationLeft(float indentation) 

Source Link

Document

Sets the indentation of this paragraph on the left side.

Usage

From source file:net.bull.javamelody.PdfRequestAndGraphDetailReport.java

License:Apache License

@Override
void toPdf() throws DocumentException, IOException {
    if (request != null) {
        writeHeader();// ww  w. j  av a 2  s .co  m

        writeRequests();

        addTableToDocument();

        if (JdbcWrapper.SINGLETON.getSqlCounter().isRequestIdFromThisCounter(request.getId())
                && !request.getName().toLowerCase(Locale.ENGLISH).startsWith("alter ")) {
            // inutile d'essayer d'avoir le plan d'excution des requtes sql
            // telles que "alter session set ..." (cf issue 152)
            writeSqlRequestExplainPlan();
        }
    }

    if (isGraphDisplayed()) {
        writeGraph();
    }

    if (request != null && request.getStackTrace() != null) {
        final Paragraph paragraph = new Paragraph("\n", cellFont);
        paragraph.setIndentationLeft(20);
        paragraph.setIndentationRight(20);
        paragraph.add(new Phrase("Stack-trace\n", boldFont));
        paragraph.add(new Phrase(request.getStackTrace().replace("\t", "        "), cellFont));
        addToDocument(paragraph);
    }
}

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

License:Open Source License

/**
 * Renders a Cell for// w ww  .j a  va2s .c  o  m
 *
 * @param label
 * @param header
 * @param depth
 * @param leaf
 * @param horizantalAlignment
 * @return
 * @throws BadElementException
 */
public static Cell bodyCell(String label, boolean header, int depth, boolean leaf, int horizantalAlignment)
        throws BadElementException {

    Cell cell = new Cell();
    cell.setHorizontalAlignment(horizantalAlignment);

    if (label != null) {
        Paragraph para = new Paragraph(label);
        Font font = bodyFont();
        if (depth == 0 && !leaf) {
            font.setColor(Color.WHITE);
        }
        para.setFont(font);
        para.setIndentationLeft(LEFT_INDENT + (header ? HEADER3_FONT_SIZE * depth : 0));
        cell.addElement(para);
    }

    cell.setBorderWidthLeft(0f);
    cell.setBorderWidthRight(0);
    cell.setBorderWidthTop(0);

    if (!leaf && depth == 0) {
        cell.setBackgroundColor(BLUE4); // #95B3D7
        cell.setBorderWidthBottom(THIN_BORDER_WIDTH);
        cell.setBorderColorBottom(BLUE5); // #DBE5F1
    } else if (!leaf && depth == 1) {
        cell.setBackgroundColor(BLUE5);
        cell.setBorderWidthBottom(THIN_BORDER_WIDTH);
        cell.setBorderColorBottom(BLUE2);
    } else {
        cell.setBorderWidthBottom(THIN_BORDER_WIDTH);
        cell.setBorderColorBottom(BLUE5);
        cell.setBorderWidthTop(THIN_BORDER_WIDTH);
        cell.setBorderColorTop(BLUE5);
    }

    return cell;
}

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

License:Open Source License

public static void processLayout(XWPFParagraph paragraph, Paragraph pdfParagraph, XWPFStyle style,
        CTDocDefaults defaults) {/*from   w  ww.j av a 2 s .  co m*/

    float indentationLeft = -1;
    float indentationRight = -1;
    float firstLineIndent = -1;
    float spacingBefore = -1;
    float spacingAfter = -1;

    // 1) From style
    CTPPr ppr = getPPr(style);
    if (ppr != null) {

        // Indentation
        CTInd ind = ppr.getInd();
        if (ind != null) {

            // Left Indentation
            BigInteger left = ind.getLeft();
            if (left != null) {
                indentationLeft = dxa2points(left);
            }

            // Right Indentation
            BigInteger right = ind.getRight();
            if (right != null) {
                indentationRight = dxa2points(right);
            }

            // First line Indentation
            BigInteger firstLine = ind.getFirstLine();
            if (firstLine != null) {
                firstLineIndent = dxa2points(firstLine);
            }
        }

        // Spacing
        CTSpacing spacing = ppr.getSpacing();
        if (spacing != null) {

            // Spacing before
            BigInteger before = spacing.getBefore();
            if (before != null) {
                spacingBefore = dxa2points(before);
            }

            // Spacing after
            BigInteger after = spacing.getAfter();
            if (after != null) {
                spacingAfter = dxa2points(after);
            }
        }

        // Text aligment
        CTTextAlignment textAligment = ppr.getTextAlignment();
        if (textAligment != null) {
            // TODO
        }

    }

    // 2) From paragraph
    if (indentationLeft == -1 && paragraph.getIndentationLeft() != -1) {
        indentationLeft = dxa2points(paragraph.getIndentationLeft());

    }
    if (indentationRight == -1 && paragraph.getIndentationRight() != -1) {
        indentationRight = dxa2points(paragraph.getIndentationRight());
    }
    if (firstLineIndent == -1 && paragraph.getIndentationFirstLine() != -1) {
        firstLineIndent = dxa2points(paragraph.getIndentationFirstLine());
    }
    if (spacingBefore == -1 && paragraph.getSpacingBefore() != -1) {
        spacingBefore = dxa2points(paragraph.getSpacingBefore());
    }
    if (spacingAfter == -1 && paragraph.getSpacingAfter() != -1) {
        spacingAfter = dxa2points(paragraph.getSpacingAfter());
    }

    // 3) From default
    // TODO

    // Apply
    if (indentationLeft != -1) {
        pdfParagraph.setIndentationLeft(indentationLeft);
    }
    if (indentationRight != -1) {
        pdfParagraph.setIndentationRight(indentationRight);
    }
    if (firstLineIndent != -1) {
        pdfParagraph.setFirstLineIndent(firstLineIndent);
    }
    if (spacingBefore != -1) {
        pdfParagraph.setSpacingBefore(spacingBefore);
    }
    if (spacingAfter != -1) {
        pdfParagraph.setSpacingAfter(spacingAfter);
    }

    // Aligment
    ParagraphAlignment alignment = paragraph.getAlignment();
    switch (alignment) {
    case LEFT:
        pdfParagraph.setAlignment(Paragraph.ALIGN_LEFT);
        break;
    case RIGHT:
        pdfParagraph.setAlignment(Paragraph.ALIGN_RIGHT);
        break;

    case CENTER:
        pdfParagraph.setAlignment(Paragraph.ALIGN_CENTER);
        break;

    case BOTH:
        pdfParagraph.setAlignment(Paragraph.ALIGN_JUSTIFIED);
        break;
    }
}

From source file:org.areasy.common.doclet.document.tags.TagDD.java

License:Open Source License

public Element[] openTagElements() {
    Element[] elements = new Element[1];
    Paragraph p1 = createParagraph("");
    p1.setIndentationLeft((float) 20.0);
    elements[0] = p1;/*from  www .j  a va  2 s.  c o  m*/
    return elements;
}

From source file:org.drools.verifier.doc.DroolsDocsComponentFactory.java

License:Apache License

public static void newRulePage(Document document, String packageName, DrlRuleParser drlData)
        throws DocumentException {

    document.add(new Paragraph(packageName, PACKAGE_NAME));
    document.add(new Paragraph("Rule " + drlData.getName(), CHAPTER_TITLE));

    // Extends//w w w.j  a  v  a 2  s .  com
    int index = drlData.getName().lastIndexOf("extends");
    if (index > 0) {
        document.add(new Paragraph("Extends:", BODY_TEXT));

        Paragraph ext = new Paragraph(drlData.getName().substring("extends".length() + index), BODY_TEXT);
        ext.setIndentationLeft(INDENTATION_LEFT);
        document.add(ext);
    }

    // if the data came from guvnor, this will be empty
    if (drlData.getDescription() != null && drlData.getDescription().trim().equals("")) {
        Iterator<String> iter = drlData.getMetadata().iterator();
        while (iter.hasNext()) {
            String nextDesc = iter.next();
            if (nextDesc.startsWith("Description")) {
                String[] parts = splitFirst(nextDesc, ":");
                // no description
                if (parts.length == 1) {
                    // guvnor did not have it
                    document.add(newDescription(drlData.getDescription()));
                } else {
                    document.add(newDescription(parts[1]));
                }
            }
        }

    } else {
        document.add(newDescription(drlData.getDescription()));
    }

    // DRL
    document.add(newRuleTable(drlData));

    // Meta data
    document.add(newTable("Metadata", drlData.getMetadata()));

    // Other
    createOtherItems(document, drlData.getOtherInformation());

    document.newPage();
}

From source file:org.esa.nest.dat.reports.PDFFormat.java

License:Open Source License

private void allign(Document document) throws DocumentException {
    // Left/*from   w w w  .ja v  a 2s. com*/
    Paragraph paragraph = new Paragraph("This is right aligned text");
    paragraph.setAlignment(Element.ALIGN_RIGHT);
    document.add(paragraph);
    // Centered
    paragraph = new Paragraph("This is centered text");
    paragraph.setAlignment(Element.ALIGN_CENTER);
    document.add(paragraph);
    // Left
    paragraph = new Paragraph("This is left aligned text");
    paragraph.setAlignment(Element.ALIGN_LEFT);
    document.add(paragraph);
    // Left with indentation
    paragraph = new Paragraph("This is left aligned text with indentation");
    paragraph.setAlignment(Element.ALIGN_LEFT);
    paragraph.setIndentationLeft(50);

    document.add(paragraph);
}

From source file:org.gtdfree.addons.PDFExportAddOn.java

License:Open Source License

@Override
public void export(GTDModel model, ActionsCollection collection, OutputStream out,
        ExportAddOn.ExportOrder order, FileFilter ff, boolean compact) throws Exception {

    fontSelector = new FontSelector();
    fontSelectorB = new FontSelector();
    fontSelectorB2 = new FontSelector();
    fontSelectorB4 = new FontSelector();

    baseFont = fontModel.getBaseFont();/*  ww  w  . ja v  a 2 s .co m*/

    for (BaseFont bf : fontModel.getFonts()) {
        fontSelector.addFont(new Font(bf, baseFontSize));
        fontSelectorB.addFont(new Font(bf, baseFontSize, Font.BOLD));
        fontSelectorB2.addFont(new Font(bf, baseFontSize + 2, Font.BOLD));
        fontSelectorB4.addFont(new Font(bf, baseFontSize + 4, Font.BOLD));
    }

    boolean emptyH2 = false;
    boolean emptyH3 = false;

    PdfPTable actionTable = null;

    Document doc = new Document();

    if (sizeSet) {
        doc.setPageSize(pageSize);
    }
    if (marginSet) {
        doc.setMargins(marginLeft, marginRight, marginTop, marginBottom);
    }

    //System.out.println("PDF size "+doc.getPageSize().toString());
    //System.out.println("PDF m "+marginLeft+" "+marginRight+" "+marginTop+" "+marginBottom);

    @SuppressWarnings("unused")
    PdfWriter pw = PdfWriter.getInstance(doc, out);

    doc.addCreationDate();
    doc.addTitle("GTD-Free PDF");
    doc.addSubject("GTD-Free data exported as PDF");

    HeaderFooter footer = new HeaderFooter(newParagraph(), true);
    footer.setAlignment(HeaderFooter.ALIGN_CENTER);
    footer.setBorder(HeaderFooter.TOP);
    doc.setFooter(footer);

    doc.open();

    Phrase ch = newTitle("GTD-Free Data");
    Paragraph p = new Paragraph(ch);
    p.setAlignment(Paragraph.ALIGN_CENTER);

    PdfPTable t = new PdfPTable(1);
    t.setWidthPercentage(100f);
    PdfPCell c = newCell(p);
    c.setBorder(Table.BOTTOM);
    c.setBorderWidth(2.5f);
    c.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
    c.setPadding(5f);
    t.addCell(c);
    doc.add(t);

    Iterator<Object> it = collection.iterator(order);

    while (it.hasNext()) {
        Object o = it.next();

        if (o == ActionsCollection.ACTIONS_WITHOUT_PROJECT) {

            if (order == ExportAddOn.ExportOrder.FoldersProjectsActions) {

                doc.add(newSubSection(ActionsCollection.ACTIONS_WITHOUT_PROJECT));

                emptyH2 = false;
                emptyH3 = true;
            } else {

                doc.add(newSection(ActionsCollection.ACTIONS_WITHOUT_PROJECT));

                emptyH2 = true;
                emptyH3 = false;
            }

            continue;
        }

        if (o instanceof Folder) {

            Folder f = (Folder) o;

            if (actionTable != null) {
                doc.add(actionTable);
                actionTable = null;
            }

            if (f.isProject()) {

                if (order == ExportAddOn.ExportOrder.ProjectsActions
                        || order == ExportAddOn.ExportOrder.ProjectsFoldersActions) {

                    if (emptyH2 || emptyH3) {
                        p = newParagraph(NONE_DOT);
                        doc.add(p);
                    }

                    doc.add(newSection(f.getName()));

                    if (compact) {
                        if (f.getDescription() != null && f.getDescription().length() > 0) {
                            p = newParagraph(f.getDescription());
                            p.setIndentationLeft(10f);
                            p.setIndentationRight(10f);
                            doc.add(p);
                        }
                    } else {
                        t = new PdfPTable(2);
                        t.setKeepTogether(true);
                        t.setSpacingBefore(5f);
                        t.setWidthPercentage(66f);
                        t.setWidths(new float[] { 0.33f, 0.66f });

                        c = newCell("ID");
                        t.addCell(c);
                        c = newCell(newStrongParagraph(String.valueOf(f.getId())));
                        t.addCell(c);
                        c = newCell("Type");
                        t.addCell(c);
                        c = newCell(newStrongParagraph("Project"));
                        t.addCell(c);
                        c = newCell("Open");
                        t.addCell(c);
                        c = newCell(newStrongParagraph(String.valueOf(f.getOpenCount())));
                        t.addCell(c);
                        c = newCell("All");
                        t.addCell(c);
                        c = newCell(newStrongParagraph(String.valueOf(f.size())));
                        t.addCell(c);
                        c = newCell("Description");
                        t.addCell(c);
                        c = newDescriptionCell(f.getDescription());
                        t.addCell(c);

                        doc.add(t);
                    }

                    emptyH2 = true;
                    emptyH3 = false;

                } else {

                    if (emptyH3) {
                        p = newParagraph(NONE_DOT);
                        doc.add(p);
                    }

                    doc.add(newSubSection("Project:" + " " + f.getName()));

                    emptyH2 = false;
                    emptyH3 = true;
                }

                continue;

            }
            if (order == ExportAddOn.ExportOrder.FoldersActions
                    || order == ExportAddOn.ExportOrder.FoldersProjectsActions) {

                if (emptyH2 || emptyH3) {
                    p = newParagraph(NONE_DOT);
                    doc.add(p);
                }

                doc.add(newSection(f.getName()));

                if (compact) {
                    if (f.getDescription() != null && f.getDescription().length() > 0) {
                        p = newParagraph(f.getDescription());
                        p.setIndentationLeft(10f);
                        p.setIndentationRight(10f);
                        doc.add(p);
                    }
                } else {

                    t = new PdfPTable(2);
                    t.setKeepTogether(true);
                    t.setSpacingBefore(5f);
                    t.setWidthPercentage(66f);
                    t.setWidths(new float[] { 0.33f, 0.66f });

                    c = newCell("ID");
                    t.addCell(c);
                    c = newCell(newStrongParagraph(String.valueOf(f.getId())));
                    t.addCell(c);

                    String type = "";
                    if (f.isAction()) {
                        type = "Action list";
                    } else if (f.isInBucket()) {
                        type = "In-Bucket";
                    } else if (f.isQueue()) {
                        type = "Next action queue";
                    } else if (f.isReference()) {
                        type = "Reference list";
                    } else if (f.isSomeday()) {
                        type = "Someday/Maybe list";
                    } else if (f.isBuildIn()) {
                        type = "Default list";
                    }

                    c = newCell("Type");
                    t.addCell(c);
                    c = newCell(newStrongParagraph(type));
                    t.addCell(c);
                    c = newCell("Open");
                    t.addCell(c);
                    c = newCell(newStrongParagraph(String.valueOf(f.getOpenCount())));
                    t.addCell(c);
                    c = newCell("All");
                    t.addCell(c);
                    c = newCell(newStrongParagraph(String.valueOf(f.size())));
                    t.addCell(c);
                    c = newCell("Description");
                    t.addCell(c);
                    c = newDescriptionCell(f.getDescription());
                    t.addCell(c);

                    doc.add(t);
                }

                emptyH2 = true;
                emptyH3 = false;

            } else {

                if (emptyH3) {
                    p = newParagraph(NONE_DOT);
                    doc.add(p);
                }

                doc.add(newSubSection("List:" + " " + f.getName()));

                emptyH2 = false;
                emptyH3 = true;

            }

            continue;

        }

        if (o instanceof Action) {
            emptyH2 = false;
            emptyH3 = false;

            Action a = (Action) o;

            if (compact) {

                if (actionTable == null) {
                    actionTable = new PdfPTable(5);
                    actionTable.setWidthPercentage(100f);
                    actionTable.setHeaderRows(1);
                    actionTable.setSpacingBefore(5f);
                    c = newHeaderCell("ID");
                    actionTable.addCell(c);
                    c = newHeaderCell("Pri.");
                    actionTable.addCell(c);
                    c = newHeaderCell("Description");
                    actionTable.addCell(c);
                    c = newHeaderCell("Reminder");
                    actionTable.addCell(c);
                    c = newHeaderCell(CHECK_RESOLVED);
                    actionTable.addCell(c);

                    float width = doc.getPageSize().getWidth() - doc.getPageSize().getBorderWidthLeft()
                            - doc.getPageSize().getBorderWidthRight();
                    int i = model.getLastActionID();
                    float step = baseFontSize - 1;
                    int steps = (int) Math.floor(Math.log10(i)) + 1;
                    // ID column
                    float col1 = 8 + steps * step;
                    // Priority column
                    float col2 = 4 + 3 * (baseFontSize + 4);
                    // Reminder column
                    float col4 = 10 + step * 11;
                    // Resolved column
                    float col5 = 8 + baseFontSize;
                    // Description column
                    float col3 = width - col1 - col2 - col4 - col5;
                    actionTable.setWidths(new float[] { col1, col2, col3, col4, col5 });

                }

                addSingleActionRow(a, actionTable);

            } else {
                addSingleActionTable(model, doc, a);
            }
        }

    }

    if (actionTable != null) {
        doc.add(actionTable);
        actionTable = null;
    }
    if (emptyH2 || emptyH3) {

        p = newParagraph(NONE_DOT);
        doc.add(p);
    }

    //w.writeCharacters("Exported: "+ApplicationHelper.toISODateTimeString(new Date()));

    doc.close();
}

From source file:org.kuali.kfs.module.ar.report.service.impl.ContractsGrantsInvoiceReportServiceImpl.java

License:Open Source License

/**
 * Generates the pdf file for printing the envelopes.
 *
 * @param list/*from   w  ww  .j  av a2 s.  co  m*/
 * @param outputStream
 * @throws DocumentException
 * @throws IOException
 */
protected void generateCombinedPdfForEnvelopes(Collection<ContractsGrantsInvoiceDocument> list,
        OutputStream outputStream) throws DocumentException, IOException {
    Document document = new Document(
            new Rectangle(ArConstants.InvoiceEnvelopePdf.LENGTH, ArConstants.InvoiceEnvelopePdf.WIDTH));
    PdfWriter.getInstance(document, outputStream);
    boolean pageAdded = false;

    for (ContractsGrantsInvoiceDocument invoice : list) {
        // add a document
        for (InvoiceAddressDetail invoiceAddressDetail : invoice.getInvoiceAddressDetails()) {
            if (ArConstants.InvoiceTransmissionMethod.MAIL
                    .equals(invoiceAddressDetail.getInvoiceTransmissionMethodCode())) {
                CustomerAddress address = invoiceAddressDetail.getCustomerAddress();

                Integer numberOfEnvelopesToPrint = address.getCustomerEnvelopesToPrintQuantity();
                if (ObjectUtils.isNull(numberOfEnvelopesToPrint)) {
                    numberOfEnvelopesToPrint = 1;
                }
                for (int i = 0; i < numberOfEnvelopesToPrint; i++) {
                    // if a page has not already been added then open the document.
                    if (!pageAdded) {
                        document.open();
                    }
                    pageAdded = true;
                    document.newPage();
                    // adding the sent From address
                    Organization org = invoice.getInvoiceGeneralDetail().getAward()
                            .getPrimaryAwardOrganization().getOrganization();
                    Paragraph sentBy = generateAddressParagraph(org.getOrganizationName(),
                            org.getOrganizationLine1Address(), org.getOrganizationLine2Address(),
                            org.getOrganizationCityName(), org.getOrganizationStateCode(),
                            org.getOrganizationZipCode(), ArConstants.PdfReportFonts.ENVELOPE_SMALL_FONT);
                    sentBy.setIndentationLeft(ArConstants.InvoiceEnvelopePdf.INDENTATION_LEFT);
                    sentBy.setAlignment(Element.ALIGN_LEFT);

                    // adding the send To address
                    String string;
                    Paragraph sendTo = generateAddressParagraph(address.getCustomerAddressName(),
                            address.getCustomerLine1StreetAddress(), address.getCustomerLine2StreetAddress(),
                            address.getCustomerCityName(), address.getCustomerStateCode(),
                            address.getCustomerZipCode(), ArConstants.PdfReportFonts.ENVELOPE_TITLE_FONT);
                    sendTo.setAlignment(Element.ALIGN_CENTER);
                    sendTo.add(new Paragraph(KFSConstants.BLANK_SPACE));

                    document.add(sentBy);
                    document.add(sendTo);
                }
            }
        }
    }
    if (pageAdded) {
        document.close();
    }
}

From source file:org.pz.platypus.plugin.pdf.PdfOutfile.java

License:Open Source License

/**
 * Handles indenting the entire paragraph. Indent occurs from the left margin.
 *
 * @param para paragraph//from  w  ww.  j a v a 2 s .co m
 * @param pData PDF data containing the amount of indent (in points)
 * @return the amount of indent in points.
 */
float doParagraphIndent(final Paragraph para, final PdfData pData) {
    assert (para != null);
    assert (pData != null);

    float indent = pData.getParagraphIndent();
    para.setIndentationLeft(indent);
    return (indent);
}

From source file:org.sakaiproject.evaluation.tool.reporting.EvalPDFReportBuilder.java

License:Educational Community License

private void addBigElementArray(ArrayList<Element> myElements) {
    //20140226 - daniel.merino@unavarra.es - https://jira.sakaiproject.org/browse/EVALSYS-1100
    //Adds an array of elements that does not fit in a column, one by one.
    //Current lowagie library does not allow to copy a List if it exceeds a whole page. It is truncated.
    //So we add Lists always one element at a time.
    LOG.debug(/*  ww  w .  ja  v a  2  s. c o m*/
            "Entering in AddBigElementArray with: " + myElements.toString() + ". Curent column is: " + column);

    responseArea.setText(null);
    LOG.debug("Initial vertical position: " + responseArea.getYLine());

    for (Element element : myElements) {
        if (element.getClass().equals(com.lowagie.text.List.class)) {
            LOG.debug("We have a List element to add.");
            com.lowagie.text.List myList = (com.lowagie.text.List) element;
            for (int i = 0; i < myList.size(); i++) {
                ArrayList<ListItem> arrayItems = myList.getItems();
                ListItem miItem = arrayItems.get(i);
                String text = (String) miItem.getContent();
                Paragraph para = new Paragraph("\u2022   " + text, paragraphFont);
                para.setIndentationLeft(20f);
                this.addLittleElementWithJump(para);
            }
        } else {
            addLittleElementWithJump(element);
        }
    }

}