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

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

本文整理了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

  1. private PdfPCell buildPdfPCell(HeaderFooter phf,String text,int type){
  2. PdfPCell cell=new PdfPCell();
  3. cell.setPadding(0);
  4. cell.setBorder(Rectangle.NO_BORDER);
  5. Font font=FontBuilder.getFont(phf.getFontFamily(), phf.getFontSize(), phf.isBold(), phf.isItalic(),phf.isUnderline());
  6. String fontColor=phf.getForecolor();
  7. if(StringUtils.isNotEmpty(fontColor)){
  8. String[] color=fontColor.split(",");
  9. font.setColor(Integer.valueOf(color[0]), Integer.valueOf(color[1]), Integer.valueOf(color[2]));
  10. }
  11. Paragraph graph=new Paragraph(text,font);
  12. cell.setPhrase(graph);
  13. switch(type){
  14. case 1:
  15. cell.setHorizontalAlignment(Element.ALIGN_LEFT);
  16. break;
  17. case 2:
  18. cell.setHorizontalAlignment(Element.ALIGN_CENTER);
  19. break;
  20. case 3:
  21. cell.setHorizontalAlignment(Element.ALIGN_RIGHT);
  22. break;
  23. }
  24. cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
  25. return cell;
  26. }
  27. }

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

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

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

  1. @Override
  2. public Font getFont(final String fontname, final String encoding,
  3. final boolean embedded, final float size, final int style,
  4. final BaseColor color) {
  5. try {
  6. BaseFont bf = BaseFont.createFont("STSong-Light", "UniGB-UCS2-H",
  7. BaseFont.NOT_EMBEDDED);
  8. Font font = new Font(bf, size, style, color);
  9. font.setColor(color);
  10. return font;
  11. } catch (DocumentException e) {
  12. e.printStackTrace();
  13. } catch (IOException e) {
  14. e.printStackTrace();
  15. }
  16. return super.getFont(fontname, encoding, embedded, size, style, color);
  17. }
  18. }

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

  1. private PdfPCell buildPdfPCell(HeaderFooter phf,String text,int type){
  2. PdfPCell cell=new PdfPCell();
  3. cell.setPadding(0);
  4. cell.setBorder(Rectangle.NO_BORDER);
  5. Font font=FontBuilder.getFont(phf.getFontFamily(), phf.getFontSize(), phf.isBold(), phf.isItalic(),phf.isUnderline());
  6. String fontColor=phf.getForecolor();
  7. if(StringUtils.isNotEmpty(fontColor)){
  8. String[] color=fontColor.split(",");
  9. font.setColor(Integer.valueOf(color[0]), Integer.valueOf(color[1]), Integer.valueOf(color[2]));
  10. }
  11. Paragraph graph=new Paragraph(text,font);
  12. cell.setPhrase(graph);
  13. switch(type){
  14. case 1:
  15. cell.setHorizontalAlignment(Element.ALIGN_LEFT);
  16. break;
  17. case 2:
  18. cell.setHorizontalAlignment(Element.ALIGN_CENTER);
  19. break;
  20. case 3:
  21. cell.setHorizontalAlignment(Element.ALIGN_RIGHT);
  22. break;
  23. }
  24. cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
  25. return cell;
  26. }
  27. }

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

  1. /**
  2. * <p>
  3. * Description: 内容索引创建
  4. * </p>
  5. *
  6. * @throws DocumentException
  7. */
  8. protected void toCreateContentIndexes(PdfWriter writer, Document document, List<ExcelObject> objects)
  9. throws DocumentException {
  10. PdfPTable table = new PdfPTable(1);
  11. table.setKeepTogether(true);
  12. table.getDefaultCell().setBorder(PdfPCell.NO_BORDER);
  13. //
  14. Font font = new Font(Resource.BASE_FONT_CHINESE, 12, Font.NORMAL);
  15. font.setColor(new BaseColor(0, 0, 255));
  16. //
  17. for (int i = 0; i < objects.size(); i++) {
  18. ExcelObject o = objects.get(i);
  19. String text = o.getAnchorName();
  20. Anchor anchor = new Anchor(text, font);
  21. anchor.setReference("#" + o.getAnchorName());
  22. //
  23. PdfPCell cell = new PdfPCell(anchor);
  24. cell.setBorder(0);
  25. //
  26. table.addCell(cell);
  27. }
  28. //
  29. document.add(table);
  30. }

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

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

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

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

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

  1. font.setColor(BaseColor.WHITE);

相关文章