itext7-将文本放在特定位置 [英] Itext7 - Place Text at specific position
本文介绍了itext7-将文本放在特定位置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
ColumnText ct = new ColumnText(writer.getDirectContent());
ct.setSimpleColumn(left,bottom,right,top);
ct.setText(new Phrase("String"));
ct.go();
这就是我们在Itext 5中所做的事情.但是我们如何将文本放在页面上的特定位置.我在图像上有多个文本要放在页面上.
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 .
谢谢
推荐答案
尝试一下:
Paragraph p = new Paragraph("test");
p.setFixedPosition(100, 800, 200);
document.add(p);
应该就是这么简单.
在此示例中,x = 100,y = 800,宽度为200.
In this example, x = 100, y = 800, and 200 is the width.
有关示例,请参见 查看全文