本文整理汇总了Java中com.itextpdf.text.pdf.PdfPCell.setHorizontalAlignment方法的典型用法代码示例。如果您正苦于以下问题:Java PdfPCell.setHorizontalAlignment方法的具体用法?Java PdfPCell.setHorizontalAlignment怎么用?Java PdfPCell.setHorizontalAlignment使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.itextpdf.text.pdf.PdfPCell
的用法示例。
在下文中一共展示了PdfPCell.setHorizontalAlignment方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getFillCell
import com.itextpdf.text.pdf.PdfPCell; //导入方法依赖的package包/类
public PdfPCell getFillCell(){
PdfPCell fillCell = new PdfPCell();
fillCell.setBorderWidth( 0f );
fillCell.setLeft(0);
fillCell.setTop(0);
fillCell.setRight( 0 );
fillCell.setBottom( 0 );
fillCell.setUseAscender( true );
fillCell.setIndent(0);
fillCell.setHorizontalAlignment( Element.ALIGN_LEFT );
fillCell.setVerticalAlignment( Element.ALIGN_BOTTOM );
fillCell.setPaddingLeft( 0f);
fillCell.setPaddingBottom(0f);
fillCell.setPaddingRight(0f );
fillCell.setPaddingTop( 0f );
fillCell.setBorder( 0 );
renderEmptyCell(fillCell);
return fillCell;
}
示例2: cellRodape
import com.itextpdf.text.pdf.PdfPCell; //导入方法依赖的package包/类
private PdfPTable cellRodape(String value, boolean l,boolean r,int align)
{
Font fontCorpoTableO= FontFactory.getFont(Fontes.FONT, BaseFont.WINANSI, BaseFont.EMBEDDED ,7.5f);
PdfPTable pTable = new PdfPTable(1);
pTable.setWidthPercentage(100f);
PdfPCell cellValue = new PdfPCell(new Phrase(value,fontCorpoTableO));
if(l){cellValue.setBorderWidthLeft(0);}
if(r){cellValue.setBorderWidthRight(0);}
switch (align)
{
case Element.ALIGN_RIGHT:cellValue.setHorizontalAlignment(Element.ALIGN_RIGHT);break;
case Element.ALIGN_LEFT:cellValue.setHorizontalAlignment(Element.ALIGN_LEFT);break;
case Element.ALIGN_CENTER:cellValue.setHorizontalAlignment(Element.ALIGN_CENTER);break;
default:break;
}
pTable.addCell(cellValue);
return pTable;
}
示例3: generatePage
import com.itextpdf.text.pdf.PdfPCell; //导入方法依赖的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;
}
示例4: buildPdfPCell
import com.itextpdf.text.pdf.PdfPCell; //导入方法依赖的package包/类
private PdfPCell buildPdfPCell(HeaderFooter phf,String text,int type){
PdfPCell cell=new PdfPCell();
cell.setPadding(0);
cell.setBorder(Rectangle.NO_BORDER);
Font font=FontBuilder.getFont(phf.getFontFamily(), phf.getFontSize(), phf.isBold(), phf.isItalic(),phf.isUnderline());
String fontColor=phf.getForecolor();
if(StringUtils.isNotEmpty(fontColor)){
String[] color=fontColor.split(",");
font.setColor(Integer.valueOf(color[0]), Integer.valueOf(color[1]), Integer.valueOf(color[2]));
}
Paragraph graph=new Paragraph(text,font);
cell.setPhrase(graph);
switch(type){
case 1:
cell.setHorizontalAlignment(Element.ALIGN_LEFT);
break;
case 2:
cell.setHorizontalAlignment(Element.ALIGN_CENTER);
break;
case 3:
cell.setHorizontalAlignment(Element.ALIGN_RIGHT);
break;
}
cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
return cell;
}
示例5: createGridColumnHeader
import com.itextpdf.text.pdf.PdfPCell; //导入方法依赖的package包/类
private void createGridColumnHeader(PdfPTable table, Collection<ColumnHeader> topHeaders, int maxHeaderLevel) throws Exception {
for (int i = 1; i < 50; i++) {
List<ColumnHeader> result = new ArrayList<ColumnHeader>();
generateGridHeadersByLevel(topHeaders, i, result);
for (ColumnHeader header : result) {
PdfPCell cell = new PdfPCell(createParagraph(header));
if (header.getBgColor() != null) {
int[] colors = header.getBgColor();
cell.setBackgroundColor(new BaseColor(colors[0], colors[1], colors[2]));
}
cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
cell.setHorizontalAlignment(header.getAlign());
cell.setColspan(header.getColspan());
if (header.getColumnHeaders().size() == 0) {
int rowspan = maxHeaderLevel - (header.getLevel() - 1);
if (rowspan > 0) {
cell.setRowspan(rowspan);
}
}
table.addCell(cell);
}
}
}
示例6: 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;
}
示例7: createGridTableDatas
import com.itextpdf.text.pdf.PdfPCell; //导入方法依赖的package包/类
private void createGridTableDatas(PdfPTable table, Collection<ReportData> datas) {
for (ReportData data : datas) {
PdfPCell cell = new PdfPCell(createParagraph(data.getTextChunk()));
cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
int level = this.calculateIndentationCount(data.getTextChunk().getText());
if (data.getBgColor() != null) {
int[] colors = data.getBgColor();
cell.setBackgroundColor(new BaseColor(colors[0], colors[1], colors[2]));
}
if (level == 0) {
cell.setHorizontalAlignment(data.getAlign());
} else {
cell.setIndent(20 * level);
}
table.addCell(cell);
}
}
示例8: createCell
import com.itextpdf.text.pdf.PdfPCell; //导入方法依赖的package包/类
public PdfPCell createCell(String value, Font font, int align, int colspan, boolean boderFlag) {
PdfPCell cell = new PdfPCell();
cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
cell.setHorizontalAlignment(align);
cell.setColspan(colspan);
cell.setPhrase(new Phrase(value, font));
cell.setPadding(3.0f);
if (!boderFlag) {
cell.setBorder(0);
cell.setPaddingTop(15.0f);
cell.setPaddingBottom(8.0f);
}
return cell;
}
示例9: onEndPage
import com.itextpdf.text.pdf.PdfPCell; //导入方法依赖的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);
}
}
示例10: addCellToTableCzech
import com.itextpdf.text.pdf.PdfPCell; //导入方法依赖的package包/类
/**
* <a href="http://stackoverflow.com/questions/44005834/changing-rowspans">
* Changing rowspans
* </a>
* <p>
* Helper method of the OP.
* </p>
* @see #testUseRowspanLikeUser7968180()
* @see #testUseRowspanLikeUser7968180Fixed()
* @see #createPdf(String)
* @see #createPdfFixed(String)
*/
private static void addCellToTableCzech(PdfPTable table, int horizontalAlignment,
int verticalAlignment, String value, int colspan, int rowspan,
String fontType, float fontSize) {
BaseFont base = null;
try {
base = BaseFont.createFont(fontType, BaseFont.CP1250, BaseFont.EMBEDDED);
} catch (Exception e) {
e.printStackTrace();
}
Font font = new Font(base, fontSize);
PdfPCell cell = new PdfPCell(new Phrase(value, font));
cell.setColspan(colspan);
cell.setRowspan(rowspan);
cell.setHorizontalAlignment(horizontalAlignment);
cell.setVerticalAlignment(verticalAlignment);
cell.setBorder(PdfPCell.NO_BORDER);
table.addCell(cell);
}
示例11: generateSectionTitle
import com.itextpdf.text.pdf.PdfPCell; //导入方法依赖的package包/类
private void generateSectionTitle(PdfPTable table, Data data) throws IOException, DocumentException {
if (!this.currentSection.equals(data.mountains)) {
currentSection = data.mountains;
currentBackgroundColor = backgroundColorGenerator.generate(data);
PdfPCell cellSeparator = new PdfPCell(PhraseUtil.phrase(" "));
cellSeparator.setBorder(0);
cellSeparator.setPadding(10);
cellSeparator.setColspan(4);
table.addCell(cellSeparator);
PdfPCell cell = new PdfPCell(PhraseUtil.phrase(currentSection, 14, Font.BOLD));
cell.setBorder(0);
cell.setPadding(10);
cell.setHorizontalAlignment(Element.ALIGN_LEFT);
cell.setColspan(4);
cell.setBackgroundColor(currentBackgroundColor);
table.addCell(cell);
}
}
示例12: tableWithPageNumber
import com.itextpdf.text.pdf.PdfPCell; //导入方法依赖的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;
}
示例13: generateFooter
import com.itextpdf.text.pdf.PdfPCell; //导入方法依赖的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;
}
示例14: createDateTable
import com.itextpdf.text.pdf.PdfPCell; //导入方法依赖的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;
}
示例15: addFooter
import com.itextpdf.text.pdf.PdfPCell; //导入方法依赖的package包/类
/**
* Adds the footer style row for the field to the PDF table.
*
* @param table
* the table.
* @param font
* the font to use.
* @param name
* the field name.
* @param value
* the field value.
*/
private static void addFooter(PdfPTable table, Font font, String name,
Integer value) {
PdfPCell emptyCell = new PdfPCell();
emptyCell.setBorder(ReportServiceHelper.PDF_NO_BORDER);
table.addCell(emptyCell);
PdfPCell footerNameCell = new PdfPCell();
footerNameCell.setBorderColorTop(BaseColor.BLACK);
footerNameCell
.setHorizontalAlignment(ReportServiceHelper.PDF_ALIGN_LEFT);
footerNameCell.addElement(new com.itextpdf.text.Phrase(name, font));
footerNameCell.setBorder(ReportServiceHelper.PDF_BORDER_TOP);
table.addCell(footerNameCell);
PdfPCell footerValueCell = new PdfPCell();
footerValueCell.setBorderColorTop(BaseColor.BLACK);
if (value != null) {
com.itextpdf.text.Paragraph p = new com.itextpdf.text.Paragraph(
value.toString(), font);
p.setAlignment(ReportServiceHelper.PDF_ALIGN_RIGHT);
footerValueCell.addElement(p);
}
footerValueCell.setBorder(ReportServiceHelper.PDF_BORDER_TOP);
table.addCell(footerValueCell);
}
开发者ID:NASA-Tournament-Lab,项目名称:CoECI-OPM-Service-Credit-Redeposit-Deposit-Application,代码行数:38,代码来源:AccountTypeTotalsReportService.java