|
Hello iText users!
I have modified the PdfDocument.addWatermark() a
little bit. Normally one would need to set the watermark before opening the
document to have it shown on the first page also. Since in my application I'm
not able to provide the watermark before the document is opened I have adjusted
the addWatermark() method in a way that the watermark will be added to the page
immediately if the page is still empty.
Here is the code, hope it can find its way into the
next release:
/**
* Sets the <CODE>Watermark</CODE>. * * @param watermark the watermark to add * @return <CODE>true</CODE> if the element was added, <CODE>false</CODE> if not. */ public boolean add(Watermark
watermark)
{ if (writer != null && writer.isPaused()) { return false; } this.watermark = watermark; try { if (pageEmpty) { if (watermark != null) { float mt[] = watermark.matrix(); addImage(graphics, watermark, mt[0], mt[1], mt[2], mt[3], watermark.offsetX() - mt[4], watermark.offsetY() - mt[5]); } } } catch (DocumentException e) { e.printStackTrace(); } return true; } Kind regards,
Gerald.
|
