Subject: rotate a watermark 2007-11-06 - By Damian Harvey
Back Is it possible to rotate a watermark created using getOverContent()? I haven't seen this in any examples and it isn't working for me.
I am using the following code but it is ignoring the rotation. I suspect this is from the absolute positioning. The image is created and the opacity is fine but it is not rotated at all.
Thanks,
Damian.
PdfContentByte over = stamper.getOverContent(1); PdfTemplate watermark = over.createTemplate(500, 500); BaseFont bf = BaseFont.createFont(BaseFont.HELVETICA, BaseFont.WINANSI , BaseFont.EMBEDDED); watermark.beginText(); watermark.setFontAndSize(bf, 72); watermark.setTextMatrix(0,0);
//I want to be able to internationalise this text watermark.showText("Draft Copy");
watermark.endText();
Image img = Image.getInstance(watermark); img.setAbsolutePosition(75, 400); img.setRotationDegrees((float)Math.PI / 4); //rotate 45 degrees
PdfGState gs1 = new PdfGState(); gs1.setFillOpacity(0.4f); over.setGState(gs1);
over.addImage(img);
-- Damian Harvey Director Locus Software Ltd www.locussoftware.co.uk
Is it possible to rotate a watermark created using getOverContent()? I haven& #39;t seen this in any examples and it isn't working for me.<br><br>I am using the following code but it is ignoring the rotation. I suspect this is from the absolute positioning. The image is created and the opacity is fine but it is not rotated at all. <br><br>Thanks,<br><br>Damian.<br><br><br>PdfContentByte over = stamper .getOverContent(1);<br>PdfTemplate watermark = over.createTemplate(500, 500);<br >BaseFont bf = BaseFont.createFont(BaseFont.HELVETICA, BaseFont.WINANSI
, BaseFont.EMBEDDED);<br>watermark.beginText();<br>watermark.setFontAndSize(bf, 72);<br>watermark.setTextMatrix(0,0);<br><br>//I want to be able to internationalise this text<br>watermark.showText("Draft Copy"); <br><br>watermark.endText();<br><br>Image img = Image.getInstance(watermark); <br>img.setAbsolutePosition(75, 400);<br>img.setRotationDegrees((float)Math.PI / 4); //rotate 45 degrees<br><br>PdfGState gs1 = new PdfGState(); <br>gs1.setFillOpacity(0.4f);<br>over.setGState(gs1);<br><br>over.addImage(img) ;<br clear="all"><br>-- <br>Damian Harvey<br>Director<br>Locus Software Ltd<br> <a href="http://www.locussoftware.co.uk">www.locussoftware.co.uk </a><br>
-- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ----- This SF.net email is sponsored by: Splunk Inc. Still grepping through log files to find problems? Stop. Now Search log events and configuration files using AJAX and a browser. Download your FREE copy of Splunk now >> http://get.splunk.com/ __ ____ ____ ____ ____ ____ ____ ____ ____ ____ iText-questions mailing list iText-questions@(protected) https://lists.sourceforge.net/lists/listinfo/itext-questions Buy the iText book: http://itext.ugent.be/itext-in-action/
|
|