views:

205

answers:

1

Does anyone know how to make angled column headings (e.g. at 45 degrees) in a table inside a PDF file, using the iText library?

The best I can do is to use images for the column headings. Each image consists of a column heading rotated by 45 degrees, against a transparent background. For each column heading, I create a PdfPCell containing the appropriate image, with the scale-to-fit parameter in the PdfPCell constructor set to false to force the image to overlap the column headings to the right of it. The transparent backgrounds and consistent rotation of all headings ensures that the headings are all visible even though the images containing them overlap.

This seems like such a kludge.

Does anyone know an easier way to create angled column headings in a PDF using iText?

+1  A: 

Have you tried rotation property of PdfPCell?

PdfPCell cell = new PdfPCell(new Paragraph("my cell text..."));
cell.setRotation(45);
 . . .
myTable.add(cell);
Pier Luigi