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