You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@pdfbox.apache.org by Derwent Ready <dr...@gmail.com> on 2017/06/05 09:03:00 UTC

Custom ICC Profiles

Hi,

My app is a fairly simple one that takes a print-ready Indesign or
Illustrator PDF and outputs image files to multiple resolutions. I'd quite
like if possible to be able to load any custom ICC profile from a specified
directory or fall back on the supplied PDFBox profile.

I found a reply to this issue:
https://issues.apache.org/jira/browse/PDFBOX-2681 that says
"If you do have a copy of the Adobe profile, you can use it with PDFBox by
creating your own subclass of PDDeviceCMYK which overrides getICCProfile
and then calling PDDeviceCMYK.INSTANCE = foo, where foo is an instance of
your subclass. You'll need to check the terms of the profile license first,
to see what usage is permitted."

I tried subclassing PDDeviceCMYK however I'm not sure how to do this
properly, I thought perhaps overriding the getICCProfile() method would
work however my tests PDFBox was clearly still using the built in ICC
profile even when I hard coded the path to my US Web Coated SWOP V2 profile
in the getICCProfile method. I don't know if it's that I called
PDDeviceCMYK.instance = new MyICCClass() in the wrong place or if I didn't
override enough of the original PDDDeviceCMYK class.

I've tried calling the PDDeviceCMYK.instance = new MyICCClass() line just
before the document loads, just after it loads and just before rendering.

public ICC_Profile getICCProfile() throws IOException {
        String name = MainClass.properties.getProperty("profiles_dir"); //
orginally hard coded the location of the US Web Coated SWOP V2 profile
        URL url = new URL(name);
        if (url == null)
        {
            throw new IOException("Error loading profile: " + name); //
fall back to default PDFBox profile
        }

        ICC_Profile iccProfile;
        try (InputStream input = url.openStream()) {
            iccProfile = ICC_Profile.getInstance(input);
        }
        System.out.println("Loaded profile: " + name );
        return iccProfile;
}

Any help would be appreciated. I can live with the slightly-off colours but
if I can I'd much rather have them corrected.

Thanks,

D

Re: Custom ICC Profiles

Posted by Derwent Ready <dr...@gmail.com>.
OK thanks,

I guess it's me being overly judgemental of my design or something. Thanks
for the help.

On 5 June 2017 at 14:36, Tilman Hausherr <TH...@t-online.de> wrote:

> Hi,
>
> I did the comparison that I mentioned and the renderings are identical. I
> do see a slight difference in your dropbox images but this goes away when
> moving my head, i.e. the difference is due to screen angle.
>
> Colorspaces can appear at many places, in the content stream, in images,
> shadings, resources...  I had a quick look at your file with PDFDebugger
> and it uses ICC colorspaces.
>
> Tilman
>
>
> Am 05.06.2017 um 13:49 schrieb Derwent Ready:
>
>> Hi,
>>
>> Thanks for the quick response. I just tried your code and put the outputs
>> from Indesign, Photoshop RGB/CYMK, PDFBox default and PDFBox using the
>> SWOP
>> profile next to each other and yes there is definitely a difference so
>> thanks for that. :)
>> The SWOP is definitely closer to the Photoshop versions than the PDFBox
>> default. This is more noticeable on one set of images than another.
>>
>> I've linked a couple of images in a dropbox link that show the
>> differences.
>> On the first image (purple) the difference is minimal but on the second
>> (orange) the gradients are really quite different. I'm not sure if this is
>> a PDFBox issue or a profile issue or what.
>> https://www.dropbox.com/sh/e80qn8qa2s2ad56/AAA0qKuhAjXeP0e2Qe2AXmFea?dl=0
>>
>> How would I check that the file has DeviceCYMK colourspace? I've included
>> a
>> blank version of the PDF in the dropbox folder.
>>
>> Thanks again,
>>
>> D
>>
>> On 5 June 2017 at 10:40, Tilman Hausherr <TH...@t-online.de> wrote:
>>
>> Here's what worked for me, I used it in my rendering tests which detect
>>> differences:
>>>
>>>          PDDeviceCMYK.INSTANCE = new PDDeviceCMYK()
>>>          {
>>>              @Override
>>>              protected ICC_Profile getICCProfile() throws IOException
>>>              {
>>>                  return ICC_Profile.getInstance("USWebCoatedSWOP.icc");
>>>              }
>>>          };
>>>
>>> The results are definitively different.
>>>
>>> If you have a test file, I could render it with and without the change
>>> and
>>> check whether it is different or not. Maybe your file doesn't have the
>>> /DeviceCMYK colorspace but something else?
>>>
>>> Tilman
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
>>> For additional commands, e-mail: users-help@pdfbox.apache.org
>>>
>>>
>>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
> For additional commands, e-mail: users-help@pdfbox.apache.org
>
>

Re: Custom ICC Profiles

Posted by Tilman Hausherr <TH...@t-online.de>.
Hi,

I did the comparison that I mentioned and the renderings are identical. 
I do see a slight difference in your dropbox images but this goes away 
when moving my head, i.e. the difference is due to screen angle.

Colorspaces can appear at many places, in the content stream, in images, 
shadings, resources...  I had a quick look at your file with PDFDebugger 
and it uses ICC colorspaces.

Tilman

Am 05.06.2017 um 13:49 schrieb Derwent Ready:
> Hi,
>
> Thanks for the quick response. I just tried your code and put the outputs
> from Indesign, Photoshop RGB/CYMK, PDFBox default and PDFBox using the SWOP
> profile next to each other and yes there is definitely a difference so
> thanks for that. :)
> The SWOP is definitely closer to the Photoshop versions than the PDFBox
> default. This is more noticeable on one set of images than another.
>
> I've linked a couple of images in a dropbox link that show the differences.
> On the first image (purple) the difference is minimal but on the second
> (orange) the gradients are really quite different. I'm not sure if this is
> a PDFBox issue or a profile issue or what.
> https://www.dropbox.com/sh/e80qn8qa2s2ad56/AAA0qKuhAjXeP0e2Qe2AXmFea?dl=0
>
> How would I check that the file has DeviceCYMK colourspace? I've included a
> blank version of the PDF in the dropbox folder.
>
> Thanks again,
>
> D
>
> On 5 June 2017 at 10:40, Tilman Hausherr <TH...@t-online.de> wrote:
>
>> Here's what worked for me, I used it in my rendering tests which detect
>> differences:
>>
>>          PDDeviceCMYK.INSTANCE = new PDDeviceCMYK()
>>          {
>>              @Override
>>              protected ICC_Profile getICCProfile() throws IOException
>>              {
>>                  return ICC_Profile.getInstance("USWebCoatedSWOP.icc");
>>              }
>>          };
>>
>> The results are definitively different.
>>
>> If you have a test file, I could render it with and without the change and
>> check whether it is different or not. Maybe your file doesn't have the
>> /DeviceCMYK colorspace but something else?
>>
>> Tilman
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
>> For additional commands, e-mail: users-help@pdfbox.apache.org
>>
>>


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
For additional commands, e-mail: users-help@pdfbox.apache.org


Re: Custom ICC Profiles

Posted by Stela Vula <vu...@hotmail.com>.
Please remove me from this list.

Thank You,

Stela


________________________________
From: Derwent Ready <dr...@gmail.com>
Sent: Monday, June 5, 2017 2:49 PM
To: users@pdfbox.apache.org
Subject: Re: Custom ICC Profiles

Hi,

Thanks for the quick response. I just tried your code and put the outputs
from Indesign, Photoshop RGB/CYMK, PDFBox default and PDFBox using the SWOP
profile next to each other and yes there is definitely a difference so
thanks for that. :)
The SWOP is definitely closer to the Photoshop versions than the PDFBox
default. This is more noticeable on one set of images than another.

I've linked a couple of images in a dropbox link that show the differences.
On the first image (purple) the difference is minimal but on the second
(orange) the gradients are really quite different. I'm not sure if this is
a PDFBox issue or a profile issue or what.
https://www.dropbox.com/sh/e80qn8qa2s2ad56/AAA0qKuhAjXeP0e2Qe2AXmFea?dl=0

How would I check that the file has DeviceCYMK colourspace? I've included a
blank version of the PDF in the dropbox folder.

Thanks again,

D

On 5 June 2017 at 10:40, Tilman Hausherr <TH...@t-online.de> wrote:

> Here's what worked for me, I used it in my rendering tests which detect
> differences:
>
>         PDDeviceCMYK.INSTANCE = new PDDeviceCMYK()
>         {
>             @Override
>             protected ICC_Profile getICCProfile() throws IOException
>             {
>                 return ICC_Profile.getInstance("USWebCoatedSWOP.icc");
>             }
>         };
>
> The results are definitively different.
>
> If you have a test file, I could render it with and without the change and
> check whether it is different or not. Maybe your file doesn't have the
> /DeviceCMYK colorspace but something else?
>
> Tilman
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
> For additional commands, e-mail: users-help@pdfbox.apache.org
>
>

Re: Custom ICC Profiles

Posted by Derwent Ready <dr...@gmail.com>.
Hi,

Thanks for the quick response. I just tried your code and put the outputs
from Indesign, Photoshop RGB/CYMK, PDFBox default and PDFBox using the SWOP
profile next to each other and yes there is definitely a difference so
thanks for that. :)
The SWOP is definitely closer to the Photoshop versions than the PDFBox
default. This is more noticeable on one set of images than another.

I've linked a couple of images in a dropbox link that show the differences.
On the first image (purple) the difference is minimal but on the second
(orange) the gradients are really quite different. I'm not sure if this is
a PDFBox issue or a profile issue or what.
https://www.dropbox.com/sh/e80qn8qa2s2ad56/AAA0qKuhAjXeP0e2Qe2AXmFea?dl=0

How would I check that the file has DeviceCYMK colourspace? I've included a
blank version of the PDF in the dropbox folder.

Thanks again,

D

On 5 June 2017 at 10:40, Tilman Hausherr <TH...@t-online.de> wrote:

> Here's what worked for me, I used it in my rendering tests which detect
> differences:
>
>         PDDeviceCMYK.INSTANCE = new PDDeviceCMYK()
>         {
>             @Override
>             protected ICC_Profile getICCProfile() throws IOException
>             {
>                 return ICC_Profile.getInstance("USWebCoatedSWOP.icc");
>             }
>         };
>
> The results are definitively different.
>
> If you have a test file, I could render it with and without the change and
> check whether it is different or not. Maybe your file doesn't have the
> /DeviceCMYK colorspace but something else?
>
> Tilman
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
> For additional commands, e-mail: users-help@pdfbox.apache.org
>
>

Re: Custom ICC Profiles

Posted by Tilman Hausherr <TH...@t-online.de>.
Here's what worked for me, I used it in my rendering tests which detect 
differences:

         PDDeviceCMYK.INSTANCE = new PDDeviceCMYK()
         {
             @Override
             protected ICC_Profile getICCProfile() throws IOException
             {
                 return ICC_Profile.getInstance("USWebCoatedSWOP.icc");
             }
         };

The results are definitively different.

If you have a test file, I could render it with and without the change 
and check whether it is different or not. Maybe your file doesn't have 
the /DeviceCMYK colorspace but something else?

Tilman

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
For additional commands, e-mail: users-help@pdfbox.apache.org