iPad 용 앱에서 두 가지 방법을 사용하여 주로 사과 코드 available here을 기반으로 멋지게 표시했습니다. 지금까지 수십 개의 서로 다른 PDF에 대해 나는 방금 어떤 식 으로든 색이 왜곡 된 것처럼 보이는 수많은 PDF 파일을 얻었습니다. 무엇 미리보기/어도비 보여줍니다웹보기 및 CGPDFDocumentCreate를 통해 PDF 색상이 이상합니다. 아직 미리보기가 아닙니다.
: 여기
을 그리고 내가 시뮬레이터를 사용하여, 두 층에,보고 아이 패드의 UIWebView (파일을 가리키는)에 CGPDFDrawPDFPage()
및을 기반으로하고있는 무슨이다
어쨌든 PDF가 이상한 색상 공간 (CMYK?)에 있는지 궁금하지만, Adobe Reader가 제대로 열 수없는 이유를 설명하지 못합니다. 당신이 볼 수 있듯이, 우리는 또한 Fast and Lean PDF Viewer for iPhone/iPad/iOs - tips and hints?
의 열렬한 독자를왔다// 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);
}
: 참고로, 이것은 UIView의 서브 클래스에서 사용되는 디스플레이 코드의 합계의 총체 (pdfPage
인스턴스 변수입니다주의)이다
우리가보고있는 것을 진단하고 색 공간을 변경하는 방법 (또는 PDF 문서를 변경하는 방법에 대한 제안 사항? 그 옵션도 있습니다.)
감사합니다. Derek -이 PDF는 우리가 제작 한 것이 아니며, 필자에게 전달하는 데 도움이됩니다. –