开发者

Where I can get hyperlinks in pdf document structure (except "Annots" entry in page dictionary)?

开发者 https://www.devze.com 2023-01-11 12:01 出处:网络
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

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 开发者_C百科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?


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.


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 ;)

0

精彩评论

暂无评论...
验证码 换一张
取 消