How to access hyperlinks in PDF documents (iPhone)?

天大地大妈咪最大 提交于 2019-12-18 15:40:10

问题


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.


回答1:


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




回答2:


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

https://github.com/vfr/Reader




回答3:


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.




回答4:


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.



来源:https://stackoverflow.com/questions/1247792/how-to-access-hyperlinks-in-pdf-documents-iphone

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!