Have read the book, searched, and experimented, but I can't seem to get
there...
In my onEndPage event, I am adding a watermark.  If I do this using
getDirectContentUnder, it works fine.  I can set the text, transparency,
color, etc.  But, if I use the getDirectContentOver, nothing is drawn.  My
code is below.

It shouldn't matter, but I am executing this from within ruby using RJB.  Am
able to do everything else I've tried (jfree charts, images, tables, etc.)
but not this.  Completely stuck and help is greatly appreciated.  I've
formatted my code for java style to make it easier to follow, but I promise
it is exactly the same code as I am using...

-----------------------------------------------------------------------------------------------

public void onEndPage(PdfWriter writer, Document document) {
...
// If I use the getDirectContentUnder method, everything is fine, with or
without transparency
//cb = writer.getDirectContentUnder();
// If I use the getDirectContentOver method, the watermark is not drawn at
all
cb = writer.getDirectContentOver();
PdfGState gState = new PdfGState();
gState.setFillOpacity(0.4f);
gState.setStrokeOpacity(0.4f);
cb.saveState();
cb.setGState(gState);
if (watermarkStyle.color != null) {
  cb.setColorFill(watermarkStyle.color);
}
cb.beginText();
if (watermarkFont != null && watermark.textStyle != null &&
watermark.textStyle.fontSize != null) {
  cb.setFontAndSize(watermarkFont, watermark.textStyle.fontSize)
}
cb.showTextAligned(Element.ALIGN_CENTER, pageBg.watermark.text,
document.getPageSize().width() / 2.0f, document.getPageSize().height() /
2.0f, watermark.rotation);
cb.endText();
cb.restoreState();
...
}

--------------------------------------------------------------------------
Thanks in advance
------------------------------------------------------------------------------
This SF.Net email is sponsored by the Verizon Developer Community
Take advantage of Verizon's best-in-class app development support
A streamlined, 14 day to market process makes app distribution fast and easy
Join now and get one step closer to millions of Verizon customers
http://p.sf.net/sfu/verizon-dev2dev 
_______________________________________________
iText-questions mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/itext-questions

Buy the iText book: http://www.1t3xt.com/docs/book.php
Check the site with examples before you ask questions: 
http://www.1t3xt.info/examples/
You can also search the keywords list: http://1t3xt.info/tutorials/keywords/

Reply via email to