Am 09.05.2017 um 12:10 schrieb Asgeir Hølleland:

Hi

I’m quite new to PDFBox and trying to find my way around. I find the documentation to be a bit confusing as I cannot find a way to commit a multiply (blend mode) to the document. Here is an outtake of my current attempt although I must admit that I do not fully understand all the PDF and PDFBox concepts yet.

COSDictionary dictionary = pdfBoxDocument.getPage(1).getCOSObject();
PDExtendedGraphicsState pdExtGfxState = new PDExtendedGraphicsState(dictionary); PDGraphicsState gfxState = new PDGraphicsState(pdfBoxDocument.getPage(1).getMediaBox());
gfxState.setBlendMode(BlendMode./MULTIPLY/);
pdExtGfxState.copyIntoGraphicsState(gfxState);
SetGraphicsStateParameters gfxParameters = new SetGraphicsStateParameters();

Could someone tell me whether I’m on the right track or doing this all wrong?

How do I set the graphics state parameters to the documents objects?


You can only set a blend mode if you are creating a document. Changing an existing document is tricky, it would depend on the document. It's probably better that you get a copy of Adobe Acrobat Pro.

What you did above does not make any sense, i.e. creating a ExtGState object from a page, this won't work. You can only do this with a page content stream, see in the examples, e.g. helloworld.java.

PDExtendedGraphicsState pdExtGfxState = new PDExtendedGraphicsState();

pdExtGfxState.setBlendMode(BlendMode./MULTIPLY/);

Then in your PDPageContentStream (see examples), you set the ExtGState with
cs.setGraphicsStateParameters(pdExtGfxState).


hre's an example, although without blendmode:
https://stackoverflow.com/questions/40267719/pdfbox-2-1-0-when-printed-from-ie11-transparent-text-watermark-has-opaque-ba

Tilman

Reply via email to