PDFsharp & MigraDoc Foundation
https://forum.pdfsharp.net/

How can we keep Transparency blending Color Space NONE ?
https://forum.pdfsharp.net/viewtopic.php?f=2&t=3225
Page 1 of 1

Author:  andreas1974 [ Wed Nov 04, 2015 11:40 am ]
Post subject:  How can we keep Transparency blending Color Space NONE ?

Hi!

Background
We have problems printing PDF files using an HP Indigo professional printer. The problems began when we started to use PDFSharp to merge a number of files into one, in a certain way. Before that we used Acrobat, but that was much slower and involved more steps than the newly written C# program that use PDFSharp.

The problem
The original pdf files have "Transparency blending Color Space" set to None. After loading and saving the PDF files with PDFSharp this setting (or perhaps lack of setting) is replaced with "DeviceRGB", which the printer (rip?) is not handling very well. It results in the CMYK 100% colours are no longer "clean", but consists of more colours. The output from the Indigo printer looks "dirty", due to the DeviceRGB setting.

I simplified the C# code to a minimum, just opening a document with PDFSharp and saving it. This still results in Transparency blend color space being set to DeviceRGB.

Code:

using PdfSharp.Pdf;
using PdfSharp.Pdf.IO;

namespace ConsoleApplication4
{
   class Program
   {
      static void Main(string[] args) {
         PdfDocument outputDocument = PdfReader.Open(@"C:\Old.pdf", PdfDocumentOpenMode.Modify);
         outputDocument.Save(@"C:\Old_SavedByPDFSharp.pdf");
      }
   }
}



I'm using PDFSharp 1.50.3915.0.

What should we do to keep Transparency blending Color Space: None, just as it was in the original files?

This is what Acrobat Preflight output shows for a PDF that is correct (that is printing clean 100% colours on the Indigo printer):
Attachment:
Transparency blending.PNG
Transparency blending.PNG [ 37.9 KiB | Viewed 10298 times ]


This is what the same setting looks like after saving the same file with PDFSharp:
Attachment:
pdfsharp.PNG
pdfsharp.PNG [ 1.31 KiB | Viewed 10295 times ]


Thanks,
Andreas

Author:  Thomas Hoevel [ Wed Nov 04, 2015 12:55 pm ]
Post subject:  Re: How can we keep Transparency blending Color Space NONE ?

Hi, Andreas,

I'm not sure whether it is the same setting.
With PDFsharp you can set this:
Code:
document.Options.ColorMode = PdfColorMode.Cmyk;

See also:
http://www.pdfsharp.net/wiki/ColorsCMYK-sample.ashx

There also is "PdfColorMode.Undefined".

Maybe this is the same setting and solves your problem (by setting Cmyk or Undefined - please try both) - maybe it is not.
Please let me know whether it helps. If not I'll have to see how to set this with PDFsharp - or how to make it settable.

Author:  andreas1974 [ Wed Nov 04, 2015 1:10 pm ]
Post subject:  Re: How can we keep Transparency blending Color Space NONE ?

Using the document that has None to begin with and
setting
Code:
document.Options.ColorMode = PdfColorMode.Cmyk

changes Transparency Blending Color Space to DeviceCMYK

But, setting
Code:
document.Options.ColorMode = PdfColorMode.Undefined

still results in DeviceRGB.

So it's the right setting! But setting it to Undefined does not result in "None".
Perhaps the setting needs to be removed altogether in order for Acrobat to show it as None?

Perhaps some placeholder or "undefined" setting is inserted into the document as soon as PdfSharp opens it, and that any unrecognized color mode is defaulting to RGB? That's just my guess (I know nothing of hte internals of PDF).

Author:  Thomas Hoevel [ Wed Nov 04, 2015 1:37 pm ]
Post subject:  Re: How can we keep Transparency blending Color Space NONE ?

Do printouts look correct with "PdfColorMode.Cmyk"?
Is this a suitable workaround?

Author:  andreas1974 [ Wed Nov 04, 2015 1:59 pm ]
Post subject:  Re: How can we keep Transparency blending Color Space NONE ?

Hi!

My colleague will try that – before that I can't say for sure. I will get back with an answer, most likely tomorrow.

My guess is that it will work fine. But for new pdfSharp users, the ones who have not yet noticed this behaviour, it's not good, since you don't expect the colour handling to change. It's not a very prominent setting.
Also this was only visible on a specific Indigo printer in the house, not on another printer of a different brand, so perhaps there are different defaults built into the software of the printers as well.

So first it took about a week until the deterioration of the colours were even noticed, and then a number of hours to figure out what the difference was between the old pdfs and the new ones saved with pdfSharp.

I think the best thing would be if the ColorMode could be left completely unchanged by pdfSharp, unless you do a decided choice to set it to something.

Author:  Thomas Hoevel [ Wed Nov 04, 2015 4:47 pm ]
Post subject:  Re: How can we keep Transparency blending Color Space NONE ?

andreas1974 wrote:
I think the best thing would be if the ColorMode could be left completely unchanged by pdfSharp, unless you do a decided choice to set it to something.
That sounds like a good choice for a 1.0 version.
For compatibility with previous version I think it is better to keep ColorMode.Rgb as the default, but setting ColorMode.Undefined should give you undefined, not RGB.

It's easy to remove the code that sets the Color Space for a PDF page. A comment at that code says there might be problems with some files if no Color Space is set.
I don't know how to verify that change.
It will be reassuring to get (hopefully positive) feedback from your tests.

Author:  andreas1974 [ Thu Nov 05, 2015 3:19 pm ]
Post subject:  Re: How can we keep Transparency blending Color Space NONE ?

My colleague has tested it, and CMYK works fine!

It was a good thing that it was so easy to set the Transparency blending Color Space to CMYK. Problem solved for us, but it might be a caveat for new pdfSharp users.
You may be right that there are people who have used pdfSharp for a long time and depend on that "None" is changed to "RGB" by default... but on the other side my guess is that you will get a lot of new users now that XRef / IRef streams are supported by PdfSharp (1.5), which is the one we are using.

Anyway thank you so much for helping out!
Best regards,
Andreas

Author:  aleq_99 [ Fri Feb 03, 2017 1:37 pm ]
Post subject:  Re: How can we keep Transparency blending Color Space NONE ?

Hi,

I'm drawing images with embedded ICC profiles and setting PdfDocument.Options.ColorMode = PdfColorMode.Undefined still results in ColorSpace set to DeviceRGB i nthe pdf, so the actual color space from the images not being respected.

Using "PDFsharp-gdi" v1.50.4000-beta3b, is there a way to avoid this?

Page 1 of 1 All times are UTC
Powered by phpBB® Forum Software © phpBB Group
https://www.phpbb.com/