本文整理汇总了Java中com.lowagie.text.pdf.PdfPTable.setSpacingAfter方法的典型用法代码示例。如果您正苦于以下问题:Java PdfPTable.setSpacingAfter方法的具体用法?Java PdfPTable.setSpacingAfter怎么用?Java PdfPTable.setSpacingAfter使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.lowagie.text.pdf.PdfPTable
的用法示例。
在下文中一共展示了PdfPTable.setSpacingAfter方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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 );
}
示例2: 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 );
}
示例3: addTitleSubtitle
import com.lowagie.text.pdf.PdfPTable; //导入方法依赖的package包/类
private static void addTitleSubtitle(Document d) throws DocumentException, JSONException {
java.awt.Color tColor = new Color(Integer.parseInt(config.getString("textColor"), 16));
fontBold.setColor(tColor);
fontRegular.setColor(tColor);
PdfPTable table = new PdfPTable(1);
table.setHorizontalAlignment(Element.ALIGN_CENTER);
table.setWidthPercentage(100);
table.setSpacingBefore(6);
//Report Title
PdfPCell cell = new PdfPCell(new Paragraph(config.getString("title"), fontBold));
cell.setBorder(0);
cell.setBorderWidth(0);
cell.setHorizontalAlignment(Element.ALIGN_CENTER);
table.addCell(cell);
//Report Subtitle(s)
String[] SubTitles = config.getString("subtitles").split("~");// '~' as separator
for(int i=0; i < SubTitles.length; i++){
cell = new PdfPCell(new Paragraph(SubTitles[i], fontSmallRegular));
cell.setBorder(0);
cell.setBorderWidth(0);
cell.setHorizontalAlignment(Element.ALIGN_CENTER);
table.addCell(cell);
}
table.setSpacingAfter(6);
d.add(table);
//Separator line
PdfPTable line = new PdfPTable(1);
line.setWidthPercentage(100);
PdfPCell cell1 = null;
cell1 = new PdfPCell(new Paragraph(""));
cell1.setBorder(PdfPCell.BOTTOM);
line.addCell(cell1);
d.add(line);
}
示例4: main
import com.lowagie.text.pdf.PdfPTable; //导入方法依赖的package包/类
/**
* Defining the spacing between the table and other content.
*
* @param args
* no arguments needed
*/
public static void main(String[] args) {
System.out.println("TableSpacing");
// step1
Document document = new Document(PageSize.A4);
try {
// step2
PdfWriter.getInstance(document, new FileOutputStream(android.os.Environment.getExternalStorageDirectory() + java.io.File.separator + "droidtext" + java.io.File.separator + "TableSpacing.pdf"));
// step3
document.open();
// step4
PdfPTable table = new PdfPTable(3);
PdfPCell cell = new PdfPCell(new Paragraph("header with colspan 3"));
cell.setColspan(3);
table.addCell(cell);
table.addCell("1.1");
table.addCell("2.1");
table.addCell("3.1");
table.addCell("1.2");
table.addCell("2.2");
table.addCell("3.2");
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);
table.setWidthPercentage(50);
document.add(new Paragraph("We add 2 tables:"));
document.add(table);
document.add(table);
document.add(new Paragraph("They are glued to eachother"));
document.add(table);
document.add(new Paragraph("This is not very nice. Turn to the next page to see how we solved this"));
document.newPage();
document.add(new Paragraph("We add 2 tables, but with a certain 'SpacingBefore':"));
table.setSpacingBefore(15f);
document.add(table);
document.add(table);
document.add(new Paragraph("Unfortunately, there was no spacing after."));
table.setSpacingAfter(15f);
document.add(table);
document.add(new Paragraph("This is much better, don't you think so?"));
} catch (Exception de) {
de.printStackTrace();
}
// step5
document.close();
}
示例5: addTitleSubtitle
import com.lowagie.text.pdf.PdfPTable; //导入方法依赖的package包/类
public void addTitleSubtitle(Document d) throws ServiceException {
try {
java.awt.Color tColor = new Color(Integer.parseInt(config.getString("textColor"), 16));
/*fontBold.setColor(tColor);
fontRegular.setColor(tColor);
fontSmallRegular.setColor(tColor);*/
PdfPTable table = new PdfPTable(1);
table.setHorizontalAlignment(Element.ALIGN_CENTER);
table.setWidthPercentage(100);
table.setSpacingBefore(6);
//Report Title
PdfPCell cell = new PdfPCell(new Paragraph(fontFamilySelector.process(config.getString("title"), FontContext.REGULAR_BOLD_HELVETICA, tColor)));
cell.setBorder(0);
cell.setBorderWidth(0);
cell.setHorizontalAlignment(Element.ALIGN_CENTER);
table.addCell(cell);
//Report Subtitle(s)
String[] SubTitles = config.getString("subtitles").split("~");// '~' as separator
for (int i = 0; i < SubTitles.length; i++) {
cell = new PdfPCell(new Paragraph(fontFamilySelector.process(SubTitles[i], FontContext.SMALL_NORMAL_HELVETICA, tColor)));
cell.setBorder(0);
cell.setBorderWidth(0);
cell.setHorizontalAlignment(Element.ALIGN_CENTER);
table.addCell(cell);
}
table.setSpacingAfter(6);
d.add(table);
//Separator line
PdfPTable line = new PdfPTable(1);
line.setWidthPercentage(100);
PdfPCell cell1 = null;
cell1 = new PdfPCell(new Paragraph(""));
cell1.setBorder(PdfPCell.BOTTOM);
line.addCell(cell1);
d.add(line);
} catch (Exception e) {
throw ServiceException.FAILURE("exportDAOImpl.addTitleSubtitle", e);
}
}