【问题标题】:Itext7 - Place Text at specific positionItext7 - 将文本放置在特定位置
【发布时间】:2018-02-17 13:41:38
【问题描述】:
ColumnText ct = new ColumnText(writer.getDirectContent());
ct.setSimpleColumn(left,bottom,right,top);
ct.setText(new Phrase("String"));
ct.go();

这就是我们在 Itext 5 中的做法。但是我们如何才能将文本放置在页面上的特定位置。我有多个文本与图像一起放置在页面上。

谢谢

【问题讨论】:

  • 嗯...你为什么不阅读文档?

标签: itext7


【解决方案1】:

试试这个:

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

应该就是这么简单。

在本例中,x = 100,y = 800,200 是宽度。

例如,请参阅https://developers.itextpdf.com/content/itext-7-building-blocks/examples/chapter-6#2574-c06e08_explicitdestinations.java

【讨论】:

  • 以及如何在没有硬编码位置的情况下在本段之后添加其他字段?
猜你喜欢
  • 1970-01-01
  • 2017-04-25
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2016-10-27
  • 2015-08-18
  • 1970-01-01
  • 2020-03-26
相关资源
最近更新 更多