Itext7 - Place Text at specific position

与世无争的帅哥 提交于 2019-12-25 11:40:28

问题


ColumnText ct = new ColumnText(writer.getDirectContent());
ct.setSimpleColumn(left,bottom,right,top);
ct.setText(new Phrase("String"));
ct.go();

This how we were doing in Itext 5 . But how can we place text on specific position on page . I have multiple text to place on page along with images .

Thanks


回答1:


Try this:

Paragraph p = new Paragraph("test");
p.setFixedPosition(100, 800, 200);
document.add(p);

It should be that simple.

In this example, x = 100, y = 800, and 200 is the width.

For an example, see https://developers.itextpdf.com/content/itext-7-building-blocks/examples/chapter-6#2574-c06e08_explicitdestinations.java



来源:https://stackoverflow.com/questions/46119704/itext7-place-text-at-specific-position

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!