PDFsharp & MigraDoc Foundation

PDFsharp - A .NET library for processing PDF & MigraDoc Foundation - Creating documents on the fly
It is currently Fri Mar 29, 2024 5:15 am

All times are UTC


Forum rules


Please read this before posting on this forum: Forum Rules



Post new topic Reply to topic  [ 8 posts ] 
Author Message
PostPosted: Wed Nov 04, 2015 11:40 am 
Offline

Joined: Thu Mar 19, 2015 2:27 pm
Posts: 5
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 9942 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 9939 times ]


Thanks,
Andreas


Last edited by andreas1974 on Wed Nov 04, 2015 12:58 pm, edited 1 time in total.

Top
 Profile  
Reply with quote  
PostPosted: Wed Nov 04, 2015 12:55 pm 
Offline
PDFsharp Guru
User avatar

Joined: Mon Oct 16, 2006 8:16 am
Posts: 3095
Location: Cologne, Germany
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.

_________________
Regards
Thomas Hoevel
PDFsharp Team


Top
 Profile  
Reply with quote  
PostPosted: Wed Nov 04, 2015 1:10 pm 
Offline

Joined: Thu Mar 19, 2015 2:27 pm
Posts: 5
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).


Top
 Profile  
Reply with quote  
PostPosted: Wed Nov 04, 2015 1:37 pm 
Offline
PDFsharp Guru
User avatar

Joined: Mon Oct 16, 2006 8:16 am
Posts: 3095
Location: Cologne, Germany
Do printouts look correct with "PdfColorMode.Cmyk"?
Is this a suitable workaround?

_________________
Regards
Thomas Hoevel
PDFsharp Team


Top
 Profile  
Reply with quote  
PostPosted: Wed Nov 04, 2015 1:59 pm 
Offline

Joined: Thu Mar 19, 2015 2:27 pm
Posts: 5
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.


Top
 Profile  
Reply with quote  
PostPosted: Wed Nov 04, 2015 4:47 pm 
Offline
PDFsharp Guru
User avatar

Joined: Mon Oct 16, 2006 8:16 am
Posts: 3095
Location: Cologne, Germany
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.

_________________
Regards
Thomas Hoevel
PDFsharp Team


Top
 Profile  
Reply with quote  
PostPosted: Thu Nov 05, 2015 3:19 pm 
Offline

Joined: Thu Mar 19, 2015 2:27 pm
Posts: 5
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


Top
 Profile  
Reply with quote  
PostPosted: Fri Feb 03, 2017 1:37 pm 
Offline

Joined: Wed Feb 03, 2016 5:21 pm
Posts: 9
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?


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 8 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 125 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Privacy Policy, Data Protection Declaration, Impressum
Powered by phpBB® Forum Software © phpBB Group