use of com.itextpdf.text.pdf.PdfPTable in project pancm_project by xuwujing.
the class PdfHelper method createTable.
/**
* 创建指定列宽、列数的表格
* @param widths
* @return
*/
public static PdfPTable createTable(float[] widths) {
PdfPTable table = new PdfPTable(widths);
try {
table.setTotalWidth(maxWidth);
table.setLockedWidth(true);
table.setHorizontalAlignment(Element.ALIGN_CENTER);
table.getDefaultCell().setBorder(1);
} catch (Exception e) {
e.printStackTrace();
}
return table;
}
use of com.itextpdf.text.pdf.PdfPTable in project pancm_project by xuwujing.
the class PdfHelper method createTable.
/**
*------------------------创建表格单元格的方法end----------------------------
*/
/**
*--------------------------创建表格的方法start------------------- ---------
*/
/**
* 创建默认列宽,指定列数、水平(居中、右、左)的表格
* @param colNumber
* @param align
* @return
*/
public static PdfPTable createTable(int colNumber, int align) {
PdfPTable table = new PdfPTable(colNumber);
try {
table.setTotalWidth(maxWidth);
table.setLockedWidth(true);
table.setHorizontalAlignment(align);
table.getDefaultCell().setBorder(1);
} catch (Exception e) {
e.printStackTrace();
}
return table;
}
use of com.itextpdf.text.pdf.PdfPTable in project pancm_project by xuwujing.
the class PdfHelper method createBlankTable.
/**
* 创建空白的表格
* @return
*/
public static PdfPTable createBlankTable() {
PdfPTable table = new PdfPTable(1);
table.getDefaultCell().setBorder(1);
table.addCell(createCell("", KEY_FONT));
table.setSpacingAfter(0.0f);
table.setSpacingBefore(0.0f);
return table;
}
use of com.itextpdf.text.pdf.PdfPTable in project MtgDesktopCompanion by nicho92.
the class PDFExport method export.
@Override
public void export(MagicDeck deck, File f) throws IOException {
PdfPTable table = new PdfPTable(3);
table.setHorizontalAlignment(Element.ALIGN_CENTER);
try {
document = new Document(PageSize.A4, 5, 5, 10, 5);
document.addAuthor(getString("AUTHOR"));
document.addCreationDate();
document.addCreator("Magic Desktop Companion");
document.addTitle(deck.getName());
PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream(f));
document.open();
int i = 0;
for (MagicCard card : deck.getAsList()) {
table.addCell(getCells(card));
setChanged();
notifyObservers(i++);
}
document.add(table);
document.close();
writer.close();
} catch (Exception e) {
logger.error("Error in pdf creation " + f, e);
}
}
Aggregations