2017-07-13 32 views
0

我使用CGPDFDocument将pdf绘制到UIView屏幕中。 但是我在绘制pdf时遇到了一些事情,所以你的帮助将会很感激。如何在缩放模式下使用CGPDFDocument绘制PDF?

要求:我希望我的pdf文档能够以某种比例显示在UIView上,这样我的pdf文档就可以轻松地读取给用户,而无需放大或缩小。

与正常流量:

//1. Set the frame of view 
view.frame = CGRectMake(0,0,1008,612); 

//2. Normal scale 
CGContextScaleCTM(context, 1.0, -1.0); 

//3. Translate PDF 
CGContextTranslateCTM(context, 0, -[self bounds].size.height); 

现在什么应该是低于事物的价值,而我试图用因数1.2缩放PDF:

//1. Set the frame of view 
view.frame = CGRectMake(0,0,1008*1.2,612*1.2); 

//2. here i am scaling the pdf with 1.2 scale factor 
CGContextScaleCTM(context, 1.2, -1.2); 

//3. Translate PDF, so what will be the value of below parameter according to scale factor 1.2? 
CGContextTranslateCTM(context, ?, ?); 

会有什么CGContextTranslateCTM的,而价值我使用的比例因子为1.2? 或 任何人都可以帮我关于CGContextTranslateCTM函数的工作原理吗?

回答

0

试试这个:

//1. Set the frame of view 
view.frame = CGRectMake(0,0,1008*1.2,612*1.2); 

//2. Translate PDF to bottom left 
CGContextTranslateCTM(context, 0, view.frame.height); 

//3. Scale with 1.2 and reverse Y 
CGContextScaleCTM(context, 1.2, -1.2); 

这是一个博客的文章,在您使用的渲染CoreGraphics的PDF页面的时候需要做的细节解释说:http://ipdfdev.com/2011/03/23/display-a-pdf-page-on-the-iphone-and-ipad/

+0

感谢iPDFDev的快速回复。你的链接工作就像魅力:) –