Tables, Cells, and background colors...
I know you mentioned in my other thread about drawing the rectangle and filling it for the background color, however, my problem is that I don't see a way to discover the 4 corners of the text that I wish to put a color behind. It is dynamic (might be in a different place vertically on the page) and could also be different lengths. It is also contained within a paragraph within a paragraph as in:
| master paragraph |
|| Body Paragraph ||
|| Some addtional ||
|| text content.. ||
And it's part or all of the content in the header paragraph that needs to have a background color to highlight it. It would be easy if there were a "background color" attribute in the Font, but I know there isn't, so, I need to find another way.
Which brings me to tables and cells. I know there is a background color attribute on PdfPCell, so I'm attempting to re-factor a portion of the code to utilize that. However, I can't seem to get the table that contains the cell, that contains the header paragraph to be placed into the master paragraph and show up on the rendered document.
Apparently it is "allowed" to add the table to a paragraph (that is then added as usual to my Column) because I don't get objections from the compiler, or exceptions at runtime. So, I wonder what I'm doing wrong.
Basically, what I'm doing looks something like this:
Paragraph masterParagraph = new Paragraph();
PdfPCell cell = new PdfPCell();
cell.addElement(new Paragraph("Header Text", myFont));
PdfPTable table = new PdfPTable(1);
masterParagraph.add(new Paragraph("body text", myOtherFont));
Of course, the ct.addElement(...) is within my other code that determines if I need a new page, etc... that was discussed in the other thread...
When I do the above, it renders the space for the element, but not the element itself.
Any ideas as to what I might be missing?