I tried that but it didn't work. After looking at the headers_and_watermarks
example, I tried using events and it seems to work now. Why would using events
(onStartPage) work when the other method didn't?
example, I tried using events and it seems to work now. Why would using events
(onStartPage) work when the other method didn't?
-------------- Original message --------------
> Put the setGState() outside the beginText()/endText(). It may also be a
> problem with Acrobat 5 that has some problems with opacity.
>
> > -----Original Message-----
> > From: [EMAIL PROTECTED]
> > [mailto:[EMAIL PROTECTED] On Behalf Of John
> > Sent: Friday, February 04, 2005 4:58 AM
> > To: itext-questions@lists.sourceforge.net
> > Subject: [iText-questions] Watermark problem in Acrobat 5
> >
> > I'm having problems adding a text watermark to a pdf. My
> > code works fine for Acrobat 6.0 but not Acrobat 5.0.5. In
> > 5.0.5, the first page will print. The watermark will be on
> > it, although it does not show properly through the text. It
> > on ly shows on the areas without text. A second page then
> > prints with an error message: "offending command: restore"
> > The line that seems to cause the error is the setFillOpacity
> > marked below. If I comment that out, the watermark prints
> > without an error, although it is dark and overwrites the
> > text. I need it to be light and be behind the text. Does
> > anyone have any idea why this is happening or maybe some
> > suggestions to try?
> >
> > Thanks!
> > John
> >
> > // get layer underneath text
> > PdfContentByte cb = writer.getDirectContentUnder();
> >
> > ...
> >
> > // define watermark graphic state
> > PdfGState watermark_gstate;
> > watermark_gstate = new PdfGState();
> > -> watermark_gstate.setFillOpacity(0.3f);
> > watermark_gstate.setStrokeOpac ity(0.3f);
> >
> > BaseFont bf = BaseFont.createFont(BaseFont.HELVETICA,
> > BaseFont.CP1252, BaseFont.NOT_EMBEDDED);
> > cb.beginText();
> > // add watermark
> > cb.setGState(watermark_gstate);
> > cb.setRGBColorFill(0, 0, 0);
> > cb.setFontAndSize(bf, watermark_font);
> > cb.showTextAligned(PdfContentByte.ALIGN_CENTER,
> > watermark_text, pageWidth / 2, pageHeight / 2, watermark_angle);
> > cb.endText();
> >
> >
> >