itext positioning text absolutely

前端 未结 5 1361
温柔的废话
温柔的废话 2020-12-03 17:00

In itext I have a chunk/phrase/paragraph (I dont mind which) and I want to position some where else on the page e.g. at 300 x 200. How would I do this?

5条回答
  •  自闭症患者
    2020-12-03 17:53

    In the end I wrote my own method to do it.

    private void PlaceChunck(String text, int x, int y) {
            PdfContentByte cb = writer.DirectContent;
            BaseFont bf = BaseFont.CreateFont(BaseFont.HELVETICA, BaseFont.CP1252, BaseFont.NOT_EMBEDDED);
            cb.SaveState();
            cb.BeginText();
            cb.MoveText(x, y);
            cb.SetFontAndSize(bf, 12);
            cb.ShowText(text);
            cb.EndText();
            cb.RestoreState();
        }
    

提交回复
热议问题