本文整理匯總了Java中com.itextpdf.text.pdf.PdfPTable.setTotalWidth方法的典型用法代碼示例。如果您正苦於以下問題:Java PdfPTable.setTotalWidth方法的具體用法?Java PdfPTable.setTotalWidth怎麽用?Java PdfPTable.setTotalWidth使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.itextpdf.text.pdf.PdfPTable
的用法示例。
在下文中一共展示了PdfPTable.setTotalWidth方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: onEndPage
import com.itextpdf.text.pdf.PdfPTable; //導入方法依賴的package包/類
@Override
public void onEndPage(PdfWriter writer, Document document) {
PdfPTable table = new PdfPTable(2);
table.setTotalWidth(527);
table.setWidthPercentage(100);
table.setLockedWidth(true);
table.getDefaultCell().setFixedHeight(105f);
table.getDefaultCell().setBorderWidth(0);
table.addCell("");
table.addCell(csmLogoImage);
table.writeSelectedRows(0, -1, 100, 840, writer.getDirectContent());
ColumnText.showTextAligned(writer.getDirectContent(),
Element.ALIGN_LEFT,
new Phrase(lebData.getSchuelername() + " " + lebData.getSchuljahr() + " " + lebData.getSchulhalbjahr().getId() + " Seite " + document.getPageNumber(), fusszeilenFont),
100, 75, 0);
}
示例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);
}
}
示例3: generateFooter
import com.itextpdf.text.pdf.PdfPTable; //導入方法依賴的package包/類
public PdfPTable generateFooter() {
try {
BaseFont baseFont = BaseFont.createFont(/*"resources/ARIAL.TTF"*/ "c:/Windows/Fonts/arial.ttf", BaseFont.IDENTITY_H, true);
footerTable = new PdfPTable(1);
footerTable.setTotalWidth(440);
footerTable.setLockedWidth(true);
Font pageNumberFont = new Font(baseFont, 9, Font.BOLD);
Paragraph pageNumberP = new Paragraph(titleIndex+"-"+ pageNumber, pageNumberFont);
PdfPCell pageNumberCell = new PdfPCell(pageNumberP);
pageNumberCell.setBorder(0);
pageNumberCell.setPaddingTop(20);
footerTable.addCell(pageNumberCell);
} catch (Exception e) {
e.printStackTrace();
}
return footerTable;
}
示例4: createReceiptHeaderAndTextBelow
import com.itextpdf.text.pdf.PdfPTable; //導入方法依賴的package包/類
private void createReceiptHeaderAndTextBelow(PdfContentByte cb) throws DocumentException {
PdfPTable headerTable = new PdfPTable(1);
float[] rows = { 450f };
headerTable.setTotalWidth(rows);
headerTable.getDefaultCell()
.setBorder(Rectangle.NO_BORDER);
headerTable.addCell(new Phrase(new Chunk("Bestätigung über Geldzuwendungen", textFontForReceiptHeader)));
headerTable.writeSelectedRows(0, 1, 75f, 625, cb);
PdfPTable table = new PdfPTable(1);
table.setTotalWidth(rows);
table.getDefaultCell()
.setBorder(Rectangle.NO_BORDER);
table.getDefaultCell()
.setLeading(8f, 0);
table.addCell(new Phrase(new Chunk("im Sinne des §10b des Einkommensteuergesetzes", textFont)));
table.addCell(new Phrase(new Chunk("an eine der in §5 Abs. 1 Nr. 9 des Körperschaftsteuergesetzes bezeichneten", textFont)));
table.addCell(new Phrase(new Chunk("Körperschaften, Personenvereinigungen oder Vermögensmassen", textFont)));
table.writeSelectedRows(0, 3, 75f, 590, cb);
}
示例5: createPriceTable
import com.itextpdf.text.pdf.PdfPTable; //導入方法依賴的package包/類
private PdfPTable createPriceTable(PdfContentByte cb, Receipt receipt) throws DocumentException {
PdfPTable tableForPrices = new PdfPTable(1);
float[] rowForTotalPrice = { 250f };
tableForPrices.setTotalWidth(rowForTotalPrice);
tableForPrices.getDefaultCell()
.setBorder(Rectangle.NO_BORDER);
tableForPrices.addCell(new Phrase(new Chunk("Betrag der Zuwendung in Ziffern:", textFont)));
tableForPrices.addCell(new Phrase(new Chunk(" ", textFont)));
Double totalPrice = 0.0;
for (final Cart cart : receipt.getCarts()) {
tableForPrices.addCell(new Phrase(new Chunk(cart.getTotalPrice()
.toString()
+ " €", textFontUserData)));
totalPrice += cart.getTotalPrice()
.doubleValue();
}
String formattedPrice = priceFormat.format(totalPrice)
.toString();
tableForPrices.addCell(new Phrase(new Chunk("Gesamt: " + formattedPrice + " €", textFontUserData)));
return tableForPrices;
}
示例6: createDateTable
import com.itextpdf.text.pdf.PdfPTable; //導入方法依賴的package包/類
private PdfPTable createDateTable(PdfContentByte cb, Receipt receipt) throws DocumentException {
PdfPTable tableForDate = new PdfPTable(1);
float[] rowForDate = { 110f };
tableForDate.setTotalWidth(rowForDate);
tableForDate.getDefaultCell()
.setBorder(Rectangle.NO_BORDER);
tableForDate.addCell(new Phrase(new Chunk("Datum der Zuwendung:", textFont)));
tableForDate.addCell(new Phrase(new Chunk(" ", textFont)));
final Calendar cal = Calendar.getInstance(TimeZone.getTimeZone("GMT+2"), Locale.GERMAN);
for (final Cart cart : receipt.getCarts()) {
cal.setTimeInMillis(cart.getTimeStamp());
final String date = cal.get(Calendar.DAY_OF_MONTH) + "." + (cal.get(Calendar.MONTH) + 1) + "." + cal.get(Calendar.YEAR);
PdfPCell cell = new PdfPCell(new Phrase(new Chunk(date, textFontUserData)));
cell.setHorizontalAlignment(PdfPCell.ALIGN_RIGHT);
cell.setBorder(PdfPCell.NO_BORDER);
tableForDate.addCell(cell);
}
return tableForDate;
}
示例7: createCircleAndText
import com.itextpdf.text.pdf.PdfPTable; //導入方法依賴的package包/類
public static void createCircleAndText(PdfContentByte cb, String text, float xCoord, float yCoord, float radius, Font textFont, int circleColorRed, int circleColorGreen, int circleColorBlue)
throws DocumentException, IOException {
cb.saveState();
cb.setRGBColorFill(circleColorRed, circleColorGreen, circleColorBlue);
cb.circle(xCoord, yCoord, radius);
cb.fill();
cb.stroke();
cb.restoreState();
PdfPTable table = new PdfPTable(1);
float[] rows = { 595f };
table.setTotalWidth(rows);
table.getDefaultCell().setBorder(Rectangle.NO_BORDER);
table.getDefaultCell().setHorizontalAlignment(Element.ALIGN_CENTER);
table.getDefaultCell().setVerticalAlignment(Element.ALIGN_MIDDLE);
table.getDefaultCell().setFixedHeight(radius * 2);
table.addCell(new Phrase(new Chunk(text, textFont)));
table.writeSelectedRows(0, 1, 0, yCoord + radius, cb);
}
示例8: createBarcodeTable
import com.itextpdf.text.pdf.PdfPTable; //導入方法依賴的package包/類
private PdfPTable createBarcodeTable(PdfContentByte cb, String caption, String detail, String code) {
// Barcode Generation
Barcode39 codeEAN = new Barcode39();
codeEAN.setCode(code);
Image imageEAN = codeEAN.createImageWithBarcode(cb, null, null);
// Table
PdfPTable table = new PdfPTable(1);
table.setSpacingBefore(10);
table.setSpacingAfter(10);
table.setTotalWidth(80);
table.setLockedWidth(true);
PdfPCell cell1 = new PdfPCell(imageEAN);
PdfPCell cell2 = new PdfPCell(new Paragraph(caption));
PdfPCell cell3 = new PdfPCell(new Paragraph(detail));
cell1.setBorder(Rectangle.NO_BORDER);
cell2.setBorder(Rectangle.NO_BORDER);
cell3.setBorder(Rectangle.NO_BORDER);
table.addCell(cell1);
table.addCell(cell2);
table.addCell(cell3);
return table;
}
示例9: 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);
}
示例10: onStartPage
import com.itextpdf.text.pdf.PdfPTable; //導入方法依賴的package包/類
@Override
public void onStartPage(PdfWriter writer, Document document) {
cabe = true;
PdfPTable pTableNumPage = new PdfPTable(1);
pTableNumPage.setTotalWidth(80f);
PdfPCell pCellImagem = new PdfPCell(new Phrase("Pag Nº: ".toUpperCase() + document.getPageNumber(), fontNump));
pCellImagem.setRotation(270);
pCellImagem.setBorder(0);
pTableNumPage.addCell(pCellImagem);
pTableNumPage.writeSelectedRows(-1, 2, 761f, 80.5f, writer.getDirectContent());
}
示例11: createTable
import com.itextpdf.text.pdf.PdfPTable; //導入方法依賴的package包/類
public PdfPTable createTable(int colNumber) {
PdfPTable table = new PdfPTable(colNumber);
try {
table.setTotalWidth(maxWidth);
table.setLockedWidth(true);
table.setHorizontalAlignment(Element.ALIGN_CENTER);
table.getDefaultCell().setBorder(1);
} catch (Exception e) {
e.printStackTrace();
}
return table;
}
示例12: createTable
import com.itextpdf.text.pdf.PdfPTable; //導入方法依賴的package包/類
public PdfPTable createTable( float widthInPs ){
PdfPTable table = new PdfPTable(1);
table.setTotalWidth(widthInPs);
table.setLockedWidth( true );
table.setSpacingBefore(0);
table.setSpacingAfter(0);
return table;
}
示例13: getContentTable
import com.itextpdf.text.pdf.PdfPTable; //導入方法依賴的package包/類
/**
* Get the header/footer content table, set to the page width up to the page margins
* @return The header/footer content table set to the correct width based on the page attributes
*/
private PdfPTable getContentTable() {
PdfPTable lTable = mContent.getContentTable();
float lContentWidth = mPageAttributes.getPageWidth() - mPageAttributes.getMarginLeft() - mPageAttributes.getMarginRight();
lTable.setTotalWidth(lContentWidth);
return lTable;
}
示例14: createAdress
import com.itextpdf.text.pdf.PdfPTable; //導入方法依賴的package包/類
public static void createAdress(PdfContentByte cb, float xCoord, float yCoord) throws DocumentException {
Font textFontForAdress = new Font(FontFamily.HELVETICA, 10, Font.NORMAL, BaseColor.BLACK);
PdfPTable table = new PdfPTable(1);
float[] rows = { 200f };
table.setTotalWidth(rows);
table.getDefaultCell().setBorder(Rectangle.NO_BORDER);
table.getDefaultCell().setFixedHeight(14f);
table.addCell(new Phrase(new Chunk("Wald 1.1 gemeinnützige GmbH", textFontForAdress)));
table.addCell(new Phrase(new Chunk("Gabelsbergerstraße 4", textFontForAdress)));
table.addCell(new Phrase(new Chunk("D-06114 Halle", textFontForAdress)));
table.writeSelectedRows(0, 3, xCoord, yCoord, cb);
}
示例15: createPdf
import com.itextpdf.text.pdf.PdfPTable; //導入方法依賴的package包/類
/**
* <a href="http://stackoverflow.com/questions/44005834/changing-rowspans">
* Changing rowspans
* </a>
* <p>
* The original code used by the OP. This code adds the second cell
* with rowspan 2 too early. Fixed in {@link #createPdfFixed(String)}.
* </p>
* @see #testUseRowspanLikeUser7968180()
* @see #addCellToTableCzech(PdfPTable, int, int, String, int, int, String, float)
*/
public void createPdf(String dest) throws IOException, DocumentException {
int horizontalAlignmentCenter = Element.ALIGN_CENTER;
int verticalAlignmentMiddle = Element.ALIGN_MIDDLE;
String fontTypeRegular = "c:/Windows/Fonts/arial.ttf";
float fontSizeRegular = 10f;
float[] columns = { 100, 50, 100, 50, 50, 50, 50, 50, 75, 50, 50, 50 };
int numberOfColumns = columns.length;
Document document = new Document(PageSize.A4.rotate(), 36, 36, 36, 36);
PdfWriter.getInstance(document, new FileOutputStream(dest));
document.open();
PdfPTable subTableZkouska = new PdfPTable(numberOfColumns);
subTableZkouska.setTotalWidth(columns);
subTableZkouska.setLockedWidth(true);
addCellToTableCzech(subTableZkouska, horizontalAlignmentCenter,
verticalAlignmentMiddle, "Brno �pit�lka 8 Brno H�jeck� 1068/14 CZ5159", 1,
2, fontTypeRegular, fontSizeRegular);
addCellToTableCzech(subTableZkouska, horizontalAlignmentCenter,
verticalAlignmentMiddle, "38", 1, 2, fontTypeRegular, fontSizeRegular);
for (int i = 0; i < 19; i++) {
addCellToTableCzech(subTableZkouska, horizontalAlignmentCenter,
verticalAlignmentMiddle, "38", 1, 1, fontTypeRegular,
fontSizeRegular);
}
addCellToTableCzech(subTableZkouska, horizontalAlignmentCenter,
verticalAlignmentMiddle, "38", 1, 1, fontTypeRegular, fontSizeRegular);
document.add(subTableZkouska);
document.close();
}