【发布时间】:2020-01-19 09:16:18
【问题描述】:
正如标题所述,我目前正在努力在 pdf-acro-field 中强制换行("\n" 分别为 "\r\n")。我正在使用 OpenPdf 和 FlyingSaucer(有关详细信息,请参阅依赖项),并通过设置“Ff”属性的位标志 13 和 26 来启用多行和富文本字段。
我使用 PDF 参考 ISO-3200_2008 作为指南(从第 442 页开始)。
https://www.adobe.com/content/dam/acom/en/devnet/pdf/pdfs/PDF32000_2008.pdf
问题
我阅读了现有的 PDF 并以编程方式填写了 acro 字段。像这样的:
acroFields.setField("address", content);
内容只是一个带有一些换行符的简单字符串。没什么特别的。
我的文字太长了,有时会中断。启用多行时,文本会中断,但前提是它到达行尾。基本上,我想要显示的是地址和顶部的一些附加信息。但并非所有行的大小都相同,例如,我希望信息 1 和 2 位于同一行,信息 4 和 5 各位于不同的行。
我的想法
<h2>What I want</h2>
<pre>Company XYZ
A brand here</pre>
<pre>Another Section
With some more info that goes further to the right
phone, email, website</pre>
<br>
<h2>What it looks like</h2>
<p>Company XYZ
A brand here
Another Section
With some more info that goes further to the right
phone, email, website</p>
问题
- 有没有办法在 PDF 中实现一般的换行?
- 有没有办法以编程方式实现换行符?
- 我可以在 OpenPdf 或 FlyingSaucer 中执行此操作吗?
- 如果没有简单的方法 - 什么是可行的解决方法?
依赖关系
compile group: 'com.github.librepdf', name: 'openpdf', version: '1.3.3'
compile group: 'com.googlecode.juniversalchardet', name: 'juniversalchardet', version: '1.0.3'
compile 'org.xhtmlrenderer:flying-saucer-core:9.1.18'
compile 'org.xhtmlrenderer:flying-saucer-pdf-openpdf:9.1.18'
【问题讨论】:
标签: pdf line-breaks flying-saucer openpdf