Reputation: 2626
In iText PDF we can set background color to a cell like this
PdfPCell cell = buildCell(phrase, displayType, col);
cell.setBackgroundColor(new java.awt.Color(33, 150, 243, 153));
But it turns out that iText ignores the java.awt.Color
opacity.
Is there any way to do this?
Upvotes: 2
Views: 689
Reputation: 95888
Support for transparent cell background colors has been added in iText 5.5.7, more exactly in git commit 09ccaa728830a404e92fc3040dd3626198576fef.
You appear to use an older iText version, though, as indicated by your use of a java.awt.Color
instead of a com.itextpdf.text.BaseColor
.
Depending on the exact version of iText you may try and use a PdfPCellEvent
implementation instead of setting the background color with setBackgroundColor
. In that implementation you'd have to first save the graphics state, then set a PdfGState
with transparency, fill the cell rectangle with the color, and restore the graphics state again.
Upvotes: 2