pdfbox-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Derwent Ready <drents...@gmail.com>
Subject Custom ICC Profiles
Date Mon, 05 Jun 2017 09:03:00 GMT
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

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message