本文整理汇总了Java中com.lowagie.text.pdf.PdfPTable.setSpacingBefore方法的典型用法代码示例。如果您正苦于以下问题:Java PdfPTable.setSpacingBefore方法的具体用法?Java PdfPTable.setSpacingBefore怎么用?Java PdfPTable.setSpacingBefore使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.lowagie.text.pdf.PdfPTable
的用法示例。
在下文中一共展示了PdfPTable.setSpacingBefore方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onEndPage
import com.lowagie.text.pdf.PdfPTable; //导入方法依赖的package包/类
@Override
public void onEndPage(PdfWriter writer, Document document) {
try {
Rectangle page = document.getPageSize();
PdfPTable footer = new PdfPTable(1);
footer.setWidthPercentage(100);
footer.setSpacingBefore(20);
PdfPCell footerPageNocell = new PdfPCell(new Paragraph(fontFamilySelector.process(messageSource.getMessage("hrms.payroll.computer.generated.payslip.not.require.signature", null, this.locale), FontContext.REGULAR_NORMAL_TIMES_NEW_ROMAN)));
footerPageNocell.setBorder(0);
footerPageNocell.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
footer.addCell(footerPageNocell);
footer.setTotalWidth(page.getWidth() - document.leftMargin() - document.rightMargin());
footer.writeSelectedRows(0, -1, document.leftMargin(), document.bottomMargin()+2 , writer.getDirectContent());
} catch (Exception e) {
throw new ExceptionConverter(e);
}
}
示例2: onEndPage
import com.lowagie.text.pdf.PdfPTable; //导入方法依赖的package包/类
@Override
public void onEndPage(PdfWriter writer, Document document) {
try {
Rectangle page = document.getPageSize();
PdfPTable footer = new PdfPTable(1);
footer.setWidthPercentage(100);
footer.setSpacingBefore(20);
String FootPager = String.valueOf(document.getPageNumber());//current page no
PdfPCell footerPageNocell = new PdfPCell(new Phrase(FootPager, fontSmallBold));
footerPageNocell.setBorder(0);
footerPageNocell.setPaddingBottom(5);
footerPageNocell.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
footer.addCell(footerPageNocell);
footer.setTotalWidth(page.getWidth() - document.leftMargin() - document.rightMargin());
footer.writeSelectedRows(0, -1, document.leftMargin(), document.bottomMargin() - 5, writer.getDirectContent());
} catch (Exception e) {
throw new ExceptionConverter(e);
}
}
示例3: onEndPage
import com.lowagie.text.pdf.PdfPTable; //导入方法依赖的package包/类
@Override
public void onEndPage(PdfWriter writer, Document document) {
try {
Rectangle page = document.getPageSize();
PdfPTable footer = new PdfPTable(1);
footer.setWidthPercentage(100);
footer.setSpacingBefore(20);
PdfPCell footerPageNocell = new PdfPCell(new Paragraph(fontFamilySelector.process(messageSource.getMessage("hrms.payroll.computer.generated.payslip.not.require.signature", null, RequestContextUtils.getLocale(request)), FontContext.SMALL_NORMAL_TIMES_NEW_ROMAN)));
footerPageNocell.setBorder(0);
footerPageNocell.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
footer.addCell(footerPageNocell);
footer.setTotalWidth(page.getWidth() - document.leftMargin() - document.rightMargin());
footer.writeSelectedRows(0, -1, document.leftMargin(), document.bottomMargin()+2 , writer.getDirectContent());
} catch (Exception e) {
throw new ExceptionConverter(e);
}
}
示例4: onEndPage
import com.lowagie.text.pdf.PdfPTable; //导入方法依赖的package包/类
@Override
public void onEndPage(PdfWriter writer, Document document) {
try {
Rectangle page = document.getPageSize();
PdfPTable footer = new PdfPTable(1);
footer.setWidthPercentage(100);
footer.setSpacingBefore(20);
String FootPager = String.valueOf(document.getPageNumber());//current page no
PdfPCell footerPageNocell = new PdfPCell(new Phrase(fontFamilySelector.process(FootPager, FontContext.SMALL_BOLD_HELVETICA)));
footerPageNocell.setBorder(0);
footerPageNocell.setPaddingBottom(5);
footerPageNocell.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
footer.addCell(footerPageNocell);
footer.setTotalWidth(page.getWidth() - document.leftMargin() - document.rightMargin());
footer.writeSelectedRows(0, -1, document.leftMargin(), document.bottomMargin() - 5, writer.getDirectContent());
} catch (Exception e) {
throw new ExceptionConverter(e);
}
}
示例5: 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);
}
}
示例6: 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);
}
示例7: onEndPage
import com.lowagie.text.pdf.PdfPTable; //导入方法依赖的package包/类
@Override
public void onEndPage(PdfWriter writer, Document document) {
try {
Rectangle page = document.getPageSize();
PdfPTable footer = new PdfPTable(1);
footer.setWidthPercentage(100);
footer.setSpacingBefore(20);
PdfPCell footerPageNocell = new PdfPCell(new Paragraph(messageSource.getMessage("hrms.payroll.computer.generated.payslip.not.require.signature", null, RequestContextUtils.getLocale(request)), fontMediumRegular));
footerPageNocell.setBorder(0);
footerPageNocell.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
footer.addCell(footerPageNocell);
footer.setTotalWidth(page.getWidth() - document.leftMargin() - document.rightMargin());
footer.writeSelectedRows(0, -1, document.leftMargin(), document.bottomMargin()+2 , writer.getDirectContent());
} catch (Exception e) {
throw new ExceptionConverter(e);
}
}
示例8: 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);
}
示例9: 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;
}
示例10: 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();
}
示例11: 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.setTableEvent(new BorderEvent(this));
pdfptable.setHeaderRows(lastHeaderRow + 1);
pdfptable.setSplitLate(cellsFitPage);
if (!Float.isNaN(offset)) {
pdfptable.setSpacingBefore(offset);
}
pdfptable.setHorizontalAlignment(alignment);
if (absWidth.length() > 0) {
try {
pdfptable.setTotalWidth(Float.parseFloat(absWidth));
}
catch(Exception e1) {
try {
pdfptable.setTotalWidth((float)Integer.parseInt(absWidth));
}
catch(Exception e2) {
pdfptable.setWidthPercentage(widthPercentage);
}
}
}
else {
pdfptable.setWidthPercentage(widthPercentage);
}
Row row;
for (Iterator iterator = iterator(); iterator.hasNext(); ) {
row = (Row) iterator.next();
Element cell;
PdfPCell pcell;
for (int i = 0; i < row.columns(); 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);
}
else {
pcell = new PdfPCell();
}
pdfptable.addCell(pcell);
}
}
}
return pdfptable;
}
示例12: 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);
}
}