私は1年以上iPadアプリでいくつかの方法を使用してきましたが、主にここで利用可能なAppleコードに基づいて、PDFページを適切に表示しています.これまで、数十の異なるPDFでうまく機能していました. なんらかの方法で色が歪んでいるように見える PDF を大量に入手しました。プレビュー/アドビが表示するもの:
CGPDFDrawPDFPage()
そして、シミュレーターを使用して、レイヤーベースとiPad UIWebView(ファイルを指している)の両方で私が見ているものは次のとおりです。
どういうわけかPDFが奇妙な色空間(CMYK?)にあるのではないかと思っていますが、プレビュー/ Adobe Readerで問題なく開くことができる理由は説明できません。参考までに、これは UIView サブクラスで使用される表示コードの合計です (注、pdfPage
はインスタンス変数です)。
// Draw the CGPDFPageRef into the layer at the correct scale.
-(void)drawLayer:(CALayer*)layer inContext:(CGContextRef)context
{
// from https://stackoverflow.com/questions/3889634/fast-and-lean-pdf-viewer-for-iphone-ipad-ios-tips-and-hints
CGContextSetInterpolationQuality(context, kCGInterpolationHigh);
CGContextSetRenderingIntent(context, kCGRenderingIntentDefault);
// First fill the background with white.
CGContextSetRGBFillColor(context, 1.0f, 1.0f, 1.0f, 1.0f);
CGContextFillRect(context, self.bounds);
CGContextSaveGState(context);
// Flip the context so that the PDF page is rendered
// right side up (all the PDF routines are built for Mac OS X
// coordinate systems, where Y is upwards.
// first move the origin down by the full height
CGContextTranslateCTM(context, 0.0f, self.bounds.size.height);
// now invert the Y position (scale by -1)
CGContextScaleCTM(context, 1.0f, -1.0f);
// Scale the context so that the PDF page is rendered
// at the correct size for the zoom level.
CGContextScaleCTM(context, myScale, myScale);
CGContextDrawPDFPage(context, pdfPage);
CGContextRestoreGState(context);
}
ご覧のとおり、私たちはiPhone / iPad / iOS 用の Fast and Lean PDF Viewer の熱心な読者でもあります - ヒントとヒント?
私たちが見ているものを診断する方法、および/または色空間を変更する方法 (または PDF ドキュメントを変更する方法についての提案はありますか? そのオプションもあります)。