I understand that your work-around is possible (setting padding manuall). I still feel like the functionality ought to be that the text by default in raised a bit to fit inside the cell, rather than have parts of the text sink through the bottom.
I attached an image of the PDF based on the sample code. Again, looking at the "g" in the word "Testing", and the (default) space above the word "Testing" in the largest font example, I think you can see what I mean.
(This sample is using the 1.00 jar by the way)
Thanks again Fred
You can set the padding individually for each border (top, bottom, left,
right).
While not really noticable at smaller font sizes, it appears that PdfPCell is placing it's phrase in such a way that roughly the baseline of the bottom is at the bottom of the cell, causing the lower part of of
characters that drop below the line (e.g. pyj,qg) to cross over the bottom border of the cell. See, for example, the letter "g" in the word "Testing" as the font size increases in this example:
PdfPTable ptable = new PdfPTable(1); ptable.getDefaultCell().setBorderColor(Color.RED); ptable.getDefaultCell().setBorder(Rectangle.BOX); ptable.getDefaultCell().setBorderWidth(.1f);
ptable.addCell(new Phrase("Testing", FontFactory.getFont(FontFactory.COURIER, 7f))); ptable.addCell(new Phrase("Testing", FontFactory.getFont(FontFactory.COURIER, 10f))); ptable.addCell(new Phrase("Testing", FontFactory.getFont(FontFactory.COURIER, 20f))); ptable.addCell(new Phrase("Testing", FontFactory.getFont(FontFactory.COURIER, 30f))); ptable.addCell(new Phrase("Testing", FontFactory.getFont(FontFactory.COURIER, 40f)));
document.add(ptable);
In examples/Chap0518.java it appears that a small font size and datatable.getDefaultCell().setPadding(3) are used. Certainly a padding can be used to prevent the lower part of the letters dropping through the bottom of the cell, but one must (re)adjust the padding based on the
font size, and as the font size increases, the amount of 'extra' padding
between the top of the phrase and the top border of the cell increases.
If this is not by design, could you point me to the section of code I can look at to fix this?
Keep up the good work, and thanks for the quick responses!
Fred
<<inline: sample.png>>