开发者

iText: PdfSpotColor with PdfTable

We are using PdfTable to layout text on a PDF document using iText. We would like to express the colors of the fonts 开发者_StackOverflow社区as Pantone values. According to the documentation, you have to use PdfSpotColor to specify Pantone colors. The problem is that I have not found a way to set the font color of piece of text inside a table as a PdfSpotColor.

Is it at all to possible to set the font color as a PdfSpotColor?


PdfSpotColor extends basecolor so you can just use PdfSpotColor.


If i understand your question correctly, you need to apply a color to a text inside a cell. Why don't you use java.awt.Color library ?

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

you can convert pantone colors to rgb from this site:

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

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

Now you can apply this color to the cell in the Pdfptable like this:

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

Hope this helps. :)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜