本文整理汇总了Java中com.itextpdf.text.pdf.PdfPCell.setFixedHeight方法的典型用法代码示例。如果您正苦于以下问题:Java PdfPCell.setFixedHeight方法的具体用法?Java PdfPCell.setFixedHeight怎么用?Java PdfPCell.setFixedHeight使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.itextpdf.text.pdf.PdfPCell
的用法示例。
在下文中一共展示了PdfPCell.setFixedHeight方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getPhotoCell
import com.itextpdf.text.pdf.PdfPCell; //导入方法依赖的package包/类
private static PdfPCell getPhotoCell(BufferedImage bufferedImage, float scalePercent, boolean isHorizontallyCentered) throws BadElementException, IOException {
Image jpeg = Image.getInstance(bufferedImage, null);
jpeg.scalePercent(scalePercent);
jpeg.setAlignment(Image.MIDDLE);
PdfPCell photoCell = new PdfPCell(jpeg);
photoCell.setBorder(0);
if (isHorizontallyCentered) {
photoCell.setHorizontalAlignment(Element.ALIGN_CENTER);
} else {
photoCell.setHorizontalAlignment(Element.ALIGN_RIGHT);
}
photoCell.setVerticalAlignment(Element.ALIGN_TOP);
int height = (int) Math.ceil(bufferedImage.getHeight() * scalePercent / 100);
photoCell.setFixedHeight(height);
return photoCell;
}
示例2: createCell
import com.itextpdf.text.pdf.PdfPCell; //导入方法依赖的package包/类
public PdfPCell createCell( Block block ){
float[] margins = block.getMargins();
PdfPCell cell = new PdfPCell();
cell.setBorderWidth(0);
cell.setVerticalAlignment( VerticalAlign.getByName(block.getVerticalAlign()).getAlignment() );
cell.setLeft(0);
cell.setTop(0);
cell.setRight(0);
cell.setBottom(0);
cell.setUseAscender( block.isUseAscender() );
cell.setIndent(0);
cell.setPaddingLeft( SizeFactory.millimetersToPostscriptPoints( margins[0]) );
cell.setPaddingBottom( SizeFactory.millimetersToPostscriptPoints(margins[3]) );
cell.setPaddingRight( SizeFactory.millimetersToPostscriptPoints(margins[1]) );
cell.setPaddingTop( SizeFactory.millimetersToPostscriptPoints(margins[2]) );
cell.setFixedHeight(SizeFactory.millimetersToPostscriptPoints( block.getPosition()[3] ));
cell.setBorder(0);
cell.setCellEvent( new CellBlockEvent().createEvent(block));
cell.setRotation( block.getRotation() );
return cell;
}
示例3: createLawTable
import com.itextpdf.text.pdf.PdfPCell; //导入方法依赖的package包/类
private PdfPTable createLawTable(PdfContentByte cb) throws DocumentException {
PdfPTable table = new PdfPTable(1);
float[] rows = { 445f };
table.setTotalWidth(rows);
table.getDefaultCell()
.setBorder(Rectangle.NO_BORDER);
table.getDefaultCell()
.setLeading(8f, 0);
table.addCell(new Phrase(new Chunk("Es handelt sich nicht um den Verzicht auf Erstattung von Aufwendungen.", textFontLawText)));
table.addCell(new Phrase(new Chunk("Die Gesellschaft ist wegen Förderung (begünstigter Zweck: Umweltschutz (§52 (2) S. 1 Nr.(n) 8 AO)) durch", textFontLawText)));
table.addCell(new Phrase(new Chunk("Bescheinigung des Finanzamt Halle (Saale)-Nord, StNr. 110/108/91169, vom 19.11.2008 ab 01.01.2009", textFontLawText)));
table.addCell(new Phrase(new Chunk("als gemeinnützig anerkannt. Letzter Freistellungsbescheid datiert auf den 20.06.2013.", textFontLawText)));
table.addCell(new Phrase(new Chunk("Es wird bestätigt, dass die Zuwendung nur zur Förderung des Umweltschutzes verwendet wird.", textFontLawText)));
PdfPCell emptyCell = new PdfPCell();
emptyCell.setBorder(Rectangle.BOTTOM);
emptyCell.setFixedHeight(15f);
table.addCell(emptyCell);
return table;
}
示例4: addCell
import com.itextpdf.text.pdf.PdfPCell; //导入方法依赖的package包/类
public void addCell(PdfPCell cell) {
cell.setBorder(borderwidth);
cell.setNoWrap(false);
cell.setFixedHeight(margins.getLabelHeight());
//cell.setHorizontalAlignment(Element.ALIGN_CENTER);
//cell.setVerticalAlignment(Element.ALIGN_TOP);
if(curX != 0)
{
PdfPCell gapcell = new PdfPCell();
gapcell.setBorder(borderwidth);
table.addCell(gapcell);
}
curX++;
table.addCell(cell);
if(curX == nAcross)
//table.completeRow();
curX = 0;
}
示例5: createStringCell
import com.itextpdf.text.pdf.PdfPCell; //导入方法依赖的package包/类
private PdfPCell createStringCell(PdfPTable table, String text, ExcelExportEntity entity,
int rowHeight, int colspan, int rowspan) {
PdfPCell iCell = new PdfPCell(new Phrase(text, styler.getFont(entity, text)));
styler.setCellStyler(iCell, entity, text);
iCell.setFixedHeight((int) (rowHeight * 2.5));
if (colspan > 1) {
iCell.setColspan(colspan);
}
if (rowspan > 1) {
iCell.setRowspan(rowspan);
}
table.addCell(iCell);
return iCell;
}
示例6: generateStamp
import com.itextpdf.text.pdf.PdfPCell; //导入方法依赖的package包/类
private PdfPCell generateStamp() throws IOException, DocumentException, URISyntaxException {
PdfPTable stampTable = new PdfPTable(2);
stampTable.setWidths(new float[] {1,12});
PdfPCell cellIcon = new PdfPCell(ImageUtils.readImageFromResources("icons/check.png"));
cellIcon.setFixedHeight(10);
cellIcon.setPadding(2);
cellIcon.setBorder(0);
cellIcon.setBackgroundColor(backgroundColor);
PdfPCell cellText = new PdfPCell(phrase("Data i pieczątka"));
cellText.setHorizontalAlignment(Element.ALIGN_LEFT);
cellText.setVerticalAlignment(Element.ALIGN_CENTER);
cellText.setBorder(0);
cellText.setBackgroundColor(backgroundColor);
cellText.setPadding(0);
cellText.setPaddingTop(5);
cellText.setPaddingLeft(5);
stampTable.addCell(cellIcon);
stampTable.addCell(cellText);
PdfPCell stampCell = new PdfPCell(stampTable);
stampCell.setPadding(0);
stampCell.setBorder(0);
return stampCell;
}
示例7: createTable
import com.itextpdf.text.pdf.PdfPCell; //导入方法依赖的package包/类
private PdfPTable createTable(PdfWriter writer, LabelFormat labelFormat, int firstRow, int lastRow) throws DocumentException {
if(firstRow >= lastRow) {
LOG.info("First row = " + firstRow + ", last row = " + lastRow + " so returning null");
return null;
}
if(lastRow - firstRow > labelFormat.getColumns() * labelFormat.getRows()) {
LOG.info("There were too many labels requested. "
+ "You wanted: " + (lastRow - firstRow) + " labels, "
+ "but this label format only allows: " + labelFormat.getColumns() * labelFormat.getRows());
return null;
}
final XSSFSheet sheet = xSSFWorkbook.getSheetAt(0);
if(lastRow > sheet.getLastRowNum()) {
LOG.info("last row was larger that the last row number of this sheet: " + sheet.getLastRowNum());
lastRow = sheet.getLastRowNum();
}
if(firstRow >= lastRow) {
LOG.info("after adjusting the last row, First row = " + firstRow + ", last row = " + lastRow + " so returning null");
return null;
}
final PdfPTable table = new PdfPTable(labelFormat.getColumns());
table.getDefaultCell().setBorder(PdfPCell.NO_BORDER);
table.setWidthPercentage(labelFormat.getWidthPercentage());
LOG.info("The width percentage i found is; " + labelFormat.getWidthPercentage());
for(int i = firstRow; i <= lastRow; i++) {
LOG.info("Showing row: " + i);
showOneLabel(sheet.getRow(i), table, writer, labelFormat);
}
if(lastRow == sheet.getLastRowNum()) {
// we are at the end
//check to make sure that the last row is filled in
if(lastRow % labelFormat.getColumns() != 0) {
for(int x = 0; x < lastRow % labelFormat.getColumns(); x++) {
final PdfPCell cell = new PdfPCell();
cell.setFixedHeight(labelFormat.getHeight() * 72);
cell.addElement(new Paragraph(" "));
table.addCell(cell);
}
}
}
return table;
}
示例8: testCreateLocalLinkInRotatedCell
import com.itextpdf.text.pdf.PdfPCell; //导入方法依赖的package包/类
/**
* <a href="http://stackoverflow.com/questions/34408764/create-local-link-in-rotated-pdfpcell-in-itextsharp">
* Create local link in rotated PdfPCell in iTextSharp
* </a>
* <p>
* This is the equivalent Java code for the C# code in the question. Indeed, this code
* also gives rise to the broken result. The cause is simple: Normally iText does not
* touch the current transformation matrix. So the chunk link creation code assumes the
* current user coordinate system to be the same as used for positioning annotations.
* But in case of rotated cells iText does change the transformation matrix and
* consequently the chunk link creation code positions the annotation at the wrong
* location.
* </p>
*/
@Test
public void testCreateLocalLinkInRotatedCell() throws IOException, DocumentException
{
Document doc = new Document();
PdfWriter writer = PdfWriter.getInstance(doc, new FileOutputStream(new File(RESULT_FOLDER, "local-link.pdf")));
doc.open();
PdfPTable linkTable = new PdfPTable(2);
PdfPCell linkCell = new PdfPCell();
linkCell.setHorizontalAlignment(Element.ALIGN_CENTER);
linkCell.setRotation(90);
linkCell.setFixedHeight(70);
Anchor linkAnchor = new Anchor("Click here");
linkAnchor.setReference("#target");
Paragraph linkPara = new Paragraph();
linkPara.add(linkAnchor);
linkCell.addElement(linkPara);
linkTable.addCell(linkCell);
PdfPCell linkCell2 = new PdfPCell();
Anchor linkAnchor2 = new Anchor("Click here 2");
linkAnchor2.setReference("#target");
Paragraph linkPara2 = new Paragraph();
linkPara2.add(linkAnchor2);
linkCell2.addElement(linkPara2);
linkTable.addCell(linkCell2);
linkTable.addCell(new PdfPCell(new Phrase("cell 3")));
linkTable.addCell(new PdfPCell(new Phrase("cell 4")));
doc.add(linkTable);
doc.newPage();
Anchor destAnchor = new Anchor("top");
destAnchor.setName("target");
PdfPTable destTable = new PdfPTable(1);
PdfPCell destCell = new PdfPCell();
Paragraph destPara = new Paragraph();
destPara.add(destAnchor);
destCell.addElement(destPara);
destTable.addCell(destCell);
destTable.addCell(new PdfPCell(new Phrase("cell 2")));
destTable.addCell(new PdfPCell(new Phrase("cell 3")));
destTable.addCell(new PdfPCell(new Phrase("cell 4")));
doc.add(destTable);
doc.close();
}
示例9: generateHeaderData
import com.itextpdf.text.pdf.PdfPCell; //导入方法依赖的package包/类
private PdfPCell generateHeaderData() throws IOException, DocumentException, URISyntaxException {
String textMountain = MessageFormat.format("{0}", data.mountains);
PdfPCell cellMountain = new PdfPCell(PhraseUtil.phrase(textMountain, 12));
cellMountain.setBorder(0);
cellMountain.setHorizontalAlignment(Element.ALIGN_RIGHT);
cellMountain.setVerticalAlignment(Element.ALIGN_CENTER);
cellMountain.setPadding(0);
cellMountain.setPaddingBottom(4);
PdfPCell cellMountainIcon = new PdfPCell(ImageUtils.readImageFromResources("icons/mountains01.png"), true);
cellMountainIcon.setBorder(0);
cellMountainIcon.setHorizontalAlignment(Element.ALIGN_RIGHT);
cellMountainIcon.setFixedHeight(10);
String heightMountain = MessageFormat.format("{0}m n.p.m., {1}km", data.height, data.distanceFromCracow);
PdfPCell cellHeight = new PdfPCell(PhraseUtil.phrase(heightMountain, 12));
cellHeight.setBorder(0);
cellHeight.setHorizontalAlignment(Element.ALIGN_RIGHT);
cellHeight.setVerticalAlignment(Element.ALIGN_CENTER);
cellHeight.setPadding(0);
cellHeight.setPaddingBottom(4);
PdfPCell cellHeightIcon = new PdfPCell(ImageUtils.readImageFromResources("icons/map01.png"), true);
cellHeightIcon.setBorder(0);
cellHeightIcon.setHorizontalAlignment(Element.ALIGN_RIGHT);
cellHeightIcon.setFixedHeight(10);
String coordinatesMountain = MessageFormat.format("{0}, {1}", data.latitude, data.longitude);
PdfPCell cellCoordinates = new PdfPCell(PhraseUtil.phrase(coordinatesMountain, 12));
cellCoordinates.setBorder(0);
cellCoordinates.setHorizontalAlignment(Element.ALIGN_RIGHT);
cellCoordinates.setVerticalAlignment(Element.ALIGN_CENTER);
cellCoordinates.setPadding(0);
cellCoordinates.setPaddingBottom(4);
PdfPCell cellCoordinatesIcon = new PdfPCell(ImageUtils.readImageFromResources("icons/compas.png"), true);
cellCoordinatesIcon.setBorder(0);
cellCoordinatesIcon.setHorizontalAlignment(Element.ALIGN_RIGHT);
cellCoordinatesIcon.setFixedHeight(10);
PdfPTable headerTable = new PdfPTable(2);
headerTable.setWidths(new float[] {10, 1});
headerTable.addCell(cellMountain);
headerTable.addCell(cellMountainIcon);
headerTable.addCell(cellHeight);
headerTable.addCell(cellHeightIcon);
headerTable.addCell(cellCoordinates);
headerTable.addCell(cellCoordinatesIcon);
PdfPCell cell = new PdfPCell(headerTable);
cell.setBorder(0);
cell.setPaddingTop(10);
cell.setPaddingBottom(10);
cell.setPaddingRight(10);
cell.setHorizontalAlignment(Element.ALIGN_RIGHT);
cell.setVerticalAlignment(Element.ALIGN_CENTER);
cell.setColspan(5);
cell.setBackgroundColor(backgroundColor);
return cell;
}
示例10: addSpace
import com.itextpdf.text.pdf.PdfPCell; //导入方法依赖的package包/类
private void addSpace(PdfPTable table) {
PdfPCell cell = new PdfPCell();
cell.setFixedHeight(15f);
cell.setBorder(PdfPCell.NO_BORDER);
table.addCell(cell);
}
示例11: createBlueBlock
import com.itextpdf.text.pdf.PdfPCell; //导入方法依赖的package包/类
private void createBlueBlock(PdfContentByte cb, int treeCount) throws DocumentException {
cb.saveState();
cb.setRGBColorFill(0x64, 0xA7, 0xBD);
cb.rectangle(0.0f, 375.0f, 595.0f, 200.0f);
cb.fill();
cb.stroke();
cb.restoreState();
Font textFont = new Font(FontFamily.TIMES_ROMAN, 14, Font.ITALIC, BaseColor.WHITE);
Font textBlack = new Font(FontFamily.TIMES_ROMAN, 14, Font.ITALIC, BaseColor.BLACK);
Font textFontTreeCount = new Font(FontFamily.HELVETICA, 30, Font.BOLD, BaseColor.BLACK);
PdfPTable tableForTreeCount = new PdfPTable(1);
float[] rows = { 495f };
tableForTreeCount.setTotalWidth(rows);
tableForTreeCount.getDefaultCell().setBorder(Rectangle.NO_BORDER);
tableForTreeCount.getDefaultCell().setVerticalAlignment(Element.ALIGN_MIDDLE);
tableForTreeCount.getDefaultCell().setHorizontalAlignment(Element.ALIGN_CENTER);
tableForTreeCount.getDefaultCell().setFixedHeight(40);
Integer treeCountAsObject = treeCount;
tableForTreeCount.addCell(new Phrase(new Chunk(treeCountAsObject.toString(), textFontTreeCount)));
tableForTreeCount.writeSelectedRows(0, 1, 50f, 575f, cb);
PdfPTable tableForWhiteText = new PdfPTable(1);
tableForWhiteText.setTotalWidth(rows);
tableForWhiteText.getDefaultCell().setBorder(Rectangle.BOTTOM);
tableForWhiteText.getDefaultCell().setBorderWidth(1f);
tableForWhiteText.getDefaultCell().setBorderColor(BaseColor.WHITE);
tableForWhiteText.getDefaultCell().setVerticalAlignment(Element.ALIGN_MIDDLE);
tableForWhiteText.getDefaultCell().setHorizontalAlignment(Element.ALIGN_CENTER);
tableForWhiteText.getDefaultCell().setFixedHeight(40);
Phrase phraseForTreesPlantForYou = new Phrase();
if (treeCount == 1) {
phraseForTreesPlantForYou.add(new Chunk("Baum wurde für Sie gepflanzt!", textFont));
} else {
phraseForTreesPlantForYou.add(new Chunk("Bäume wurden für Sie gepflanzt!", textFont));
}
PdfPCell longTextCell = new PdfPCell();
longTextCell.setHorizontalAlignment(Element.ALIGN_LEFT);
longTextCell.setVerticalAlignment(Element.ALIGN_MIDDLE);
longTextCell.setBorder(Rectangle.BOTTOM);
longTextCell.setBorderWidth(1f);
longTextCell.setBorderColor(BaseColor.WHITE);
longTextCell.setFixedHeight(65);
Paragraph longText = new Paragraph(new Chunk(
"Mit diesem Gutschein können sie Ihre Pflanzung in Augenschein nehmen und mehr über die naturnahen Aufforstungsprojekte bei \"I Plant A Tree\" erfahren. Ihre Bäume wachsen auf ehemals brachliegenden Flächen und sind Teil neu entstehender Wälder.",
textFont));
longText.setLeading(15f);
longTextCell.addElement(longText);
tableForWhiteText.addCell(phraseForTreesPlantForYou);
tableForWhiteText.addCell(longTextCell);
tableForWhiteText.writeSelectedRows(0, 2, 50f, 535f, cb);
PdfPTable tableForHowItWorks = new PdfPTable(1);
tableForHowItWorks.setTotalWidth(rows);
tableForHowItWorks.getDefaultCell().setBorder(Rectangle.NO_BORDER);
tableForHowItWorks.getDefaultCell().setVerticalAlignment(Element.ALIGN_MIDDLE);
tableForHowItWorks.getDefaultCell().setHorizontalAlignment(Element.ALIGN_CENTER);
tableForHowItWorks.getDefaultCell().setFixedHeight(40);
tableForHowItWorks.addCell(new Phrase(new Chunk("Und so einfach funktioniert's:", textBlack)));
tableForHowItWorks.writeSelectedRows(0, 2, 50f, 425f, cb);
}
示例12: addCell
import com.itextpdf.text.pdf.PdfPCell; //导入方法依赖的package包/类
/**
* adds new cell to table
* @param table table to work with
* @param text content of cell
* @param fontSize font fontSize
* @param alignment enum alignment
* @param rowFixedHeight cell fixed height
* @return added cell
*/
private static PdfPCell addCell(PdfPTable table, String text, int fontSize, int alignment, float rowFixedHeight) {
Phrase ph = new Phrase(text, getFont(fontSize));
PdfPCell cell = new PdfPCell(ph);
cell.setHorizontalAlignment(alignment);
if (rowFixedHeight > 0) cell.setFixedHeight(rowFixedHeight);
table.addCell(cell);
return cell;
}