簡體   English   中英

如何使用CGPDFDocument以縮放模式繪制PDF?

[英]How to draw PDF with CGPDFDocument in scaled mode?

我正在使用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函數的工作原理,有人可以幫我嗎?

嘗試這個:

//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的/

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM