How to set custom color in itext?

Thank you for taking the time to answer my question.

I am creating a PDF using iText in Java. I need to set table column headers of a different color than value columns. I have a hexadecimal color value from Photoshop. I use PdfPTable with chunks and paragraphs. How can I set them to a different color than the ones that are predefined in the BaseColor enumeration?

Thanks in advance!

+6
source share
2 answers

You need to take an 8-bit hexadecimal color value and convert it to 8-bit RGB values.

How to convert hex to rgb using Java?

Then you can create a new BaseColor with your RGB values.

cell.setBackgroundColor(new BaseColor(255, 0, 0)); 
+10
source

Take a look at this site . Despite the fact that in C # there are only Java codes. Let me know if you find it or not. I created a successful PDF system by looking at these examples.

-3
source

Source: https://habr.com/ru/post/919983/


All Articles