com.itextpdf.text.Font.setColor()方法的使用及代码示例

x33g5p2x  于2022-01-19 转载在 其他  
字(3.6k)|赞(0)|评价(0)|浏览(118)

本文整理了Java中com.itextpdf.text.Font.setColor()方法的一些代码示例,展示了Font.setColor()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Font.setColor()方法的具体详情如下:
包路径:com.itextpdf.text.Font
类名称:Font
方法名:setColor

Font.setColor介绍

[英]Sets the color.
[中]

代码示例

代码示例来源:origin: youseries/ureport

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;
  }
}

代码示例来源:origin: youseries/ureport

font.setColor(Integer.valueOf(color[0]), Integer.valueOf(color[1]), Integer.valueOf(color[2]));

代码示例来源:origin: net.oschina.durcframework/easyopen

@Override
  public Font getFont(final String fontname, final String encoding,
            final boolean embedded, final float size, final int style,
            final BaseColor color) {
    try {
      BaseFont bf = BaseFont.createFont("STSong-Light", "UniGB-UCS2-H",
          BaseFont.NOT_EMBEDDED);
      Font font = new Font(bf, size, style, color);
      font.setColor(color);
      return font;
    } catch (DocumentException e) {
      e.printStackTrace();
    } catch (IOException e) {
      e.printStackTrace();
    }
    return super.getFont(fontname, encoding, embedded, size, style, color);
  }
}

代码示例来源:origin: com.bstek.ureport/ureport2-core

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;
  }
}

代码示例来源:origin: caryyu/excel2pdf

/**
 * <p>
 * Description: 内容索引创建
 * </p>
 * 
 * @throws DocumentException
 */
protected void toCreateContentIndexes(PdfWriter writer, Document document, List<ExcelObject> objects)
    throws DocumentException {
  PdfPTable table = new PdfPTable(1);
  table.setKeepTogether(true);
  table.getDefaultCell().setBorder(PdfPCell.NO_BORDER);
  //
  Font font = new Font(Resource.BASE_FONT_CHINESE, 12, Font.NORMAL);
  font.setColor(new BaseColor(0, 0, 255));
  //
  for (int i = 0; i < objects.size(); i++) {
    ExcelObject o = objects.get(i);
    String text = o.getAnchorName();
    Anchor anchor = new Anchor(text, font);
    anchor.setReference("#" + o.getAnchorName());
    //
    PdfPCell cell = new PdfPCell(anchor);
    cell.setBorder(0);
    //
    table.addCell(cell);
  }
  //
  document.add(table);
}

代码示例来源:origin: com.bstek.ureport/ureport2-core

font.setColor(Integer.valueOf(color[0]), Integer.valueOf(color[1]), Integer.valueOf(color[2]));

代码示例来源:origin: caryyu/excel2pdf

if (color != null) {
  int rbg = POIUtil.getRGB(color);
  result.setColor(new BaseColor(rbg));

代码示例来源:origin: aboullaite/SpringBoot-Excel-Csv

font.setColor(BaseColor.WHITE);

相关文章