如何使用iText设置表格单元格的背景颜色? [英] How to set a background color of a Table Cell using iText?

查看:762
本文介绍了如何使用iText设置表格单元格的背景颜色?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

虽然当然可以使用 BaseColor ,但默认情况下,它提供的选择非常有限。

While it is of course possible to use BaseColor, by default, it offers very limited choices.

我想知道如何将自己的自定义颜色添加到文档中?

I wonder how can i add my own custom color to the document?

...
        PdfPTable table = new PdfPTable(3);

        PdfPCell cell = new PdfPCell(new Phrase("some clever text"));
        cell.setBackgroundColor(BaseColor.GREEN);
        table.addCell(cell);
...


推荐答案

许多选项。

BaseColor color = new BaseColor(red, green, blue); // or red, green, blue, alpha
CYMKColor cmyk = new CMYKColor(cyan, yellow, magenta, black); // no alpha
GrayColor gray = new GrayColor(someFloatBetweenZeroAndOneInclusive); // no alpha

还有图案颜色和阴影颜色,但这些颜色要简单得多。

There's also pattern colors and shading colors, but those are Much Less Simple.

这篇关于如何使用iText设置表格单元格的背景颜色?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆