使用 iText 获取 pdf 文件中元素的坐标
我正在使用 BIRT 报告库创建 pdf 文件。稍后我需要对这些文件进行数字签名。我正在使用 iText 对文档进行数字签名。
我面临的问题是,我需要将签名放在不同报告的不同位置。我已经有了对文档进行数字签名的代码,现在我总是将签名放在每个报告的最后一页的底部。
最终我需要每份报告都说明我需要在哪里签名。然后我必须使用 iText 读取该位置,然后将签名放在该位置。
这可以使用 BIRT 和 iText 实现吗?
谢谢
I'm creating a pdf file using BIRT reporting library. Later I need to digitally sign these files. I'm using iText to digitally sign the document.
The issue I'm facing is, I need to place the signature in different places in different reports. I already have the code to digitally sign the document, now I'm always placing the signature at the bottom of last page in every report.
Eventually I need each report to say where I need to place the signature. Then I've to read the location using iText and then place the signature at that location.
Is this possible to achieve using BIRT and iText
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果您愿意稍微作弊,您可以使用一个链接...根据我刚才对他们的文档的深入了解,BIRT 支持该链接。
链接是一个注释。遗憾的是,iText 不支持在高层检查注释,只支持生成注释,因此您必须使用低层对象调用。
提取它的代码可能如下所示:
如果 BIRT 在链接下的页面内容中生成一些文本以用于其视觉表示,那么这只是一个小问题。您的签名应完全覆盖它。
如果您一开始就可以直接从 BIRT 生成签名,那么您肯定会更好,但是我对他们的文档的一点检查并没有让我对他们的 PDF 定制能力充满信心......尽管坐在 iText 之上。它是一个能够生成 PDF 的报告生成器...我不应该期望太多。
`
编辑:如果您需要查找特定的 URL,您需要查看 PDF 参考的“12.5.6.5 链接注释”部分,可以在此处找到:
http://www.adobe.com/content /dam/Adobe/en/devnet/pdf/pdfs/PDF32000_2008.pdf
If you're willing to cheat a bit, you can use a link... which BIRT supports according to my little dive into their docs just now.
A link is an annotation. Sadly, iText doesn't support examining annotations at a high level, only generating them, so you'll have to use the low-level object calls.
The code to extract it might look something like this:
If BIRT generates some text in the page contents under the link for its visual representation, that's only a minor issue. Your signature should cover it completely.
You're definitely better of if you can generate the signature directly from BIRT in the first place, but my little inspection of their docs didn't exactly fill me with confidence in their PDF customization abilities... despite sitting on top of iText themselves. It's a report generator that happens to be able to produce PDFs... I shouldn't expect too much.
`
Edit: If you need to look for the specific URL, you'll want to look at section "12.5.6.5 Link Annotations" of the PDF Reference, which can be found here:
http://www.adobe.com/content/dam/Adobe/en/devnet/pdf/pdfs/PDF32000_2008.pdf
我对BIRT一无所知,对iText也只有一点了解。但也许这可行...
BIRT 可以将签名框的轮廓生成为具有给定字段名称的常规表单字段吗?如果是这样,那么您应该能够:
I don't know anything about BIRT, and have only a little familiarity with iText. But maybe this works...
Can BIRT generate the signature box's outline as a regular form field with a given field name? If so, then you should be able to: