如何使用Apache PDFBox在Adobe Acrobat中动态调整文本字段?

发布于 2025-01-29 18:57:09 字数 755 浏览 3 评论 0原文

我正在使用Apache PDFBox来填充现有的Adobe Acrobat PDF模板。 在此模板中,我有固定的文本字段尺寸,其中我从数据库中插入数据。

在一个文本字段中,数据量可能会有所不同,因此,如果文本字段变大或更小以适应插入的文本量,那将是很棒的。

主要的问题是,我要动态大小的另一个文本字段在一个文本字段下方,因此,在使其更大或更小的其他文本字段必须相对较大的情况下,

我正在搜索解决方案,但发现只能动态调整字体大小,但是它不满足我的需求。我可以创建一个文本字段并将所有数据插入其中,但是其中一些文本字段必须具有不同的文本颜色,因此拥有不同的文本字段以便能够在代码中指定其颜色很重要(据我所知)。

这是可能的,如果不是,我该怎么做才能实现我要寻找的结果?

PS我们的代码基于Adobe Acrobat和Apache PDFBox的模板,因此更可取以这种方式保持它。但是,如果这两个是不可能的,我将很高兴听到您对我应该使用什么的建议(开源)。

PDF生产商:Adobe Acrobat Pro DC(32位)21.7.20102, PDF版本:1.6(Acrobat 7.x), Apache PDFBox版本:2.0.26

您可以在下面找到我的PDF的示例

”在此处输入图像描述”

I'm using Apache PDFBox to populate an existing Adobe Acrobat PDF template.
In this template I have fixed sizes of text fields in which I insert data from database.

In one text field the amount of data may vary so it would be great if text field could get bigger or smaller to adjust to the amount of text inserted.

The main problem is that I have another text fields below the one I want to resize dynamically so in case of making it bigger or smaller other text fields have to move relatively

I was searching for the solution but found only offers to resize font dynamically, but it doesn't satisfy my needs. I could create one text field and insert all of my data in it, but some of those text fields must have different color of text so it's important to have different text fields to be able to specify their color in code (as far as I know).

Is that even possible and if not what can I do to achieve the result I'm looking for?

P.S. Our code is based on templates from Adobe Acrobat and Apache PDFBox, so it's more preferable to keep it that way. But if this is not possible with those two, I will be glad to hear your recommendations on what should I use (open source first).

PDF Producer: Adobe Acrobat Pro DC (32-bit) 21.7.20102,
PDF Version: 1.6 (Acrobat 7.x),
Apache PDFBox Version: 2.0.26

You can find an example of my PDF below

enter image description here

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文