You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@pdfbox.apache.org by Gilles Coppex <g....@gmail.com> on 2015/01/08 19:52:08 UTC
PDFBox drawXObject alpha channel
Dear all,
Can we reduce the alpha channel before calling the drawXObject() method?
I would like to embedd the other pdf with a 33% transparency.
P.S.: I reposted this question as a new thread because it seems more
logical to separate topics.
Thanks a lot
G. Coppex
Re: PDFBox drawXObject alpha channel
Posted by John Hewson <jo...@jahewson.com>.
Yes, there’s not a built-in API for this, so you have to write the
PDF commands out yourself. PDF uses an external graphics state
object which you can enable with the “gs” operator:
Assuming you have a PDPageContentStream named “contents”:
PDExtendedGraphicsState gs1 = new PDExtendedGraphicsState();
gs1.setNonStrokingAlphaConstant(.33f);
page.getResources().put(COSName.getPDFName("gs1"), gs1);
… do what you like here
contents.saveGraphicsState()
contents.appendRawCommands("/gs1 gs\n”);
… draw your from
contents.restoreGraphicsState()
-- John
> On 8 Jan 2015, at 10:52, Gilles Coppex <g....@gmail.com> wrote:
>
> Dear all,
>
> Can we reduce the alpha channel before calling the drawXObject() method?
> I would like to embedd the other pdf with a 33% transparency.
>
>
> P.S.: I reposted this question as a new thread because it seems more
> logical to separate topics.
>
> Thanks a lot
>
> G. Coppex