首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >iPhone,CGPDFDocument - PDF链接

iPhone,CGPDFDocument - PDF链接
EN

Stack Overflow用户
提问于 2010-07-15 15:23:09
回答 1查看 8.1K关注 0票数 24

我试图使用CGPDFDocument编写一个基于QuartzDemo的简单PDF查看器。

有常见的渲染:

代码语言:javascript
复制
-(void)drawInContext:(CGContextRef)context
{
    // PDF page drawing expects a Lower-Left coordinate system, 
    // so we flip the coordinate system before we start drawing.
    CGContextTranslateCTM(context, 0.0, self.bounds.size.height);
    CGContextScaleCTM(context, 1.0, -1.0);

    // Grab the first PDF page
    CGPDFPageRef page = CGPDFDocumentGetPage(pdf, pageNumber);
    // We're about to modify the context CTM to draw the PDF page
    //  where we want it, so save the graphics state 
    // in case we want to do more drawing
    CGContextSaveGState(context);
    // CGPDFPageGetDrawingTransform provides an easy way 
    // to get the transform for a PDF page. It will scale down to fit, 
    // including any base rotations necessary to display the PDF page correctly. 
    CGAffineTransform pdfTransform = 
            CGPDFPageGetDrawingTransform(page, 
                    kCGPDFCropBox, self.bounds, 0, true);
    // And apply the transform.
    CGContextConcatCTM(context, pdfTransform);
    // Finally, we draw the page 
    // and restore the graphics state for further manipulations!
    CGContextDrawPDFPage(context, page);
    CGContextRestoreGState(context);
}

据我所知,它的唯一绘图,所以所有的结构导航或传出链接应该手动处理(例如。接触事件)。

它将设置URL用URL创建元素函数。

问题是:如何从特定的PDF块获取传出链接URL?

谢谢!

类似的问题:

iPhone/iPad上的PDF超链接

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

同上

iPhone SDK开发GGroup

macRumors论坛

iPhone开发SDK论坛

发展和发展论坛

iphonedevbook.com

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2010-09-28 00:27:05

这是一个很重要的问题,这就是为什么你没有找到简单的答案。解决方案是:您必须解析PDF文档。好消息是,苹果公司提供了一些功能,可以让你做到这一点。坏消息是,它们是程序性的,人类,这是一个复杂的混乱。

在非常粗略的伪代码中:

  • 使用CGPDFDocumentGetCatalog获取PDF的目录
  • 查找您要查找的页面的目录中的"pages“元素(是的,它是一个字典,而不是一个数组和一个嵌套的数组,因此这个简单的操作并不那么简单)。
  • 现在使用CGPDFDictionaryGetArray获取"Annots“对象
  • 接下来,您需要遍历注释并查找"Link“对象。

Adobe已经发布了一个文档,它展示了PDF规范。祝好运!

票数 17
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/3257057

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档