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:de.xirp.report.ReportGenerator.java

License:Open Source License

/**
 * Adds the header page to the PDF//  w  w w .jav  a  2  s .c o m
 * {@link com.lowagie.text.Document}.
 * 
 * @throws DocumentException
 *             if something went wrong adding the page.
 * @see com.lowagie.text.Document
 */
private static void addHeader() throws DocumentException {
    Header header = report.getHeader();

    para = getParagraph(header.getTitle(), HEADER, Element.ALIGN_CENTER);
    document.add(para);
    addSkip(4);
    List list = getList(ListType.BULLET);
    list.add(new ListItem(I18n.getString("ReportGenerator.report.header.created.date") //$NON-NLS-1$
            + " " + Util.getTimeAsString(header.getDate(), "dd.MM.yyyy"))); //$NON-NLS-1$ //$NON-NLS-2$
    list.add(new ListItem(I18n.getString("ReportGenerator.report.header.created.time") //$NON-NLS-1$
            + " " //$NON-NLS-1$
            + Util.getTimeAsString(header.getDate(), "HH:mm") //$NON-NLS-1$
            + I18n.getString("ReportGenerator.report.oClock"))); //$NON-NLS-1$
    list.add(new ListItem(I18n.getString("ReportGenerator.report.header.created.plugin") //$NON-NLS-1$
            + " " + header.getPlugin().getName())); //$NON-NLS-1$
    list.add(new ListItem(I18n.getString("ReportGenerator.report.header.created.robot") //$NON-NLS-1$
            + " " + header.getRobot().getName())); //$NON-NLS-1$
    document.add(list);
}

From source file:de.xirp.report.ReportGenerator.java

License:Open Source License

/**
 * Adds a//  www  . j ava  2 s  .  c  om
 * {@link de.xirp.report.data.ContentPartImage image}
 * item to the PDF {@link com.lowagie.text.Document}.
 * 
 * @param item
 *            The image item to add.
 * @throws IOException
 *             if something went wrong saving the PDF.
 * @throws DocumentException
 *             if something went wrong adding the page.
 * @throws MalformedURLException
 *             if something went wrong saving the PDF.
 * @see de.xirp.report.data.ContentPartImage
 * @see com.lowagie.text.Document
 */
private static void addImage(ContentPartImage item)
        throws MalformedURLException, IOException, DocumentException {

    imageCounter++;

    String path = ""; //$NON-NLS-1$
    File file = new File(item.getPath());
    if (file.exists()) {
        path = item.getPath();
    }

    Image image = Image.getInstance(path);
    image.setAlignment(Image.MIDDLE);
    int maxWidth = 500;
    float plain = image.plainWidth();
    if (plain > maxWidth) {
        float percentage = maxWidth / plain;
        image.scalePercent(percentage * 100);
    }
    document.add(image);
    document.add(getParagraph(I18n.getString("ReportGenerator.report.document.image") //$NON-NLS-1$
            + " " + imageCounter + ": " + item.getShortDescription(), //$NON-NLS-1$ //$NON-NLS-2$
            IMAGE, Element.ALIGN_CENTER));

}

From source file:de.xirp.report.ReportGenerator.java

License:Open Source License

/**
 * Adds a//from ww  w .  j a  va2s .com
 * {@link de.xirp.report.data.ContentPartTable table}
 * item to the PDF {@link com.lowagie.text.Document}.
 * 
 * @param reportTable
 *            The table to add.
 * @throws DocumentException
 *             if something went wrong adding the page.
 * @see de.xirp.report.data.ContentPartTable
 * @see com.lowagie.text.Document
 */
private static void addTable(ContentPartTable reportTable) throws DocumentException {

    tableCounter++;
    PdfPTable table = new PdfPTable(reportTable.getColumnCount());

    for (String cellHeader : reportTable.getHeader().getColumnHeaders()) {
        table.addCell(cellHeader);
    }
    logClass.debug("Table row count: " + reportTable.getRows().size() //$NON-NLS-1$
            + Constants.LINE_SEPARATOR);
    for (ContentPartTableRow row : reportTable.getRows()) {
        for (int i = 0; i < reportTable.getColumnCount(); i++) {
            table.addCell(row.getRowEntrys().get(i));
        }
    }

    // cell = new PdfPCell(new Paragraph("cell test1"));
    // cell.setBorderColor(new Color(255, 0, 0));
    // table.addCell(cell);
    // cell = new PdfPCell(new Paragraph("cell test2"));
    // cell.setColspan(2);
    // cell.setBackgroundColor(new Color(0xC0, 0xC0, 0xC0));
    // table.addCell(cell);

    document.add(table);
    document.add(getParagraph(I18n.getString("ReportGenerator.report.document.table") + " " //$NON-NLS-1$ //$NON-NLS-2$
            + tableCounter + ": " //$NON-NLS-1$
            + reportTable.getShortDescription(), IMAGE, Element.ALIGN_CENTER));
}

From source file:desktopbugtracker.export.PdfAlign.java

License:Open Source License

public int toITextElement() {
    switch (this) {
    case CENTER://  w ww .j  a  v  a 2  s.c  o  m
        return Element.ALIGN_CENTER;
    default:
        return Element.ALIGN_LEFT;
    }
}

From source file:domain.reports.menu.PDFReportMenu.java

License:LGPL

/**
 * Return a report section formatted as a table
 * @param data/*  www  .j a v a2  s.c  o  m*/
 * @return
 */
PdfPTable getGroupDetail(Recordset master, Recordset detail) throws Throwable {

    //cols
    PdfPTable datatable = new PdfPTable(2);

    //header
    datatable.getDefaultCell().setPadding(1);
    int headerwidths[] = { 50, 50 }; // percentage
    datatable.setWidths(headerwidths);
    datatable.setWidthPercentage(70); // percentage
    datatable.setHorizontalAlignment(Element.ALIGN_CENTER);
    datatable.getDefaultCell().setBorderWidth(1);
    datatable.getDefaultCell().setHorizontalAlignment(Element.ALIGN_CENTER);

    PdfPCell c = null;
    String v = "";

    //encabezados de columnas
    c = new PdfPCell(new Phrase("ITEMS DEL MEN", tblHeaderFont));
    c.setGrayFill(0.95f);
    c.setColspan(2);
    c.setHorizontalAlignment(Element.ALIGN_CENTER);
    datatable.addCell(c);

    c = new PdfPCell(new Phrase("Item del men", tblHeaderFont));
    c.setGrayFill(0.95f);
    c.setHorizontalAlignment(Element.ALIGN_CENTER);
    datatable.addCell(c);

    c = new PdfPCell(new Phrase("Servicio", tblHeaderFont));
    c.setGrayFill(0.95f);
    c.setHorizontalAlignment(Element.ALIGN_CENTER);
    datatable.addCell(c);

    while (detail.next()) {
        v = detail.getString("description");
        c = new PdfPCell(new Phrase(v, tblBodyFont));
        c.setHorizontalAlignment(Element.ALIGN_LEFT);
        datatable.addCell(c);

        v = detail.getString("path");
        c = new PdfPCell(new Phrase(v, tblBodyFont));
        c.setHorizontalAlignment(Element.ALIGN_LEFT);
        datatable.addCell(c);
    }

    datatable.setSpacingBefore(20);
    return datatable;

}

From source file:domain.reports.role.PDFReportRole.java

License:LGPL

/**
 * Return a report section formatted as a table
 * @param data/*w w  w  .ja v a2s  .c o  m*/
 * @return
 */
PdfPTable getGroupDetail(Recordset master, Recordset detail) throws Throwable {

    //cols
    PdfPTable datatable = new PdfPTable(4);

    //header
    datatable.getDefaultCell().setPadding(1);
    int headerwidths[] = { 20, 20, 20, 20 }; // percentage
    datatable.setWidths(headerwidths);
    datatable.setWidthPercentage(100); // percentage
    datatable.setHorizontalAlignment(Element.ALIGN_CENTER);
    datatable.getDefaultCell().setBorderWidth(1);
    datatable.getDefaultCell().setHorizontalAlignment(Element.ALIGN_CENTER);

    PdfPCell c = null;
    String v = "";

    //encabezados de columnas
    c = new PdfPCell(new Phrase("USUARIOS DEL ROL", tblHeaderFont));
    c.setGrayFill(0.95f);
    c.setColspan(4);
    c.setHorizontalAlignment(Element.ALIGN_CENTER);
    datatable.addCell(c);

    c = new PdfPCell(new Phrase("Login de Usuario", tblHeaderFont));
    c.setGrayFill(0.95f);
    c.setHorizontalAlignment(Element.ALIGN_CENTER);
    datatable.addCell(c);

    c = new PdfPCell(new Phrase("Apellido", tblHeaderFont));
    c.setGrayFill(0.95f);
    c.setHorizontalAlignment(Element.ALIGN_CENTER);
    datatable.addCell(c);

    c = new PdfPCell(new Phrase("Nombre", tblHeaderFont));
    c.setGrayFill(0.95f);
    c.setHorizontalAlignment(Element.ALIGN_CENTER);
    datatable.addCell(c);

    c = new PdfPCell(new Phrase("Email", tblHeaderFont));
    c.setGrayFill(0.95f);
    c.setHorizontalAlignment(Element.ALIGN_CENTER);
    datatable.addCell(c);

    while (detail.next()) {
        v = detail.getString("userlogin");
        c = new PdfPCell(new Phrase(v, tblBodyFont));
        c.setHorizontalAlignment(Element.ALIGN_CENTER);
        datatable.addCell(c);

        v = detail.getString("lname");
        c = new PdfPCell(new Phrase(v, tblBodyFont));
        c.setHorizontalAlignment(Element.ALIGN_CENTER);
        datatable.addCell(c);

        v = detail.getString("fname");
        c = new PdfPCell(new Phrase(v, tblBodyFont));
        c.setHorizontalAlignment(Element.ALIGN_CENTER);
        datatable.addCell(c);

        v = detail.getString("email");
        c = new PdfPCell(new Phrase(v, tblBodyFont));
        c.setHorizontalAlignment(Element.ALIGN_CENTER);
        datatable.addCell(c);
    }

    datatable.setSpacingBefore(20);
    return datatable;

}

From source file:ec.edu.chyc.manejopersonal.managebean.PDFCustomExporter.java

License:Apache License

protected void tableColumnGroup(PdfPTable pdfTable, DataTable table, String facetType) {
    ColumnGroup cg = table.getColumnGroup(facetType);
    List<UIComponent> headerComponentList = null;
    if (cg != null) {
        headerComponentList = cg.getChildren();
    }/*from   w  ww.j ava2s . c om*/
    if (headerComponentList != null) {
        for (UIComponent component : headerComponentList) {
            if (component instanceof Row) {
                Row row = (Row) component;
                for (UIComponent rowComponent : row.getChildren()) {
                    UIColumn column = (UIColumn) rowComponent;
                    String value = null;
                    if (column.isRendered() && column.isExportable()) {
                        if (facetType.equalsIgnoreCase("header")) {
                            value = column.getHeaderText();
                        } else {
                            value = column.getFooterText();
                        }
                        int rowSpan = column.getRowspan();
                        int colSpan = column.getColspan();
                        PdfPCell cell = new PdfPCell(new Paragraph(value, this.facetFont));
                        if (facetBackground != null) {
                            cell.setBackgroundColor(facetBackground);
                        }
                        if (rowSpan > 1) {
                            cell.setVerticalAlignment(Element.ALIGN_CENTER);
                            cell.setRowspan(rowSpan);

                        }
                        if (colSpan > 1) {
                            cell.setHorizontalAlignment(Element.ALIGN_CENTER);
                            cell.setColspan(colSpan);

                        }
                        // addColumnAlignments(component,cell);
                        if (facetType.equalsIgnoreCase("header")) {
                            cell.setHorizontalAlignment(Element.ALIGN_CENTER);
                        }
                        pdfTable.addCell(cell);
                    }
                }
            }

        }
    }
    pdfTable.completeRow();

}

From source file:ec.edu.chyc.manejopersonal.managebean.PDFCustomExporter.java

License:Apache License

protected void tableColumnGroup(PdfPTable pdfTable, SubTable table, String facetType) {
    ColumnGroup cg = table.getColumnGroup(facetType);
    List<UIComponent> headerComponentList = null;
    if (cg != null) {
        headerComponentList = cg.getChildren();
    }//from  www  .  j a  v  a  2s  .c  om
    if (headerComponentList != null) {
        for (UIComponent component : headerComponentList) {
            if (component instanceof Row) {
                Row row = (Row) component;
                for (UIComponent rowComponent : row.getChildren()) {
                    UIColumn column = (UIColumn) rowComponent;
                    String value = null;
                    if (facetType.equalsIgnoreCase("header")) {
                        value = column.getHeaderText();
                    } else {
                        value = column.getFooterText();
                    }
                    int rowSpan = column.getRowspan();
                    int colSpan = column.getColspan();
                    PdfPCell cell = new PdfPCell(new Paragraph(value, this.facetFont));
                    if (facetBackground != null) {
                        cell.setBackgroundColor(facetBackground);
                    }
                    if (rowSpan > 1) {
                        cell.setVerticalAlignment(Element.ALIGN_CENTER);
                        cell.setRowspan(rowSpan);

                    }
                    if (colSpan > 1) {
                        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
                        cell.setColspan(colSpan);

                    }
                    // addColumnAlignments(component,cell);
                    if (facetType.equalsIgnoreCase("header")) {
                        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
                    }
                    pdfTable.addCell(cell);

                }
            }

        }
    }
    pdfTable.completeRow();

}

From source file:ec.edu.uce.erp.web.common.util.CustomPDFExporter.java

protected void addHeaderValue(PdfPTable pdfTable, UIComponent component, Font font) {

    String value = component == null ? "" : exportValue(FacesContext.getCurrentInstance(), component);
    PdfPCell cell = new PdfPCell(new Paragraph(value, font));
    cell.setHorizontalAlignment(Element.ALIGN_CENTER);
    pdfTable.addCell(cell);/*from  w  ww  .j  a  v  a  2 s .com*/

}

From source file:EplanPrinter.RTFWrite.java

License:Open Source License

public String openDoc(String name, String title) throws FileNotFoundException, DocumentException {
    document = new Document();
    RtfWriter2.getInstance(document, new FileOutputStream(name + ".rtf"));
    document.open();/*from   ww w  . j  a  v a  2s.co m*/
    Paragraph p = new Paragraph("Permit " + title);
    p.setAlignment(Element.ALIGN_CENTER);
    document.add(p);
    return "";
}