Example usage for com.lowagie.text.pdf PdfPCell setColumn

List of usage examples for com.lowagie.text.pdf PdfPCell setColumn

Introduction

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

Prototype

public void setColumn(ColumnText column) 

Source Link

Document

Sets the columntext in the cell.

Usage

From source file:fr.opensagres.odfdom.converter.pdf.internal.stylable.StylableDocument.java

License:Open Source License

private void setColIdx(int idx) {
    colIdx = idx;//from   w w w.j  a v  a  2s .co m
    PdfPCell cell = StylableDocumentSection.getCell(layoutTable, colIdx);
    text.setSimpleColumn(cell.getLeft() + cell.getPaddingLeft(), -getAdjustedPageHeight(),
            cell.getRight() - cell.getPaddingRight(), 0.0f);
    cell.setColumn(ColumnText.duplicate(text));
}

From source file:fr.opensagres.odfdom.converter.pdf.internal.stylable.StylableDocumentSection.java

License:Open Source License

private List<ColumnText> fillTable(float height) {
    // copy text for simulation
    List<ColumnText> tt = null;
    if (breakHandlingParent == null && colIdx >= layoutTable.getNumberOfColumns()) {
        // more column breaks than available column
        // we try not to lose content
        // but results may be different than in open office
        // anyway it is logical error made by document creator
        tt = new ArrayList<ColumnText>();
        ColumnText t = createColumnText();
        tt.add(t);/*from  www.j  a v a  2 s  .  co m*/
        for (int i = 0; i < texts.size(); i++) {
            PdfPTable table = new PdfPTable(1);
            table.setWidthPercentage(100.0f);
            PdfPCell cell = new PdfPCell();
            cell.setBorder(Table.NO_BORDER);
            cell.setPadding(0.0f);
            cell.setColumn(ColumnText.duplicate(texts.get(i)));
            table.addCell(cell);
            t.addElement(table);
        }
    } else {
        tt = new ArrayList<ColumnText>(texts);
        for (int i = 0; i < tt.size(); i++) {
            tt.set(i, ColumnText.duplicate(tt.get(i)));
        }
    }
    // clear layout table
    clearTable(layoutTable, true);
    setWidthIfNecessary();

    // try to fill cells with text
    ColumnText t = tt.get(0);
    for (PdfPCell cell : layoutTable.getRow(0).getCells()) {
        cell.setFixedHeight(height >= 0.0f ? height : -1.0f);
        cell.setColumn(ColumnText.duplicate(t));
        //
        t.setSimpleColumn(cell.getLeft() + cell.getPaddingLeft(),
                height >= 0.0f ? -height : PdfPRow.BOTTOM_LIMIT, cell.getRight() - cell.getPaddingRight(), 0);
        int res = 0;
        try {
            res = t.go(true);
        } catch (DocumentException e) {
            throw new ODFConverterException(e);
        }
        if (!ColumnText.hasMoreText(res)) {
            // no overflow in current column
            if (tt.size() == 1) {
                // no more text
                return null;
            } else {
                // some text waiting for new column
                tt.remove(0);
                t = tt.get(0);
            }
        }
    }
    return tt;
}

From source file:fr.opensagres.odfdom.converter.pdf.internal.stylable.StylableDocumentSection.java

License:Open Source License

public static SectionPdfPTable createLayoutTable(float width, float height,
        List<StyleColumnProperties> columnPropertiesList) {
    // create one row table which will layout section text
    int colCount = columnPropertiesList.size();
    int relativeWidths[] = new int[colCount];
    SectionPdfPTable table = new SectionPdfPTable(colCount);
    // add cells//from w w w .  j  a  va2s  . com
    for (int i = 0; i < colCount; i++) {
        PdfPCell cell = new PdfPCell();
        cell.setBorder(Table.NO_BORDER);
        cell.setPadding(0.0f);
        cell.setColumn(createColumnText());
        cell.setFixedHeight(height >= 0.0f ? height : -1.0f);
        // apply styles to cell
        StyleColumnProperties columnProperties = columnPropertiesList.get(i);
        relativeWidths[i] = columnProperties.getRelWidth();
        cell.setPaddingLeft(
                columnProperties.getStartIndent() != null ? columnProperties.getStartIndent() : 0.0f);
        cell.setPaddingRight(columnProperties.getEndIndent() != null ? columnProperties.getEndIndent() : 0.0f);
        table.addCell(cell);
    }
    replaceTableCells(table);
    // set width
    try {
        table.setWidths(relativeWidths);
    } catch (DocumentException e) {
        throw new ODFConverterException(e);
    }
    table.setTotalWidth(width);
    table.setLockedWidth(true);
    return table;
}

From source file:fr.opensagres.odfdom.converter.pdf.internal.stylable.StylableDocumentSection.java

License:Open Source License

public static void clearTable(PdfPTable table, boolean resetFixedHeight) {
    for (PdfPCell cell : table.getRow(0).getCells()) {
        cell.setColumn(createColumnText());
        if (resetFixedHeight) {
            cell.setFixedHeight(-1.0f);/*  w  w  w  .j  a  v  a2 s.  c o  m*/
        }
    }
}

From source file:fr.opensagres.poi.xwpf.converter.pdf.internal.elements.StylableDocumentSection.java

License:Open Source License

private List<ColumnText> fillTable(float height) {
    // copy text for simulation
    List<ColumnText> tt = null;
    if (breakHandlingParent == null && colIdx >= layoutTable.getNumberOfColumns()) {
        // more column breaks than available column
        // we try not to lose content
        // but results may be different than in open office
        // anyway it is logical error made by document creator
        tt = new ArrayList<ColumnText>();
        ColumnText t = createColumnText();
        tt.add(t);// w  ww .jav  a 2 s .  co  m
        for (int i = 0; i < texts.size(); i++) {
            PdfPTable table = new PdfPTable(1);
            table.setWidthPercentage(100.0f);
            PdfPCell cell = new PdfPCell();
            cell.setBorder(Table.NO_BORDER);
            cell.setPadding(0.0f);
            cell.setColumn(ColumnText.duplicate(texts.get(i)));
            table.addCell(cell);
            t.addElement(table);
        }
    } else {
        tt = new ArrayList<ColumnText>(texts);
        for (int i = 0; i < tt.size(); i++) {
            tt.set(i, ColumnText.duplicate(tt.get(i)));
        }
    }
    // clear layout table
    clearTable(layoutTable, true);
    setWidthIfNecessary();

    // try to fill cells with text
    ColumnText t = tt.get(0);
    for (PdfPCell cell : layoutTable.getRow(0).getCells()) {
        cell.setFixedHeight(height >= 0.0f ? height : -1.0f);
        cell.setColumn(ColumnText.duplicate(t));
        //
        t.setSimpleColumn(cell.getLeft() + cell.getPaddingLeft(),
                height >= 0.0f ? -height : PdfPRow.BOTTOM_LIMIT, cell.getRight() - cell.getPaddingRight(), 0);
        int res = 0;
        try {
            res = t.go(true);
        } catch (DocumentException e) {
            throw new XWPFConverterException(e);
        }
        if (!ColumnText.hasMoreText(res)) {
            // no overflow in current column
            if (tt.size() == 1) {
                // no more text
                return null;
            } else {
                // some text waiting for new column
                tt.remove(0);
                t = tt.get(0);
            }
        }
    }
    return tt;
}

From source file:fr.opensagres.poi.xwpf.converter.pdf.internal.elements.StylableDocumentSection.java

License:Open Source License

public static SectionPdfPTable createLayoutTable(float width, float height,
        List<StyleColumnProperties> columnPropertiesList) {
    // create one row table which will layout section text
    int colCount = columnPropertiesList.size();
    int relativeWidths[] = new int[colCount];
    SectionPdfPTable table = new SectionPdfPTable(colCount);
    // add cells//from   www . j  av  a 2s .  c  om
    for (int i = 0; i < colCount; i++) {
        PdfPCell cell = new PdfPCell();
        cell.setBorder(Table.NO_BORDER);
        cell.setPadding(0.0f);
        cell.setColumn(createColumnText());
        cell.setFixedHeight(height >= 0.0f ? height : -1.0f);
        // apply styles to cell
        StyleColumnProperties columnProperties = columnPropertiesList.get(i);
        relativeWidths[i] = columnProperties.getRelWidth();
        cell.setPaddingLeft(
                columnProperties.getStartIndent() != null ? columnProperties.getStartIndent() : 0.0f);
        cell.setPaddingRight(columnProperties.getEndIndent() != null ? columnProperties.getEndIndent() : 0.0f);
        table.addCell(cell);
    }
    replaceTableCells(table);
    // set width
    try {
        table.setWidths(relativeWidths);
    } catch (DocumentException e) {
        throw new XWPFConverterException(e);
    }
    table.setTotalWidth(width);
    table.setLockedWidth(true);
    return table;
}