ios - 通过 webview 和 CGPDFDocument 创建的 PDF 颜色很奇怪,但不在预览中

标签 ios ipad pdf cgpdfdocument

一年多以来,我一直在 iPad 应用程序中使用几种方法,主要基于苹果代码 available here很好地显示 PDF 页面 - 到目前为止,它适用于数十种不同的 PDF。我刚收到一堆 PDF,它们的颜色似乎以某种方式变形。 Preview/Adobe 显示的内容:

What I expected

这就是我所看到的,都是基于层的CGPDFDrawPDFPage()并在 iPad UIWebView(指向文件)中,使用模拟器:

What I got

我想知道 PDF 是否处于某种奇怪的色彩空间(CMYK?)中,但这并不能解释为什么 Preview/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);
}

如您所见,我们也是 Fast and Lean PDF Viewer for iPhone / iPad / iOs - tips and hints? 的热心读者。

关于如何诊断我们所看到的内容和/或更改色彩空间(或更改 PDF 文档?我们也有这个选项)的任何建议。

最佳答案

我猜您的 PDF 除了 CMYK 之外还使用一种或多种专色。 iOS 似乎不支持这些 - 据我所知,这在任何地方都没有记录,但这是我的经验。

如果您有 Acrobat Pro,您可以使用 Ink Manager(高级 → Print Production → Ink Manager)进行检查。

您还可以使用 Acrobat 将专色转换为打印色(高级 → 打印制作 → 转换颜色...)。单击颜色转换对话框中的“墨水管理器”按钮,并在此处激活“将所有点转换为打印”复选框。

关于ios - 通过 webview 和 CGPDFDocument 创建的 PDF 颜色很奇怪,但不在预览中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10464823/

相关文章:

ios - TVAnimationsGestures 可重用错误 :

javascript - 通过 php 或 javascript 检索 iPad/iPhone 序列号

javascript - 是否可以通过 PHP 或 JS 使用表单操作 PDF?

ios - 如何在 Xamarin.Forms 中设置 ListView 行高

javascript - 当尝试删除选择元素中的任何选定选项时,Safari 将其显示为空白

c# - PdfContentByte.SetFontAndSize() 抛出 "Object reference not set to instance of object"

javascript - Acrobat Javascript 保存和退出按钮

ios - 电子邮件截图而不保存到相机胶卷

iphone - 如何在 iPhone 上执行 HTML 文件( objective-c )?

iphone - 使用 webrequest 和 uialertview 在 MonoTouch 中线程化