【问题标题】:iPhone, CGPDFDocument - PDF linksiPhone, CGPDFDocument - PDF 链接
【发布时间】:2011-03-16 11:36:39
【问题描述】:

我正在尝试使用CGPDFDocument 编写一个基于 QuartzDemo 的简单 PDF 查看器。
有常见的渲染:

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

据我了解,它是唯一的绘图,因此所有结构导航或传出链接都应手动处理(例如在触摸事件中)。

有函数which will set URLcreate element with URL

问题是:如何从某个 PDF 块中获取传出链接 URL?

谢谢!

类似问题:
PDF hyperlinks on iPhone/iPad
How to access hyperlinks in PDF documents (iPhone)?

同样在
iPhone SDK Dev GGroup
macRumors Forum
iPhone Dev SDK Forum
Dev Shed Forum
iphonedevbook.com

【问题讨论】:

  • +1 表示在任何地方都没有答案的问题。 揉着头继续挖
  • +1,50 分赏金 - 我也很想知道答案,我们已经搜索了几个星期,但无论我们尝试了什么都没有结果
  • 工作样本+100分!

标签: iphone cocoa-touch pdf hyperlink quartz-2d


【解决方案1】:

这是一个重要的问题,这就是为什么您找不到简单的答案。解决方案是:您必须解析 PDF 文档。好消息是,Apple 提供了一些功能可以让你做到这一点。坏消息是,它们是程序性的,伙计,这是一个令人费解的混乱。

在非常粗略的伪代码中:

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

Adobe 发布了一份document,其中列出了 PDF 规范。祝你好运!

【讨论】:

  • 谢谢我意识到这不是一个微不足道的问题,因此是赏金,但它非常重要,Apple 的关于 iPhone 上 Quartz PDF 的文档非常差,并且没有其他博客或教程涵盖它
猜你喜欢
  • 2011-02-06
  • 2011-06-19
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2010-11-17
  • 2012-02-15
  • 2017-12-18
  • 1970-01-01
相关资源
最近更新 更多