开发者

Creating angled column headings using iText

开发者 https://www.devze.com 2022-12-18 23:17 出处:网络
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?

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

精彩评论

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

关注公众号