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 only 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.setStrokeOpacity(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();



-------------------------------------------------------
This SF.Net email is sponsored by: IntelliVIEW -- Interactive Reporting
Tool for open source databases. Create drag-&-drop reports. Save time
by over 75%! Publish reports on the web. Export to DOC, XLS, RTF, etc.
Download a FREE copy at http://www.intelliview.com/go/osdn_nl
_______________________________________________
iText-questions mailing list
iText-questions@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/itext-questions

Reply via email to