iText - 创建 link 到 PDF/A-3 中的嵌入图像

iText - Create link to embedded image in PDF/A-3

我使用 iText 5.5.4 创建了一个带有附加图像文件的 PDF/A-3 文档。我需要的是在文档正文中添加链接以直接打开图像。

我试过这个来创建链接:

PdfAnnotation linktoimg = PdfAnnotation.createFileAttachment
                                        (writer, rectangle, "Open picture", fileSpec);
writer.addAnnotation(linktoimg);

编译正常,但在 运行 时我得到一个 PdfAConformanceException :

Annotation type /FileAttachment not allowed

我也尝试添加一个锚点来打开图像,但我发现 ISO-32000-1 规范不支持它。并且 gotoEmbedded 函数仅适用于附加的 PDF 文件。

那么有没有办法实现这个,或者我是否面临 PDF/A 的限制?

这不是 PDF/A-3(或 PDF/A-2)的限制。事实上,您发现了 iText PDF/A 实现中的错误。 FileAttachment 注释在 PDF/A-1 中是不允许的,但在 PDF/A-2 和 PDF/A-3.

中是不允许的

我已经修复了。它将在 develop branch of iText repository on GitHub soon. Alternatively, if you don't want to build from source, you can download a snapshot build from the iText repository

中可用