iOS开发CoreGraphics核心图形框架之九——PDF文件的渲染与创建 一、渲染已有的PDF文档 在CoreGraphics框架中,有两个类型与PDF文档的渲染有关,分别为CGPDFDocumentRef 其中,CGPDFDocumentRef对应整个PDF文档,里面封装了许多文档相关的信息,CGPDFPageRef对应PDF文档中某一页的内容,通过它开发者可以将PDF内容通过CGContext上下文渲染到指定目标上 引用的创建 CGPDFDocumentRef document = CGPDFDocumentCreateWithURL(url); CFRelease(url); //获取文档的第 url); //进行引用计数+1 CGPDFDocumentRef CGPDFDocumentRetain(CGPDFDocumentRef cg_nullable document); //进行引用计数 (CGPDFDocumentRef cg_nullable document, int page); int CGPDFDocumentGetRotationAngle(CGPDFDocumentRef
initWithFrame:frame]; if (self) { NSURL *docURL = [NSURL fileURLWithPath:path]; CGPDFDocumentRef
//进行PDF文档绘制 CGPDFPage相关API代替 void CGContextDrawPDFDocument(CGContextRef cg_nullable c, CGRect rect, CGPDFDocumentRef