如何访问PDF文档中的超链接(iPhone)?

发布于 2024-08-01 21:22:16 字数 294 浏览 11 评论 0 原文

是否可以使用 CGPDFDocument 或其他方式访问 PDF 文档中的“内部”链接? 我正在构建一个简单的阅读器应用程序,并希望以 PDF 形式提供我的内容,但如果我不能支持文档中页面之间的链接,这可能无法正常工作。

这个问题 类似,但没有解决如何支持超链接的问题。

Is it possible to get access to "internal" links in PDF documents using CGPDFDocument, or other means? I'm building a simple reader app and would like to deliver my content in PDF form, but if I can't support links between pages in the doc this probably isn't going to work.

This question is similar, but does not address the issue of how to support hyperlinks.

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

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

发布评论

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

评论(4

情魔剑神 2024-08-08 21:22:16

请参阅我的回答此处。 基本上,您需要熟悉 PDF 链接注释。

See my answer here. Basically, you'll need to get familiar with PDF link annotations.

清秋悲枫 2024-08-08 21:22:16

请参阅此示例代码...pdf 超链接在此

https://github.com/vfr/Reader中有效

see this sample code...pdf hyperlinks works in this

https://github.com/vfr/Reader

鸵鸟症 2024-08-08 21:22:16

如果您使用 Quartz 打开并查看 PDF,然后是的,看起来您将有权访问内部链接。 Quartz 还可以让您 向 PDF 添加新链接。 我没有任何 iPhone/Mac 开发的第一手经验,但如果他们让你添加超链接,但不使用它们,那就很奇怪了。

If you're using Quartz to open and view a PDF, then yes, it looks like you will have access to internal links. Quartz will also let you add new links to PDFs. I don't have any first hand experience with iPhone/Mac development, but it would be quite strange for them to let you add hyperlinks, but not use them.

无法回应 2024-08-08 21:22:16

您需要分两步进行。

第一:解析 pdf 以找到标记的内容运算符

这是解析代码的示例:(

-(void)parseContent() {
    CGPDFOperatorTableRef myTable;
    myTable = CGPDFOperatorTableCreate();
    CGPDFOperatorTableSetCallback(myTable, "BMC", &myOperator_BMC);
    CGPDFContentStreamRef myContentStream = CGPDFContentStreamCreateWithPage(page);
    CGPDFScannerRef myScanner = CGPDFScannerCreate(myContentStream, myTable, autoZoomAreas);
    CGPDFScannerScan(myScanner);
    CGPDFScannerRelease(myScanner);
    CGPDFContentStreamRelease(myContentStream); 
}

void myOperator_BMC(CGPDFScannerRef s, void *info)
{
    const char *name;
    CGPDFScannerPopName(s, &name);
}

您需要完成并调整此代码以满足您的要求)

第二:响应 toucheEnded 消息以处理对这些区域的点击并使 UI 响应因此。

You need to do in two steps.

First: Parse your pdf to locate marked content operators

That's an exemple of a parsing code :

-(void)parseContent() {
    CGPDFOperatorTableRef myTable;
    myTable = CGPDFOperatorTableCreate();
    CGPDFOperatorTableSetCallback(myTable, "BMC", &myOperator_BMC);
    CGPDFContentStreamRef myContentStream = CGPDFContentStreamCreateWithPage(page);
    CGPDFScannerRef myScanner = CGPDFScannerCreate(myContentStream, myTable, autoZoomAreas);
    CGPDFScannerScan(myScanner);
    CGPDFScannerRelease(myScanner);
    CGPDFContentStreamRelease(myContentStream); 
}

void myOperator_BMC(CGPDFScannerRef s, void *info)
{
    const char *name;
    CGPDFScannerPopName(s, &name);
}

(You need to complete and adjust this code to match your requirement)

Second: respond to the toucheEnded message to handle tap on those zones and make the UI respond accordingly.

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