代码之家  ›  专栏  ›  技术社区  ›  Maksym Gontar

iPhone,cgpdfdocument-pdf链接

  •  24
  • Maksym Gontar  · 技术社区  · 15 年前

    我正在尝试使用 CGPDFDocument ,基于Quartzdemo。
    有常见的渲染:

    -(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 URL create 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 回复  |  直到 14 年前
        1
  •  17
  •   Ben Gottlieb    14 年前

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

    在非常粗糙的伪代码中:

    • 使用cgpdfdocumentgetcatalog获取PDF的目录
    • 在目录的“page s”元素中查找要查找的页面(是的,它是一个字典,而不是数组,并且是嵌套的,所以这个简单的操作并不那么简单)。
    • 现在使用cgpdfDictionaryGetArray获取“annots”对象
    • 接下来,您需要迭代注释并查找“链接”对象。

    Adobe发布了 document 这就制定了PDF规范。祝你好运!