0

我正在使用 CGPDFDocument 将 pdf 绘制到 UIView 屏幕中。但是,我在绘制 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, ?, ?);

当我使用比例因子为 1.2 时,CGContextTranslateCTM 的值是多少?或者任何人都可以帮助我了解 CGContextTranslateCTM 函数的工作原理吗?

4

1 回答 1

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-和-ipad/

于 2017-07-13T14:41:56.223 回答