当前位置: 首页>>代码示例>>Java>>正文


Java PdfPCell.setPhrase方法代码示例

本文整理汇总了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;
}
 
开发者ID:youseries,项目名称:ureport,代码行数:27,代码来源:PageHeaderFooterEvent.java

示例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;
}
 
开发者ID:melonlee,项目名称:PowerApi,代码行数:15,代码来源:PDFTest.java

示例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);
     
}
 
开发者ID:PacktPublishing,项目名称:Spring-MVC-Blueprints,代码行数:52,代码来源:HRPDFBuilderImpl.java

示例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;
}
 
开发者ID:johnmans,项目名称:EnTax,代码行数:75,代码来源:Printer.java

示例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);
        
   }
 
开发者ID:TransformCore,项目名称:BIS-BDT-Citizen,代码行数:50,代码来源:PdfView.java


注:本文中的com.itextpdf.text.pdf.PdfPCell.setPhrase方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。