本文整理汇总了Java中com.itextpdf.text.pdf.PdfPCell.setPhrase方法的典型用法代码示例。如果您正苦于以下问题:Java PdfPCell.setPhrase方法的具体用法?Java PdfPCell.setPhrase怎么用?Java PdfPCell.setPhrase使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.itextpdf.text.pdf.PdfPCell
的用法示例。
在下文中一共展示了PdfPCell.setPhrase方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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;
}
示例2: 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;
}
示例3: buildPdfDocument
import com.itextpdf.text.pdf.PdfPCell; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
@Override
protected void buildPdfDocument(Map<String, Object> model, Document doc,
PdfWriter writer, HttpServletRequest request, HttpServletResponse response)
throws Exception {
// get data model which is passed by the Spring container
List<HrmsLogin> users = (List<HrmsLogin>) model.get("allUsers");
doc.add(new Paragraph("Master List of Users"));
PdfPTable table = new PdfPTable(4);
table.setWidthPercentage(100.0f);
table.setWidths(new float[] {3.0f, 2.0f, 2.0f, 2.0f});
table.setSpacingBefore(10);
// define font for table header row
Font font = FontFactory.getFont(FontFactory.HELVETICA);
font.setColor(BaseColor.WHITE);
// define table header cell
PdfPCell cell = new PdfPCell();
cell.setBackgroundColor(BaseColor.BLUE);
cell.setPadding(5);
// write table header
cell.setPhrase(new Phrase("Employee ID", font));
table.addCell(cell);
cell.setPhrase(new Phrase("Username", font));
table.addCell(cell);
cell.setPhrase(new Phrase("Password", font));
table.addCell(cell);
cell.setPhrase(new Phrase("Role", font));
table.addCell(cell);
// write table row data
for (HrmsLogin user : users) {
table.addCell(user.getHrmsEmployeeDetails().getEmpId()+"");
table.addCell(user.getUsername());
table.addCell(user.getPassword());
table.addCell(user.getRole());
}
doc.add(table);
}
示例4: getTable
import com.itextpdf.text.pdf.PdfPCell; //导入方法依赖的package包/类
public static PdfPTable getTable(String dbTable, BaseFont bf)
throws SQLException, DocumentException, IOException {
PdfPTable table = new PdfPTable(new float[] { 1, 2, 2, 3, 2 });
table.setWidthPercentage(100f);
table.getDefaultCell().setPadding(10);
table.getDefaultCell().setUseAscender(true);
table.getDefaultCell().setUseDescender(true);
table.getDefaultCell().setColspan(5);
table.getDefaultCell().setBackgroundColor(BaseColor.ORANGE);
table.getDefaultCell().setHorizontalAlignment(Element.ALIGN_CENTER);
table.addCell(new Phrase(Util.tablenameToDate(dbTable), new Font(bf, 16, Font.NORMAL, BaseColor.DARK_GRAY)));
table.getDefaultCell().setPadding(3);
table.getDefaultCell().setColspan(1);
table.getDefaultCell().setBackgroundColor(BaseColor.GRAY);
Font titleFont = new Font(bf, 13, Font.NORMAL, BaseColor.WHITE);
table.addCell(new Phrase("Α/Α", titleFont));
table.addCell(new Phrase("Ημερομηνία", titleFont));
table.addCell(new Phrase("Τιμή", titleFont));
table.addCell(new Phrase("ΑΦΜ", titleFont));
table.addCell(new Phrase("Όνομα", titleFont));
table.getDefaultCell().setBackgroundColor(null);
String data[][] = null;
data = Util.arrayFromTablename(dbTable);
int rows = data.length;
float sum = 0;
for (int i=0; i<rows; i++) {
table.getDefaultCell().setHorizontalAlignment(Element.ALIGN_CENTER);
table.addCell(i + "");
table.addCell(data[i][0]);
table.getDefaultCell().setHorizontalAlignment(Element.ALIGN_RIGHT);
table.addCell(data[i][1] + "€");
table.getDefaultCell().setHorizontalAlignment(Element.ALIGN_CENTER);
table.addCell(data[i][2]);
table.addCell(data[i][3]);
sum += Float.parseFloat(data[i][1]);
}
if (rows > 0) {
PdfPCell cell = new PdfPCell();
cell.setPadding(7);
cell.setHorizontalAlignment(Element.ALIGN_CENTER);
cell.setBackgroundColor(BaseColor.WHITE);
cell.setBorderColor(BaseColor.WHITE);
cell.disableBorderSide(Rectangle.TOP | Rectangle.RIGHT);
cell.setPhrase(new Phrase(""));
table.addCell(cell);
cell.setBorderColor(BaseColor.BLACK);
cell.setBackgroundColor(BaseColor.GRAY);
cell.setPhrase(new Phrase("Σύνολο", titleFont));
cell.enableBorderSide(Rectangle.RIGHT);
table.addCell(cell);
String sumS = Util.formatSum(sum);
cell.setBackgroundColor(BaseColor.ORANGE);
cell.setPhrase(new Phrase(sumS));
cell.setHorizontalAlignment(Element.ALIGN_RIGHT);
table.addCell(cell);
cell.setBorderColor(BaseColor.WHITE);
cell.setBackgroundColor(BaseColor.WHITE);
cell.disableBorderSide(Rectangle.LEFT);
cell.setPhrase(new Phrase(""));
table.addCell(cell);
table.addCell(cell);
}
return table;
}
示例5: buildPdfDocument
import com.itextpdf.text.pdf.PdfPCell; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
@Override
protected void buildPdfDocument(Map<String, Object> model, Document doc,
PdfWriter writer, HttpServletRequest request, HttpServletResponse response)
throws Exception {
// get data model which is passed by the Spring container
List<Answer> listAnswers = (List<Answer>) model.get("listAnswers");
doc.add(new Paragraph("Here's your Answers"));
PdfPTable table = new PdfPTable(4);
table.setWidthPercentage(100.0f);
table.setWidths(new float[] {3.0f, 2.0f, 2.0f, 2.0f});
table.setSpacingBefore(10);
// define font for table header row
Font font = FontFactory.getFont(FontFactory.HELVETICA);
font.setColor(BaseColor.WHITE);
// define table header cell
PdfPCell cell = new PdfPCell();
cell.setBackgroundColor(BaseColor.BLUE);
cell.setPadding(5);
// write table header
cell.setPhrase(new Phrase("Answer 1", font));
table.addCell(cell);
cell.setPhrase(new Phrase("Answer 2", font));
table.addCell(cell);
cell.setPhrase(new Phrase("Answer 3", font));
table.addCell(cell);
cell.setPhrase(new Phrase("Published Date", font));
table.addCell(cell);
// write table row data
for (Answer answer : listAnswers) {
table.addCell(answer.getAnswer1());
table.addCell(answer.getAnswer2());
table.addCell(answer.getAnswer3());
table.addCell(answer.getAnsweredDate());
//table.addCell(String.valueOf(answer.getPrice()));
}
doc.add(table);
}