Java Code Examples for com.lowagie.text.pdf.PdfPTable#setKeepTogether()

The following examples show how to use com.lowagie.text.pdf.PdfPTable#setKeepTogether() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: GridUtils.java    From dhis2-core with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
private static void toPdfInternal( Grid grid, Document document, float spacing )
{
    if ( grid == null || grid.getVisibleWidth() == 0 )
    {
        return;
    }

    PdfPTable table = new PdfPTable( grid.getVisibleWidth() );

    table.setHeaderRows( 1 );
    table.setWidthPercentage( 100F );
    table.setKeepTogether( false );
    table.setSpacingAfter( spacing );

    table.addCell( resetPaddings( getTitleCell( grid.getTitle(), grid.getVisibleWidth() ), 0, 30, 0, 0 ) );

    if ( StringUtils.isNotEmpty( grid.getSubtitle() ) )
    {
        table.addCell( getSubtitleCell( grid.getSubtitle(), grid.getVisibleWidth() ) );
        table.addCell( getEmptyCell( grid.getVisibleWidth(), 30 ) );
    }

    for ( GridHeader header : grid.getVisibleHeaders() )
    {
        table.addCell( getItalicCell( header.getColumn() ) );
    }

    table.addCell( getEmptyCell( grid.getVisibleWidth(), 10 ) );

    for ( List<Object> row : grid.getVisibleRows() )
    {
        for ( Object col : row )
        {
            table.addCell( getTextCell( col ) );
        }
    }

    addTableToDocument( document, table );
}
 
Example 2
Source File: PdfTimetableGridTable.java    From unitime with Apache License 2.0 5 votes vote down vote up
private void createTable() {
	iPdfTable = new PdfPTable(getNrColumns());
	iPdfTable.setWidthPercentage(100);
	iPdfTable.getDefaultCell().setPadding(3);
	iPdfTable.getDefaultCell().setBorderWidth(1);
	iPdfTable.setSplitRows(false);
	iPdfTable.setSpacingBefore(10);
	if (iTable.isDispModePerWeek()) {
		iPdfTable.setKeepTogether(true);
	}
}
 
Example 3
Source File: PdfExamGridTable.java    From unitime with Apache License 2.0 5 votes vote down vote up
private void createTable(boolean keepTogether) {
    iPdfTable = new PdfPTable(getNrColumns());
    iPdfTable.setWidthPercentage(100);
    iPdfTable.getDefaultCell().setPadding(3);
    iPdfTable.getDefaultCell().setBorderWidth(1);
    iPdfTable.setSplitRows(false);
    iPdfTable.setSpacingBefore(10);
    iPdfTable.setKeepTogether(keepTogether);
}
 
Example 4
Source File: PDFUtils.java    From dhis2-core with BSD 3-Clause "New" or "Revised" License 3 votes vote down vote up
/**
 * <p>
 * Creates a table. Specify the columns and widths by providing one<br>
 * float per column with a percentage value. For instance
 * </p>
 * <p>
 * <p>
 * getPdfPTable( 0.35f, 0.65f )
 * </p>
 * <p>
 * <p>
 * will give you a table with two columns where the first covers 35 %<br>
 * of the page while the second covers 65 %.
 * </p>
 *
 * @param keepTogether Indicates whether the table could be broken across
 *                     multiple pages or should be kept at one page.
 * @param columnWidths The column widths.
 * @return
 */
public static PdfPTable getPdfPTable( boolean keepTogether, float... columnWidths )
{
    PdfPTable table = new PdfPTable( columnWidths );

    table.setWidthPercentage( 100f );
    table.setKeepTogether( keepTogether );

    return table;
}