You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@pdfbox.apache.org by Asgeir Hølleland <As...@knowit.no> on 2017/05/09 10:10:31 UTC
Blend Mode - Multiply
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?
Best regards,
Asgeir
---------------
[cid:image001.png@01D2C8BD.4135E170]
Asgeir Hølleland
Utvikler / Developer
Email: asgeir.holleland@knowit.no<ma...@knowit.no>
Mobil: +47 979 69 083
Knowit Experience AS
Besøksadresse: Nøstegaten 58, 5011 Bergen
Postadresse: Pb 453 Sentrum, 5805 Bergen
Norge | Sverige | Finland +47 55 33 39 00 | www.knowit.no<http://www.knowit.no/>
Re: Blend Mode - Multiply
Posted by Tilman Hausherr <TH...@t-online.de>.
Am 09.05.2017 um 12:57 schrieb Tilman Hausherr:
>
> pdExtGfxState.setBlendMode(BlendMode.MULTIPLY);
I forgot that this doesn't work yet, use this:
|pdExtGfxState.getCOSObject().setItem(COSName.BM,COSName.MULTIPLY);|
Re: Blend Mode - Multiply
Posted by Tilman Hausherr <TH...@t-online.de>.
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