Example usage for com.lowagie.text.pdf PdfPTable getWidthPercentage

List of usage examples for com.lowagie.text.pdf PdfPTable getWidthPercentage

Introduction

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

Prototype

public float getWidthPercentage() 

Source Link

Document

Gets the width percentage that the table will occupy in the page.

Usage

From source file:com.jk.framework.desktop.swing.dao.TableModelPdfBuilder.java

License:Apache License

/**
 * Creates the pdf footer.//www  .  j  a  v  a  2s . com
 *
 * @param pdfPTable
 *            the pdf P table
 * @param font
 *            the font
 * @throws DocumentException
 *             the document exception
 * @throws IOException
 *             Signals that an I/O exception has occurred.
 */
public void createPdfFooter(final PdfPTable pdfPTable, Font font) throws DocumentException, IOException {
    final float width = pdfPTable.getWidthPercentage();
    final int headerWidth = (int) width;
    font = getFont();
    final PdfPCell footerCell = new PdfPCell(new Phrase(getFooter(), font));
    footerCell.setHorizontalAlignment(Element.ALIGN_CENTER);
    footerCell.setVerticalAlignment(Element.ALIGN_MIDDLE);
    footerCell.setColspan(headerWidth);
    footerCell.setBorder(0);
    footerCell.setUseDescender(true);
    pdfPTable.addCell(footerCell);
    pdfPTable.setFooterRows(1);
}

From source file:com.jk.framework.desktop.swing.dao.TableModelPdfBuilder.java

License:Apache License

/**
 * Creates the pdf headers.//from w ww.  java2 s . c om
 *
 * @param pdfPTable
 *            the pdf P table
 * @param font
 *            the font
 * @throws DocumentException
 *             the document exception
 * @throws IOException
 *             Signals that an I/O exception has occurred.
 */
public void createPdfHeaders(final PdfPTable pdfPTable, Font font) throws DocumentException, IOException {
    font = getFont();
    final float width = pdfPTable.getWidthPercentage();
    final int headerWidth = (int) width;
    final PdfPCell headersCells = new PdfPCell(new Phrase(getHeader(), font));
    headersCells.setHorizontalAlignment(Element.ALIGN_CENTER);
    headersCells.setColspan(headerWidth);
    headersCells.setUseDescender(true);
    headersCells.setBorder(0);
    pdfPTable.addCell(headersCells);
    for (int i = 0; i < this.model.getColumnCount(); i++) {
        if (this.model.isVisible(i)) {
            final PdfPCell cell = new PdfPCell(new Phrase(Lables.get(this.model.getActualColumnName(i)), font));
            cell.setRotation(getRotationDegree());
            cell.setHorizontalAlignment(Element.ALIGN_CENTER);
            pdfPTable.addCell(cell);
        }
    }
    // Please explain
    pdfPTable.setHeaderRows(3);
    createPdfFooter(pdfPTable, font);

}

From source file:org.pentaho.reporting.engine.classic.core.modules.output.table.rtf.itext.PatchRtfTable.java

License:Open Source License

/**
 * Imports the rows and settings from the Table into this PatchRtfTable.
 *
 * @param table//from   www. j  a  v a  2 s  . c o  m
 *          The source PdfPTable
 * @since 2.1.3
 */
private void importTable(PdfPTable table) {
    this.rows = new ArrayList<PatchRtfRow>();
    this.tableWidthPercent = table.getWidthPercentage();
    // this.tableWidthPercent = table.getWidth();
    this.proportionalWidths = table.getAbsoluteWidths();
    // this.proportionalWidths = table.getProportionalWidths();
    this.cellPadding = (float) (table.spacingAfter() * TWIPS_FACTOR);
    // this.cellPadding = (float) (table.getPadding() * TWIPS_FACTOR);
    this.cellSpacing = (float) (table.spacingAfter() * TWIPS_FACTOR);
    // this.cellSpacing = (float) (table.getSpacing() * TWIPS_FACTOR);
    // this.borders = new PatchRtfBorderGroup(this.document, PatchRtfBorder.ROW_BORDER, table.getBorder(),
    // table.getBorderWidth(), table.getBorderColor());
    // this.borders = new PatchRtfBorderGroup(this.document, PatchRtfBorder.ROW_BORDER, table.getBorder(),
    // table.getBorderWidth(), table.getBorderColor());
    this.alignment = table.getHorizontalAlignment();
    // this.alignment = table.getAlignment();

    int i = 0;
    Iterator rowIterator = table.getRows().iterator();
    // Iterator rowIterator = table.iterator();
    while (rowIterator.hasNext()) {
        this.rows.add(new PatchRtfRow(this.document, this, (PdfPRow) rowIterator.next(), i));
        i++;
    }
    for (i = 0; i < this.rows.size(); i++) {
        this.rows.get(i).handleCellSpanning();
        this.rows.get(i).cleanRow();
    }

    this.headerRows = table.getHeaderRows();
    // this.headerRows = table.getLastHeaderRow();
    this.cellsFitToPage = table.getKeepTogether();
    // this.cellsFitToPage = table.isCellsFitPage();
    this.tableFitToPage = table.getKeepTogether();
    // this.tableFitToPage = table.isTableFitsPage();
    // if(!Float.isNaN(table.getOffset())) {
    // this.offset = (int) (table.getOffset() * 2);
    // }
    // if(!Float.isNaN(table.getOffset())) {
    // this.offset = (int) (table.getOffset() * 2);
    // }
}