How do you extract color profiles from a PDF file using pdfbox (or other open source Java lib) -
once you've loaded document:
public static void main(string[] args) throws ioexception { pddocument doc = pddocument.load(new file("blah.pdf"));
how page page printing color intent pddocument? read docs, didn't see coverage.
this gets output intents (you'll these high quality pdf files) , icc profiles colorspaces , images:
pddocument doc = pddocument.load(new file("xxxxx.pdf")); (pdoutputintent oi : doc.getdocumentcatalog().getoutputintents()) { cosstream destoutputintent = oi.getdestoutputintent(); string info = oi.getoutputcondition(); if (info == null || info.isempty()) { info = oi.getinfo(); } inputstream = destoutputintent.createinputstream(); fileoutputstream fos = new fileoutputstream(info + ".icc"); ioutils.copy(is, fos); fos.close(); is.close(); } (int p = 0; p < doc.getnumberofpages(); ++p) { pdpage page = doc.getpage(p); (cosname name : page.getresources().getcolorspacenames()) { pdcolorspace cs = page.getresources().getcolorspace(name); if (cs instanceof pdiccbased) { pdiccbased icccs = (pdiccbased) cs; inputstream = icccs.getpdstream().createinputstream(); fileoutputstream fos = new fileoutputstream(system.currenttimemillis() + ".icc"); ioutils.copy(is, fos); fos.close(); is.close(); } } (cosname name : page.getresources().getxobjectnames()) { pdxobject x = page.getresources().getxobject(name); if (x instanceof pdimagexobject) { pdimagexobject img = (pdimagexobject) x; if (img.getcolorspace() instanceof pdiccbased) { inputstream = ((pdiccbased) img.getcolorspace()).getpdstream().createinputstream(); fileoutputstream fos = new fileoutputstream(system.currenttimemillis() + ".icc"); ioutils.copy(is, fos); fos.close(); is.close(); } } } } doc.close();
what doesn't (but add of if needed):
- colorspaces of shadings, patterns, xobject forms, appearance stream resources
- recursion in colorspaces devicen , separation
- recursion in patterns, xobject forms, soft masks
Comments
Post a Comment