當前位置: 首頁>>代碼示例>>Java>>正文


Java PdfPTable.setWidths方法代碼示例

本文整理匯總了Java中com.itextpdf.text.pdf.PdfPTable.setWidths方法的典型用法代碼示例。如果您正苦於以下問題:Java PdfPTable.setWidths方法的具體用法?Java PdfPTable.setWidths怎麽用?Java PdfPTable.setWidths使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在com.itextpdf.text.pdf.PdfPTable的用法示例。


在下文中一共展示了PdfPTable.setWidths方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: generatePage

import com.itextpdf.text.pdf.PdfPTable; //導入方法依賴的package包/類
@Override
public PdfPTable generatePage() throws Exception {
    Image image = Image.getInstance(imageFile.toURL());
    float heightToWidthRatio = (210f / 297f);
    Image imageCropped = ImageUtils.cropImageToMeetRatio(pdfWriter, image, heightToWidthRatio);

    PdfPCell cell = new PdfPCell(imageCropped, true);
    cell.setBorder(0);
    cell.setPadding(COVER_MARGIN);
    cell.setHorizontalAlignment(Element.ALIGN_CENTER);
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
    cell.setExtraParagraphSpace(0);
    cell.setRightIndent(0);

    PdfPTable table = new PdfPTable(1);
    ;
    table.setWidthPercentage(100f);
    table.setWidths(new int[]{1});
    table.setExtendLastRow(true);
    table.addCell(cell);

    return table;
}
 
開發者ID:lenrok258,項目名稱:MountainQuest-PL,代碼行數:24,代碼來源:CoverPageGenerator.java

示例2: onEndPage

import com.itextpdf.text.pdf.PdfPTable; //導入方法依賴的package包/類
/**
 * Adds a header to every page
 * @see com.itextpdf.text.pdf.PdfPageEventHelper#onEndPage(
 *      com.itextpdf.text.pdf.PdfWriter, com.itextpdf.text.Document)
 */
public void onEndPage(PdfWriter writer, Document document) {
	PdfPTable table = new PdfPTable(3);
	try {
		table.setWidths(new int[]{40,5,10});
		table.setTotalWidth(100);
		table.getDefaultCell().setBorder(Rectangle.NO_BORDER);
		table.getDefaultCell().setHorizontalAlignment(Element.ALIGN_RIGHT);
		Font font=new Font(chineseFont,8);
		font.setColor(new BaseColor(55,55,55));
		Paragraph paragraph=new Paragraph("第   "+writer.getPageNumber()+" 頁   共",font);
		paragraph.setAlignment(Element.ALIGN_RIGHT);
		table.addCell(paragraph);
		Image img=Image.getInstance(total);
		img.scaleAbsolute(28, 28);
		PdfPCell cell = new PdfPCell(img);
		cell.setBorder(Rectangle.NO_BORDER);
		cell.setHorizontalAlignment(Element.ALIGN_CENTER);
		table.addCell(cell);
		PdfPCell c = new PdfPCell(new Paragraph("頁",font));
		c.setHorizontalAlignment(Element.ALIGN_LEFT);
		c.setBorder(Rectangle.NO_BORDER);
		table.addCell(c);
		float center=(document.getPageSize().getWidth())/2-120/2;
		table.writeSelectedRows(0, -1,center,30, writer.getDirectContent());
	}
	catch(DocumentException de) {
		throw new ExceptionConverter(de);
	}
}
 
開發者ID:bsteker,項目名稱:bdf2,代碼行數:35,代碼來源:PdfReportPageNumber.java

示例3: createGridTable

import com.itextpdf.text.pdf.PdfPTable; //導入方法依賴的package包/類
protected PdfPTable createGridTable(ReportDataModel dataModel, boolean isRepeatHeader) throws Exception {
	PdfPTable table = new PdfPTable(calculateGridColumnCount(dataModel.getTopColumnHeaders()));
	table.setWidthPercentage(100);
	Collection<ColumnHeader> topHeaders = dataModel.getTopColumnHeaders();
	List<Integer> widths = new ArrayList<Integer>();
	generateGridColumnWidths(topHeaders, widths);
	int[] values = new int[widths.size()];
	for (int i = 0; i < widths.size(); i++) {
		values[i] = widths.get(i);
	}
	table.setWidths(values);
	int maxHeaderLevel = getGridMaxColumngroup(topHeaders);
	createGridColumnHeader(table, topHeaders, maxHeaderLevel);
	createGridTableDatas(table, dataModel.getReportData());
	if (isRepeatHeader) {
		table.setHeaderRows(maxHeaderLevel);
	}
	return table;
}
 
開發者ID:bsteker,項目名稱:bdf2,代碼行數:20,代碼來源:AbstractPdfReportBuilder.java

示例4: createFooterTable

import com.itextpdf.text.pdf.PdfPTable; //導入方法依賴的package包/類
/**
     * <a href="http://stackoverflow.com/questions/43807931/creating-table-in-pdf-on-last-page-bottom-wrong-official-solution">
     * Creating table in pdf on last page bottom (wrong official solution)
     * </a>
     * <p>
     * Helper method for {@link #testCreateTableLikeUser7968180()}.
     * </p>
     */
    private static PdfPTable createFooterTable() throws DocumentException
    {
        int[] columnWidths = new int[] { 1, 1, 1, 1, 1, 1, 1, 1, 1 };
        PdfPTable datatable = new PdfPTable(columnWidths.length);
        datatable.setKeepTogether(true);
        datatable.setWidthPercentage(100);
        datatable.setWidths(columnWidths);
        datatable.getDefaultCell().setPadding(5);

//        datatable.getDefaultCell().setHorizontalAlignment(horizontalAlignment);
//        datatable.getDefaultCell().setVerticalAlignment(verticalAlignment);

        for (int i = 0; i < 100; i++)
        {
            datatable.addCell("Přehledová tabulka");
//            addCellToTable(datatable, horizontalAlignmentLeft, verticalAlignmentMiddle, "Přehledová tabulka",
//                    columnWidths.length, 1, fontTypeBold, fontSizeRegular, cellLayout_Bottom);
        }

        return datatable;
    }
 
開發者ID:mkl-public,項目名稱:testarea-itext5,代碼行數:30,代碼來源:CreateTableDirectContent.java

示例5: tableWithPageNumber

import com.itextpdf.text.pdf.PdfPTable; //導入方法依賴的package包/類
private PdfPTable tableWithPageNumber() throws DocumentException, IOException {

        PdfPTable innerTable = new PdfPTable(1);
        innerTable.setWidths(new int[]{1});
        innerTable.setWidthPercentage(100);
        innerTable.setPaddingTop(0);
        innerTable.addCell(new PageNumberCellGenerator(pageNumber, BackgroundColorGenerator.DEFAULT_BACKGROUND_COLOR)
                .generateTile());

        PdfPCell cell = new PdfPCell();
        cell.setVerticalAlignment(Element.ALIGN_BOTTOM);
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        cell.setBorder(0);
        cell.setPadding(0);
        cell.addElement(innerTable);

        PdfPTable table = new PdfPTable(1);
        table.setWidthPercentage(100f);
        table.setWidths(new int[]{1});
        table.setExtendLastRow(true);
        table.addCell(cell);
        return table;
    }
 
開發者ID:lenrok258,項目名稱:MountainQuest-PL,代碼行數:24,代碼來源:EmptyPageGenerator.java

示例6: generatePage

import com.itextpdf.text.pdf.PdfPTable; //導入方法依賴的package包/類
@Override
public PdfPTable generatePage() throws DocumentException, IOException, URISyntaxException {
    PdfPTable table = new PdfPTable(12); // Bootstrap style
    table.setWidthPercentage(100f);
    table.setWidths(new int[]{1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1});
    table.setExtendLastRow(true);

    table.addCell(generateHeaderTitle());
    table.addCell(generateHeaderData());
    table.addCell(generatePhoto());
    table.addCell(generateMapImage());
    table.addCell(generateDescription());
    table.addCell(generateFooter());

    return table;
}
 
開發者ID:lenrok258,項目名稱:MountainQuest-PL,代碼行數:17,代碼來源:DataPageGenerator.java

示例7: generateFooter

import com.itextpdf.text.pdf.PdfPTable; //導入方法依賴的package包/類
private PdfPCell generateFooter() throws IOException, DocumentException, URISyntaxException {

        PdfPCell cell = new PdfPCell();
        cell.setColspan(12);
        cell.setVerticalAlignment(Element.ALIGN_BOTTOM);
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        cell.setBorder(0);
        cell.setPadding(0);

        PdfPTable innerTable = new PdfPTable(2);
        innerTable.getDefaultCell().setBorder(0);
        innerTable.setWidths(new int[]{1, 1});
        innerTable.setWidthPercentage(100);
        innerTable.addCell(generateStamp());
        innerTable.addCell(new PageNumberCellGenerator(pageNumber, backgroundColor).generateTile());

        cell.addElement(innerTable);
        return cell;
    }
 
開發者ID:lenrok258,項目名稱:MountainQuest-PL,代碼行數:20,代碼來源:DataPageGenerator.java

示例8: buildFooterVersetzungsvermerkLine

import com.itextpdf.text.pdf.PdfPTable; //導入方法依賴的package包/類
public static PdfPTable buildFooterVersetzungsvermerkLine(String versetzungsvermerk, Font footerFont) throws DocumentException {
	PdfPCell labelCell = new PdfPCell(new Phrase("Versetzungsvermerk", footerFont));
	labelCell.setBorder(Rectangle.BOTTOM);
	labelCell.setBorderWidth(1f);

	PdfPCell nameCell = new PdfPCell(new Phrase(versetzungsvermerk, footerFont));
	nameCell.setBorder(Rectangle.BOTTOM);
	nameCell.setBorderWidth(1f);
	
	PdfPTable table = new PdfPTable(2);
	table.setHorizontalAlignment(Element.ALIGN_LEFT);
	table.setWidthPercentage(100f);
	table.addCell(labelCell);
	table.addCell(nameCell);
	table.setWidths(new float[] {0.3f, 0.7f});
	return table;
}
 
開發者ID:fossaag,項目名稱:rolp,代碼行數:18,代碼來源:PdfFormatHelper.java

示例9: buildFooterDatumLine

import com.itextpdf.text.pdf.PdfPTable; //導入方法依賴的package包/類
public static PdfPTable buildFooterDatumLine(String datumString, Font footerFont) throws DocumentException {
	PdfPCell labelCell = new PdfPCell(new Phrase("Datum", footerFont));
	labelCell.setBorder(Rectangle.BOTTOM);
	labelCell.setBorderWidth(1f);

	PdfPCell nameCell = new PdfPCell(new Phrase(datumString, footerFont));
	nameCell.setBorder(Rectangle.BOTTOM);
	nameCell.setBorderWidth(1f);
	
	PdfPTable table = new PdfPTable(2);
	table.setHorizontalAlignment(Element.ALIGN_LEFT);
	table.setWidthPercentage(100f);
	table.addCell(labelCell);
	table.addCell(nameCell);
	table.setWidths(new float[] {0.3f, 0.7f});
	return table;
}
 
開發者ID:fossaag,項目名稱:rolp,代碼行數:18,代碼來源:PdfFormatHelper.java

示例10: buildFooterDienstsiegelLine

import com.itextpdf.text.pdf.PdfPTable; //導入方法依賴的package包/類
public static PdfPTable buildFooterDienstsiegelLine(Font footerFont) throws DocumentException {
	PdfPCell leftCell = new PdfPCell(new Phrase("", footerFont));
	leftCell.setBorder(Rectangle.NO_BORDER);
	leftCell.setBorderWidth(1f);
	
	PdfPCell centerCell = new PdfPCell(new Phrase("Dienstsiegel der Schule", footerFont));
	centerCell.setBorder(Rectangle.NO_BORDER);
	centerCell.setBorderWidth(1f);
	centerCell.setHorizontalAlignment(Element.ALIGN_CENTER);

	PdfPCell rightCell = new PdfPCell(new Phrase("", footerFont));
	rightCell.setBorder(Rectangle.NO_BORDER);
	rightCell.setBorderWidth(1f);
	
	PdfPTable table = new PdfPTable(3);
	table.setHorizontalAlignment(Element.ALIGN_MIDDLE);
	table.setWidthPercentage(100f);
	table.addCell(leftCell);
	table.addCell(centerCell);
	table.addCell(rightCell);
	table.setWidths(new float[] {0.3f, 0.3f, 0.3f});
	return table;
}
 
開發者ID:fossaag,項目名稱:rolp,代碼行數:24,代碼來源:PdfFormatHelper.java

示例11: buildFooterUnterschriftenLine

import com.itextpdf.text.pdf.PdfPTable; //導入方法依賴的package包/類
public static PdfPTable buildFooterUnterschriftenLine(Font footerFont) throws DocumentException {
	PdfPCell leftCell = new PdfPCell(new Phrase("Schulleiter(in)", footerFont));
	leftCell.setBorder(Rectangle.TOP);
	leftCell.setBorderWidth(1f);
	leftCell.setHorizontalAlignment(Element.ALIGN_CENTER);
	
	PdfPCell centerCell = new PdfPCell(new Phrase("", footerFont));
	centerCell.setBorder(Rectangle.TOP);
	centerCell.setBorderWidth(1f);
	centerCell.setHorizontalAlignment(Element.ALIGN_CENTER);

	PdfPCell rightCell = new PdfPCell(new Phrase("Klassenleiter(in)", footerFont));
	rightCell.setBorder(Rectangle.TOP);
	rightCell.setBorderWidth(1f);
	rightCell.setHorizontalAlignment(Element.ALIGN_CENTER);
	
	PdfPTable table = new PdfPTable(3);
	table.setWidthPercentage(100f);
	table.addCell(leftCell);
	table.addCell(centerCell);
	table.addCell(rightCell);
	table.setWidths(new float[] {0.3f, 0.3f, 0.3f});
	return table;
}
 
開發者ID:fossaag,項目名稱:rolp,代碼行數:25,代碼來源:PdfFormatHelper.java

示例12: buildFooterHalbjahrDatumLine

import com.itextpdf.text.pdf.PdfPTable; //導入方法依賴的package包/類
public static PdfPTable buildFooterHalbjahrDatumLine(String datumString, Font footerFont) throws DocumentException {
	PdfPCell leftCell = new PdfPCell(new Phrase(datumString, footerFont));
	leftCell.setBorder(Rectangle.NO_BORDER);
	leftCell.setHorizontalAlignment(Element.ALIGN_CENTER);
	
	PdfPCell centerCell = new PdfPCell(new Phrase("", footerFont));
	centerCell.setBorder(Rectangle.NO_BORDER);
	centerCell.setHorizontalAlignment(Element.ALIGN_CENTER);

	PdfPCell rightCell = new PdfPCell(new Phrase("", footerFont));
	rightCell.setBorder(Rectangle.NO_BORDER);
	rightCell.setHorizontalAlignment(Element.ALIGN_CENTER);
	
	PdfPTable table = new PdfPTable(3);
	table.setWidthPercentage(100f);
	table.addCell(leftCell);
	table.addCell(centerCell);
	table.addCell(rightCell);
	table.setWidths(new float[] {0.3f, 0.3f, 0.3f});
	return table;
}
 
開發者ID:fossaag,項目名稱:rolp,代碼行數:22,代碼來源:PdfFormatHelper.java

示例13: buildFooterHalbjahrDatumKlassenleiterLine

import com.itextpdf.text.pdf.PdfPTable; //導入方法依賴的package包/類
public static PdfPTable buildFooterHalbjahrDatumKlassenleiterLine(Font footerFont) throws DocumentException {
	PdfPCell leftCell = new PdfPCell(new Phrase("Datum", footerFont));
	leftCell.setBorder(Rectangle.TOP);
	leftCell.setBorderWidth(1f);
	leftCell.setHorizontalAlignment(Element.ALIGN_CENTER);
	
	PdfPCell centerCell = new PdfPCell(new Phrase("", footerFont));
	centerCell.setBorder(Rectangle.TOP);
	centerCell.setBorderWidth(1f);
	centerCell.setHorizontalAlignment(Element.ALIGN_CENTER);

	PdfPCell rightCell = new PdfPCell(new Phrase("Klassenleiter(in)", footerFont));
	rightCell.setBorder(Rectangle.TOP);
	rightCell.setBorderWidth(1f);
	rightCell.setHorizontalAlignment(Element.ALIGN_CENTER);
	
	PdfPTable table = new PdfPTable(3);
	table.setWidthPercentage(100f);
	table.addCell(leftCell);
	table.addCell(centerCell);
	table.addCell(rightCell);
	table.setWidths(new float[] {0.3f, 0.3f, 0.3f});
	return table;
}
 
開發者ID:fossaag,項目名稱:rolp,代碼行數:25,代碼來源:PdfFormatHelper.java

示例14: generateAwesomeFontPdf

import com.itextpdf.text.pdf.PdfPTable; //導入方法依賴的package包/類
private File generateAwesomeFontPdf() throws DocumentException, IOException {
    File fileOut = openDocument("awesomeFont");

    BaseFont bf = BaseFont.createFont("font/FontAwesome.otf", BaseFont.IDENTITY_H, BaseFont.EMBEDDED);
    Font font = new Font(bf, 12);
    FontAwesome awesome = FontAwesome.getInstance();

    PdfPTable table = new PdfPTable(2);
    table.setWidthPercentage(288 / 5.23f);
    table.setWidths(new int[]{2, 1});
    for (String key : awesome.keys().toSortedList(stringComparator())) {
        table.addCell(new PdfPCell(new Phrase(key)));
        table.addCell(new PdfPCell(new Phrase(awesome.get(key), font)));
    }
    document.add(table);
    closeDocument();
    return fileOut;
}
 
開發者ID:Arnauld,項目名稱:gutenberg,代碼行數:19,代碼來源:FontawesomePdfTest.java

示例15: extendTableToWidth

import com.itextpdf.text.pdf.PdfPTable; //導入方法依賴的package包/類
public static void extendTableToWidth(PdfPTable element, float width) throws DocumentException {
    element.setTotalWidth(width);

    float[] absoluteWidths = element.getAbsoluteWidths();
    if (element.getNumberOfColumns() < 10) {
        float sum = sum(absoluteWidths);
        float minWidth = sum / 10; // at least 10% of the table
        for (int i = 0; i < absoluteWidths.length; i++) {
            absoluteWidths[i] = Math.max(minWidth, absoluteWidths[i]);
        }
    }

    int[] widths = new int[element.getNumberOfColumns()];
    for (int i = 0; i < widths.length; i++)
        widths[i] = 1;
    element.setWidths(absoluteWidths);
}
 
開發者ID:Arnauld,項目名稱:cucumber-contrib,代碼行數:18,代碼來源:Configuration.java


注:本文中的com.itextpdf.text.pdf.PdfPTable.setWidths方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。