iPhone,CGPDF文档 - PDF链接 [英] iPhone, CGPDFDocument - PDF links

查看:193
本文介绍了iPhone,CGPDF文档 - PDF链接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用 CGPDFDocument ,基于QuartzDemo。

有常见的渲染:

I'm trying to write a simple PDF viewer using CGPDFDocument, based on QuartzDemo.
There is common rendering:

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

据我所知,它唯一的绘图,所有结构导航或输出链接(例如触摸事件)。

As I understand, its only drawing, so all structure navigation or outgoing links should be handled manually (ex. in touch event).

有一些功能将设置网址使用网址创建元素

问题是:如何从某些PDF块获取传出链接网址?

谢谢!

类似问题:

iPhone / iPad上的PDF超链接


$ b相同$ b
iPhone SDK Dev GGroup

macRumors论坛

iPhone Dev SDK论坛

开发论坛

iphonedevbook.com

推荐答案

琐碎的问题,这就是为什么你没有找到没有容易的答案。解决方案是:您必须解析PDF文档。好消息是,苹果提供的功能允许你这样做。坏消息是,他们是程序性的,人,是一个令人费解的混乱。

This is a non-trivial question, which is why you've found no easy answer. The solution is: you have to parse the PDF document. The good news is, there are functions provided by Apple to allow you do to this. The bad news is, they're procedural, and man, is it a convoluted mess.

在非常粗糙的伪代码中:

In very rough pseudo code:


  • 使用CGPDFDocumentGetCatalog获取目录PDF

  • 在目录的pages元素中查找您要查找的页面(是的,它是一个字典,不是数组和嵌套的,所以这个简单的操作不是那么简单)。

  • 现在使用CGPDFDictionaryGetArray获取Annots对象

  • 接下来,您需要遍历注释并查找链接对象。

  • use CGPDFDocumentGetCatalog to get the catalog for the PDF
  • look in the "pages" element of the catalog for the page you're looking for (yes, it's a dictionary, not an array, and a nested one, so this simple operation is not-so-simple).
  • now use CGPDFDictionaryGetArray to get the "Annots" object
  • next, you need to iterate through the annotations and look for "Link" objects.

Adob​​e已发布文档,其中列出了PDF规范。祝你好运!

Adobe has published a document that lays out the PDF specification. Good luck!

这篇关于iPhone,CGPDF文档 - PDF链接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆