我在哪里可以获得 pdf 文档结构中的超链接(页面词典中的“注释”条目除外)?

发布于 2024-09-14 12:28:29 字数 680 浏览 2 评论 0原文

我有两个带有超链接的 pdf 文档(doc1 和 doc2),例如 www.somlink.com、www.somlink2.com。 根据 PDF 规范,我可以通过链接注释获取这些超链接。链接注释可以在 pdf 页面的字典中的“注释”键下找到。

    CGPDFDictionaryRef pageDictionary = CGPDFPageGetDictionary(someCGPDFPage);
CGPDFArrayRef annots;
CGPDFDictionaryGetArray(pageDictionary, "Annots", &annots);

所以问题是,在一个 pdf 文档(doc1)中,我得到了“Annots”数组,但在另一文档(doc2)中,页面字典中没有这样的条目。 问题是,使用 PDFKit.framework,即使页面字典中没有“Annots”条目,您也可以使用 - (NSArray *)annotations 方法在 PDFPage 类中获取这些注释。

我无法在 iPad/iPhone 上使用 PDFKit.framework,所以我正在使用 Quartz 框架:)

所以看来还有另一个地方可以指定超链接(或 PDF 参考中的链接注释),而不仅仅是在“Annots”数组中PDFKit.framework 不知何故知道如何做到这一点。

有什么想法可以在哪里获得这些超链接吗?

I have two pdf documents (doc1 and doc2) with hyperlinks e.g www.somlink.com, www.somlink2.com.
According to PDF Specification I can get those hyperlinks via Link Annotations. Link Annotations can be found in pdf page's dictionary under "Annots" key.

    CGPDFDictionaryRef pageDictionary = CGPDFPageGetDictionary(someCGPDFPage);
CGPDFArrayRef annots;
CGPDFDictionaryGetArray(pageDictionary, "Annots", &annots);

So the problem is that in one pdf document (doc1) I get that "Annots" array but in another document (doc2) there is no such entry in page dictionary.
And the thing is that with PDFKit.framework you can get those annotations in PDFPage class using - (NSArray *)annotations method even if there is no "Annots" entry in page dictionary.

I can't use PDFKit.framework on iPad/iPhone so I am working with Quartz framework :)

So it seems that there is another place where you can specify hyperlinks (or Link Annotations in PDF Reference), not only in "Annots" array and PDFKit.framework somehow know ho to do that.

Any ideas where can I get those hyperlinks?

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

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

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

薄暮涼年 2024-09-21 12:28:29

您可以点击的页面上的链接必须是注释。时期。没有注释,没有链接。

一串文本“http://blah.com”不一定是链接,它只是描述 URL 的一段文本。这可能是导致您困惑的原因。

还可以在书签中嵌入链接操作。我对 PDFKit 或 Quartz 一点也不熟悉,所以就 API 调用而言,你得靠自己。

最后,(重读您的问题),我相信注释可以从其父 Pages 对象继承。得去看看那个……不。注释数组必须位于叶页面对象中,否则无效。

您可以发布 PDF 链接吗?这里有些不对劲。

Links on a page THAT YOU CAN CLICK ON have to be annotations. Period. No annotations, no links.

A string of text "http://blah.com" isn't necessarily a link, it's just a piece of text describing a URL. This may be what's causing your confusion.

It's also possible to embed link actions in bookmarks. I'm not at all familiar with PDFKit or Quartz, so you're on your own as far as API calls are concerned.

And finally, (having reread your question), I believe annotations can be inherited from their parent Pages object. Gonna have to look that one up... Nope. The annotations array MUST be in the leaf page object, or it's not valid.

Can you post links to your PDFs? Something Ain't Right here.

鸩远一方 2024-09-21 12:28:29

像 Adob​​e Reader 这样的 PDF 查看器只允许单击并导航纯文本(如果它看起来像超链接) - 即以 http://、https://、ftp:// 开头并以一些 URL 分隔符(例如空格)结束。就这么简单;)

PDF viewer like Adobe Reader simply allows to click and navigate on a plain text, if it looks as a hyperlink - i.e. starts with http://, https://, ftp:// and ends up with some URL delimiter such as space. As simple as that ;)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文