如何在iPhone SDK中检测PDF文档的方向 [英] How to detect the orientation of a PDF document in iPhone SDK
问题描述
我目前正在使用CGPDFDocumnentRef开发一个简单的PDF阅读器.当我尝试渲染Portrait PDF文档时,一切都很好.但是,当我尝试在风景"中渲染一个时,它会显示一个旋转的PDF文档.当然,当我在pdf阅读器的网络浏览器中查看横向PDF文件时,它就是横向文件.
I am currently working for a simple PDF reader using CGPDFDocumnentRef. It is all fine when I try to render a Portrait PDF document. But when I try to render one in Landscape, it shows a rotated PDF document. Of course when I view that landscape PDF file in the web browser of a pdf reader, it is a landscape one.
iPhone SDK中是否有任何方法可以检测pdf文档的方向?
Is there any method in iPhone SDK that can detect the Orientation of a pdf document?
任何帮助将不胜感激.
关于, Xeron0719
Regards, Xeron0719
推荐答案
您可以尝试获取pdf的页面大小,然后检查width是否大于heigh并最终将其旋转...
You may try to get the page size of your pdf and then check if width is > than heigh and eventually rotate it...
-(CGSize)getPdfSize{
CFURLRef pdfURL = CFBundleCopyResourceURL(CFBundleGetMainBundle(), CFSTR("aPdfFile.pdf"), NULL, NULL);
pdf = CGPDFDocumentCreateWithURL((CFURLRef)pdfURL);
CGPDFPageRef page = CGPDFDocumentGetPage(pdf, 1);
CGRect appR = CGPDFPageGetBoxRect (page, 1);
// NSLog(@" ..... pdf width: %f", appR.size.width);
return appR.size;
}
这篇关于如何在iPhone SDK中检测PDF文档的方向的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!