Search in sources :

Example 41 with PdfPTable

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;
}
Also used : PdfPTable(com.itextpdf.text.pdf.PdfPTable)

Example 42 with PdfPTable

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;
}
Also used : PdfPTable(com.itextpdf.text.pdf.PdfPTable)

Example 43 with PdfPTable

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;
}
Also used : PdfPTable(com.itextpdf.text.pdf.PdfPTable)

Example 44 with PdfPTable

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);
    }
}
Also used : PdfPTable(com.itextpdf.text.pdf.PdfPTable) PdfWriter(com.itextpdf.text.pdf.PdfWriter) MagicCard(org.magic.api.beans.MagicCard) FileOutputStream(java.io.FileOutputStream) Document(com.itextpdf.text.Document) NotImplementedException(org.apache.commons.lang3.NotImplementedException) BadElementException(com.itextpdf.text.BadElementException) IOException(java.io.IOException)

Aggregations

PdfPTable (com.itextpdf.text.pdf.PdfPTable)44 PdfPCell (com.itextpdf.text.pdf.PdfPCell)24 Paragraph (com.itextpdf.text.Paragraph)18 Phrase (com.itextpdf.text.Phrase)17 DocumentException (com.itextpdf.text.DocumentException)12 Font (com.itextpdf.text.Font)8 IOException (java.io.IOException)8 ExceptionConverter (com.itextpdf.text.ExceptionConverter)6 Document (com.itextpdf.text.Document)5 BadElementException (com.itextpdf.text.BadElementException)4 BaseFont (com.itextpdf.text.pdf.BaseFont)4 PdfContentByte (com.itextpdf.text.pdf.PdfContentByte)4 PdfWriter (com.itextpdf.text.pdf.PdfWriter)4 FileOutputStream (java.io.FileOutputStream)4 BaseColor (com.itextpdf.text.BaseColor)3 Chapter (com.itextpdf.text.Chapter)3 Chunk (com.itextpdf.text.Chunk)3 Image (com.itextpdf.text.Image)3 ListItem (com.itextpdf.text.ListItem)3 PdfReader (com.itextpdf.text.pdf.PdfReader)3