开发者

Creating angled column headings using iText

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 cons开发者_运维问答tructor 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?


Have you tried rotation property of PdfPCell?

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


PdfPCell rotation only allows a multiple of 90.

You have to skew your text.

Chunk chn = new Chunk("Hello World");
chn.SetSkew(0f, 45f);

http://www.roseindia.net/Java/itext/Skewing.shtml

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜