Reputation: 10267
I've got this iTextSharp code to give a cell on a PDF file a green background:
PdfPCell cellSec2 = new PdfPCell(parSectionHeading2);
cellSec2.BackgroundColor = BaseColor.GREEN;
The problem is that "BaseColor.GREEN" is too dark/intense. I need more of a verdigris color - light green, or pale green. Is it possible to assign RGB (or RGBA) values or some such to the BackgroundColor property?
Bruno's answer plus this site, and you've got what you need. I needed:
var lightGreen = new BaseColor(204, 255, 204);
cellSec2.BackgroundColor = lightGreen;
Upvotes: 1
Views: 976
Reputation: 77528
We have plenty of documentation on all things iText. For instance: chapter 10 of my book is about images and color. If you don't own a copy of the book, why don't you take a look at the examples of chapter 10?
Take for instance DeviceColor.cs where you have plenty of examples of other colors such as:
new GrayColor(0x20) // Gray value
new BaseColor(0f, 1f, 1f) // RGB
new CMYKColor(0x00, 0x00, 0xFF, 0xFF) // CMYK
The values for R, G and B, or for C, M, Y and K, can either be floats between 0 and 1 or integers between 0 and 255.
Upvotes: 2