1

My requirement is to set page-level transparency blending color space to Device RGB. I am trying to use pdfBox to achieve this. Screenshot is from the Adobe Acrobat reader (Print Production -> flatten Previewer -> change page level transparency color space)where you can set the value from the dropdown.

I tried to set blend mode using PDGraphicState of PDFBOX. Is it right way to achieve page level transparency showed in screenshot?

PDGraphicsState gState = new PDGraphicsState(page.getArtBox());
gState.setBlendMode(BlendMode.OVERLAY);
PDExtendedGraphicsState pde = new PDExtendedGraphicsState();
pde.copyIntoGraphicsState(gState);
final COSName blendMode =page.getResources().add(pde);

But this is not working. I have some other code which uses "PDExtendedGraphicState"

which will be added to page using page.getResources().add(graphicsState) But PDExtendedGraphicState does not have any method to setBlend Mode. So I created new PDExtendedGraphicState object and did "copyIntoGraphicsState".

Am I missing something or the approach is wrong?

Thanks in advance.

EDIT
Before Open file in Adobe acrobat Pro DC. Open : Tools -> Print production -> output preview. Try to open and close output preview. you can see color shifts. Before

After Open same file (Before.pdf) in Acrobat Pro DC. Open : Tools -> Print production -> Flattener Preview -> Look for Page level transparency blending color space(See the screenshot) -> change -> select Device RGB from the dropdown -> apply. Now you will get after.pdf which I added here. After this if you open output Preview as stated above you will not see shifting of colors.
After

zero
  • 11
  • 3
  • Your question clearly is about pdfbox, not itext. So I removed the [tag:itext] tag. – mkl Feb 13 '19 at 06:22

2 Answers2

0

Part of the issue here is, I think, is that there are blending modes (normal, darken, multiply, color burn, etc.), and then the page-level transparency blending color space (DeviceRGB or DeviceCMYK). The latter can be set in InDesign (there's a menu item for it), but setting this parameter using PDFBox or another tool is what's needed here. So, it's not an overprint or blend mode, it's setting the color space (which is set to "none" in the OP's PDF to be modified).

In my testing, transparency blending between two RGB objects doesn't work correctly if this setting is set to "none," and does work correctly if set to "DeviceRGB" or an appropriate RGB colorspace with no changes to overprint or blend mode.

It appears that both Enfocus PitStop Pro and Callas pdfToolbox can set this parameter, but it would be useful if PDFBox could do so as well.

  • Actually it isn't a simple "parameter" even though InDesign may make it look that way. If there was a technical specification of the meaning of the term "page-level transparency blending color space", it might be possible to implement this in PDFBox. Unfortunately "transparency blending color space" is not to be found as term in the PDF specification, though. – mkl Feb 18 '19 at 16:08
  • It looks like section 7.2.3 in the PDF Reference, v.1.7, discusses blending color space. I'm not sure how this corresponds to the PDF spec, however. http://archimedespalimpsest.net/Documents/External/pdf_reference_1-7.pdf – John Reinert Nash Feb 18 '19 at 20:50
  • Indeed. In the PDF specification ISO 32000-1 that discussion is in section 11.3.4. And later *The blending colour space shall be an attribute of the transparency group within which an object is painted. The page as a whole shall also be treated as a group, the page group (see “Page Group”), with a colour space attribute of its own.* So one would assume the color space we talk about here is the one set in the page transparency group dictionary. But in case of the OP's "After.pdf" the page does not have a **Group** entry. D'oh! – mkl Feb 19 '19 at 07:38
  • By way of followup, my particular issue was solved by setting the blending colo(u)rspace of the assets in question (not the document as a whole) to DeviceRGB. Interestingly, Acrobat Pro DC doesn't "Output Preview" the color correctly, but the press prints it correctly. Thanks for the feedback, good learnings here. – John Reinert Nash Feb 19 '19 at 21:55
0

To set DeviceRGB as transparency blending colorspace for the document. We have used:

group.setItem(COSName.S, COSName.TRANSPARENCY);
group.setItem(COSName.CS, COSName.DEVICERGB);
page.getCOSObject().setItem(COSName.GROUP, group)

This solves problem. Thanks guys for suggesting different approaches.

zero
  • 11
  • 3
  • 1
    While that's what I assumed after John's answer, see my comments to it, it's not what Adobe Acrobat did with your example file. Oh well, many roads lead to Rome... – mkl Feb 22 '19 at 20:30