PDF格式通过Web视图和CGPDFDocumentCreate很奇怪,但不在预览中 [英] PDF colours weird via web view and CGPDFDocumentCreate, yet not in preview

查看:146
本文介绍了PDF格式通过Web视图和CGPDFDocumentCreate很奇怪,但不在预览中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在iPad应用程序中使用了一些方法已有一年多了,主要基于苹果代码



任何su关于如何诊断我们正在看到的东西和/或改变色彩空间(或改变PDF文档?我们也有这个选项。)

解决方案

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



如果你有Acrobat Pro ,您可以使用墨水管理器(高级→打印生产→墨水管理器)进行检查。



您还可以使用Acrobat将专色转换为印刷色(高级→打印制作→转换颜色......)。单击颜色转换对话框中的Ink Manager按钮,然后激活将所有点转换为处理复选框。


I've been using a couple of methods in an iPad app for over a year now, largely based on apple code available here to display PDF pages nicely - it's worked fine for dozens of different PDFs until now. I just got a bunch of PDFs that appear to be having their colours warped in some way. What Preview/Adobe shows:

And here's what I'm seeing, both in Layer based CGPDFDrawPDFPage() and in an iPad UIWebView (pointing to the file), using simulator:

I am wondering if somehow the PDF is in some weird colorspace (CMYK?), but that wouldn't explain why Preview/Adobe Reader can open it just fine. For reference, this is the sum totality of the display code used in the UIView subclass (note, pdfPage is an instance variable):

// 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);
}

As you can see, we also have been avid readers of Fast and Lean PDF Viewer for iPhone / iPad / iOs - tips and hints?

Any suggestions on how to diagnose what we're seeing, and/or alter the color space (or alter the PDF document? We do have that option too).

解决方案

I would guess that your PDF uses one or more spot color(s) in addition to CMYK. It seems that those are not supported on iOS – as far as I know, this isn't documented anywhere, but it has been my experience.

If you have Acrobat Pro, you can check this with the Ink Manager (Advanced → Print Production → Ink Manager).

You can also use Acrobat to convert the spot colors to process colors (Advanced → Print Production → Convert Colors...). Click the "Ink Manager" button in the color conversion dialog and activate the "Convert all Spots to Process" checkbox there.

这篇关于PDF格式通过Web视图和CGPDFDocumentCreate很奇怪,但不在预览中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆