iText:使用PdfpTable的Pdf专色

时间:2011-10-04 06:24:58

标签: java itext pantone

我们正在使用PdfTable使用iText在PDF文档上布局文本。我们想将字体的颜色表示为Pantone值。根据文档,您必须使用PdfSpotColor指定Pantone颜色。问题是我还没有找到一种方法来将表格内的文本字体颜色设置为PdfSpotColor。

是否可以将字体颜色设置为PdfSpotColor?

2 个答案:

答案 0 :(得分:0)

PdfSpotColor扩展了basecolor,因此您只需使用PdfSpotColor。

答案 1 :(得分:-1)

如果我正确理解您的问题,您需要将颜色应用于单元格内的文本。你为什么不用java.awt.Color库?

Color FONT_COLOR = new Color(192, 192, 192);

你可以从这个网站将pantone颜色转换为rgb:

http://goffgrafix.com/pantone-rgb-100.php

Font cellFont;
cellFont = FontFactory.getFont("Arial", 24, Font.NORMAL, FONT_COLOR);

现在您可以将此颜色应用于Pdfptable中的单元格,如下所示:

PdfPTable testTable = new PdfPTable(1);
Phrase title = new Phrase(new Chunk("TEST", cellFont));
PdfPCell testCell = new PdfPCell(title);
testTable.addCell(testCell);

希望这会有所帮助。 :)