我通过拍摄UIView的截图来创建PDF,目前在带有视网膜显示屏的iPad3上工作得很好,但是当在其他具有较低分辨率屏幕的设备上进行测试时,我遇到文本分辨率问题.
这是我的代码:
//start a new page with default size and info //this can be changed later to include extra info. UIGraphicsBeginPDFPage(); //render the view's layer into an image context //the last option specifies scale. If 0,it uses the devices scale. UIGraphicsBeginImageContextWithOptions(view.bounds.size,view.opaque,2.0); CGContextRef context = UIGraphicsGetCurrentContext(); [view.layer renderInContext:context]; UIImage *screenShot = UIGraphicsGetImageFromCurrentImageContext(); UIGraphicsEndImageContext(); //render the screenshot into the pdf page CGContext [screenShot drawInRect:view.bounds]; //close the pdf context (saves the pdf to the NSData object) UIGraphicsEndPDFContext();
我还尝试将UIGraphicsBeginImageContextWithOptions比例设置为2.0,但这没有任何改变.如何强制iPad2上的视图以2倍的分辨率渲染?
预期产量:
实际产量: