本文整理汇总了Java中com.lowagie.text.pdf.PdfPTable.setKeepTogether方法的典型用法代码示例。如果您正苦于以下问题:Java PdfPTable.setKeepTogether方法的具体用法?Java PdfPTable.setKeepTogether怎么用?Java PdfPTable.setKeepTogether使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.lowagie.text.pdf.PdfPTable
的用法示例。
在下文中一共展示了PdfPTable.setKeepTogether方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createTable
import com.lowagie.text.pdf.PdfPTable; //导入方法依赖的package包/类
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);
}
}
示例2: createTable
import com.lowagie.text.pdf.PdfPTable; //导入方法依赖的package包/类
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);
}
示例3: toPdfInternal
import com.lowagie.text.pdf.PdfPTable; //导入方法依赖的package包/类
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.getName() ) );
}
table.addCell( getEmptyCell( grid.getVisibleWidth(), 10 ) );
for ( List<Object> row : grid.getVisibleRows() )
{
for ( Object col : row )
{
table.addCell( getTextCell( col ) );
}
}
addTableToDocument( document, table );
}
示例4: toPdfInternal
import com.lowagie.text.pdf.PdfPTable; //导入方法依赖的package包/类
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.getName() ) );
}
table.addCell( getEmptyCell( grid.getVisibleWidth(), 10 ) );
for ( List<Object> row : grid.getVisibleRows() )
{
for ( Object col : row )
{
table.addCell( getTextCell( col ) );
}
}
addTableToDocument( document, table );
}
示例5: parseForm
import com.lowagie.text.pdf.PdfPTable; //导入方法依赖的package包/类
protected static String parseForm(WikiPDFContext context, Connection db, BufferedReader in, String line, Document document, PdfPCell cell) throws Exception {
if (line == null) {
return line;
}
CustomForm form = WikiToHTMLUtils.retrieveForm(in, line);
LOG.debug("parseForm");
for (CustomFormGroup group : form) {
LOG.debug(" group...");
// Start the table
PdfPTable pdfTable = new PdfPTable(2);
pdfTable.setHorizontalAlignment(Element.ALIGN_LEFT);
pdfTable.setSpacingBefore(10);
// pdfTable.setWidthPercentage(100);
pdfTable.setKeepTogether(true);
if (group.getDisplay() && StringUtils.hasText(group.getName())) {
// output the 1st row with a colspan of 2
if (StringUtils.hasText(group.getName())) {
Paragraph groupParagraph = new Paragraph(group.getName());
PdfPCell groupCell = new PdfPCell(groupParagraph);
groupCell.setHorizontalAlignment(Element.ALIGN_CENTER);
groupCell.setColspan(2);
groupCell.setPadding(20);
groupCell.setBorderColor(new Color(100, 100, 100));
groupCell.setBackgroundColor(new Color(200, 200, 200));
groupCell.setNoWrap(true);
pdfTable.addCell(groupCell);
}
}
for (CustomFormField field : group) {
LOG.debug(" field...");
if (field.hasValue()) {
// output the row (2 columns: label, value)
Paragraph fieldLabelParagraph = new Paragraph(field.getLabel());
PdfPCell fieldLabelCell = new PdfPCell(fieldLabelParagraph);
fieldLabelCell.setPadding(20);
fieldLabelCell.setBorderColor(new Color(100, 100, 100));
// fieldLabelCell.setNoWrap(true);
pdfTable.addCell(fieldLabelCell);
Paragraph fieldValueParagraph = new Paragraph(getFieldValue(context, field));
PdfPCell fieldValueCell = new PdfPCell(fieldValueParagraph);
fieldValueCell.setPadding(20);
fieldValueCell.setBorderColor(new Color(100, 100, 100));
// fieldValueCell.setNoWrap(true);
pdfTable.addCell(fieldValueCell);
}
}
LOG.debug("document.add(pdfTable)");
document.add(pdfTable);
}
return null;
}
示例6: createPdfPTable
import com.lowagie.text.pdf.PdfPTable; //导入方法依赖的package包/类
/**
* Create a PdfPTable based on this Table object.
* @return a PdfPTable object
* @throws BadElementException
*/
public PdfPTable createPdfPTable() throws BadElementException {
if (!convert2pdfptable) {
throw new BadElementException("No error, just an old style table");
}
setAutoFillEmptyCells(true);
complete();
PdfPTable pdfptable = new PdfPTable(widths);
pdfptable.setComplete(complete);
if (isNotAddedYet())
pdfptable.setSkipFirstHeader(true);
SimpleTable t_evt = new SimpleTable();
t_evt.cloneNonPositionParameters(this);
t_evt.setCellspacing(cellspacing);
pdfptable.setTableEvent(t_evt);
pdfptable.setHeaderRows(lastHeaderRow + 1);
pdfptable.setSplitLate(cellsFitPage);
pdfptable.setKeepTogether(tableFitsPage);
if (!Float.isNaN(offset)) {
pdfptable.setSpacingBefore(offset);
}
pdfptable.setHorizontalAlignment(alignment);
if (locked) {
pdfptable.setTotalWidth(width);
pdfptable.setLockedWidth(true);
}
else {
pdfptable.setWidthPercentage(width);
}
Row row;
for (Iterator iterator = iterator(); iterator.hasNext(); ) {
row = (Row) iterator.next();
Element cell;
PdfPCell pcell;
for (int i = 0; i < row.getColumns(); i++) {
if ((cell = (Element)row.getCell(i)) != null) {
if (cell instanceof Table) {
pcell = new PdfPCell(((Table)cell).createPdfPTable());
}
else if (cell instanceof Cell) {
pcell = ((Cell)cell).createPdfPCell();
pcell.setPadding(cellpadding + cellspacing / 2f);
SimpleCell c_evt = new SimpleCell(SimpleCell.CELL);
c_evt.cloneNonPositionParameters((Cell)cell);
c_evt.setSpacing(cellspacing * 2f);
pcell.setCellEvent(c_evt);
}
else {
pcell = new PdfPCell();
}
pdfptable.addCell(pcell);
}
}
}
return pdfptable;
}
示例7: getPdfPTable
import com.lowagie.text.pdf.PdfPTable; //导入方法依赖的package包/类
/**
* <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;
}