prawnpdf / prawn

Fast, Nimble PDF Writer for Ruby
https://prawnpdf.org
Other
4.65k stars 687 forks source link

CMYK pdf inverts color when opened in Illustrator #359

Closed robzolkos closed 10 years ago

robzolkos commented 12 years ago

I have produced a CMYK PDF using prawn. The background image I used is a cmyk jpg and then apply prawns text commands to it. When I open the PDF in any application it looks correct. However opening it in Adobe Illustrator, the background has inverted colors.

I am not sure what is causing this or how to resolve. But I need to be able to open the PDF generated by prawn and edit it in Illustrator. Hopefully someone has heard of this happening and knows a fix.

Ive put an example PDF in this repo https://github.com/RobZolkos/pdfissue

yob commented 11 years ago

Hi Rob,

Thanks for the report. When I open the sample pdf on my system (in evince and Acrobat X) it has a yellow heading, white type and a black background. Is that correct?

Unfortunately I don't have illustrator handy at the moment, but I'd like to clarify the issue first.

robzolkos commented 11 years ago

What you are seeing in evince and Acrobat X is correct. I have attached a screenshot of what is looks like when opened in Illustrator.

Screen Shot 2012-12-11 at 4 34 44 PM

practicingruby commented 10 years ago

Did we ever sort out what this issue was?

robzolkos commented 10 years ago

No. And still ocurrs.

On Tuesday, March 18, 2014, Gregory Brown notifications@github.com wrote:

Did we ever sort out what this issue was?

Reply to this email directly or view it on GitHubhttps://github.com/prawnpdf/prawn/issues/359#issuecomment-37871527 .

thanks, Rob

practicingruby commented 10 years ago

@robzolkos: If you can restore your bug example repo, we can take a closer look. Just to confirm, you've reproduced the problem on Prawn 1.0.0 (just released last night)?

ghinda commented 10 years ago

I'm seeing the exact same issue, but with completely different tools, so I don't think the issue is specifically related to prawn.

I'm converting a RGB jpg to CMYK using imagemagick, then inserting the image in a PDF using the Node.js pdfkit library.

Just like on your end, the PDF looks ok in all PDF readers (evice, okular, acrobat, etc.), but the image colors are inverted when opened in Illustrator.

Have you found any work-around?

ghinda commented 10 years ago

Seems that, at least on my end, I've managed to find a work-around for the issue, by using the -interlace flag, when converting the image to CMYK with ImageMagick, making a progressive jpeg.

robzolkos commented 10 years ago

An example showing the issue is here: https://github.com/robzolkos/prawn-issue

hello.pdf is the generated pdf. Opening in Illustrator the colors are inverted.

Screwface commented 9 years ago

Don't worry people, its simply that your RGB PDF is being automatically converted to CMYK witch creates that bug. Follow those steps and you should be OK.

  1. open your file (just like you did) in illustrator.
  2. delete the artwork (PDF) leaving the artwork size only
  3. File > Document Color Mode > RGB Color *(remember?... your PDF is in RGB!)
  4. File > Place.... find you file on your computer.

Like magic, your issue is no more !

elsurudo commented 7 years ago

@Screwface What if we want our PDF to be in CMYK, though?

elsurudo commented 7 years ago

I would propose to re-open this issue. I don't believe it is fixed, and the workaround is not a tenable one.

In short: When opening a prawn-generated CMYK PDF in illustrator with embedded JPGs that are also in CMYK, the embedded JPGs colors are inverted.

gettalong commented 7 years ago

@elsurudo Have you tried PDFs generated with other applications if they exhibit the same issue? E.g. creating a PDF from a LibreOffice Writer document that contains a CMYK JPG? @ghinda said that the same problem applies to other libraries too, so maybe it is something on Illustrator's side...

teambuktu commented 6 years ago

I had the same problem with CMYK PDFs generated with TCPDF or FPDF. They look fine in Acrobat Reader, Photoshop, etc. However, Illustrator shows them inverted. I found a solution:

Illustrator obviously ignores this string. Other PDF readers will invert the inverted CMYK back (basically).

cxgraphics commented 5 years ago

This is how I did it:

Open the pdf file in Acrobat Pro, choose “Edit PDF”, do any minor changes, then save the file.

Now the pdf should appear in correct colors in other Adobe softwares.

lukacsaron commented 4 years ago

Hey @teambuktu,

I really like your workaround. Hopefully, it'd save my ass on a project. Could you please clarify the "Change the source code (in your PDF library), so that" part regarding to an embedded image with jsPDF?

Thanks a lot, Aron

teambuktu commented 4 years ago

Hey @teambuktu,

I really like your workaround. Hopefully, it'd save my ass on a project. Could you please clarify the "Change the source code (in your PDF library), so that" part regarding to an embedded image with jsPDF?

Thanks a lot, Aron

I'm not sure about jsPDF. After generating your PDF open it in a text viewer and try to do a full text search for "CMYK" and locate a line like this:

<</Type /XObject /Subtype /Image /Width 2929 /Height 1535 /ColorSpace /DeviceCMYK /Decode [0 1 0 1 0 1 0 1] /BitsPerComponent 8 /Filter /DCTDecode /Length 70659 >> stream

If the bits behind decode are not in this order, it seems to cause problems. That's why I inverted the CMYK jpeg and made sure the Decode value is [0 1 0 1 0 1 0 1]

Now you would have to find out the function in the source code that generates this Decode-String. It might have something to do with the line "options.push({ key: "Decode", value: "[0.0 1.0 0.0 1.0 0.0 1.0]" });" in https://github.com/MrRio/jsPDF/blob/master/src/jspdf.js

But that's just a quick guess, which might be wrong.

I hope I could give you a first clue.