kumarjasper Posted October 4, 2006 Share Posted October 4, 2006 Hi i am trying to get the waternark on my pdf. But the water mark overlaps the Text on PDF.But i want the water mark to be translucent. i m using the below code to get watermark on PDF. public byte[] addWatermark(byte[] bytes) { ByteArrayOutputStream bos = new ByteArrayOutputStream(); try { PdfReader reader = new PdfReader(bytes); int n = reader.getNumberOfPages(); PdfStamper stamp = new PdfStamper(reader, bos); int i = 0; PdfContentByte under; BaseFont bf = BaseFont.createFont(BaseFont.HELVETICA,BaseFont.WINANSI, BaseFont.EMBEDDED); while (i < n) { i++; under = stamp.getUnderContent(i); under.setGrayFill(0.9f); under.beginText(); under.setFontAndSize(bf, 40); under.showTextAligned(PdfContentByte.ALIGN_CENTER, "PREVIEW ONLY",300, 500, 0); under.endText(); } stamp.close(); } catch (Throwable de) { de.printStackTrace(); } return if anyone knows about how to make watermark transparetn so that the text will be visisble to users. ThanksKumar Link to comment Share on other sites More sharing options...
C-Box Posted October 5, 2006 Share Posted October 5, 2006 Why don't you use the Backgroundband of JasperReport where you can put your text in background of the report content!?!?! (at each Page) So you needn't change the PDF afterwards. hthC-Box Link to comment Share on other sites More sharing options...
kumarjasper Posted October 5, 2006 Author Share Posted October 5, 2006 in our office we have Ultimate Guide version 2.2 but it doesn't say anything regarding background bands. can you please let me know how to use the background band. fast reply is appreciated. ThanksKumar Link to comment Share on other sites More sharing options...
C-Box Posted October 6, 2006 Share Posted October 6, 2006 Well we don't have the UltimateGuide but I learned a lot whith Trial&Error!:P Well here you go:open your JRXML in iReport.go to the band-properties dialogselect the BACKGROUND Band (first band)set a band height (e.g. half page-height, or even whole page-height --> see report properties (paper size) depends where you want to place your watermark)put your Text/graphic etc at this bandvoilá that's it.B) [/ol] just try! hthC-Box Link to comment Share on other sites More sharing options...
kumarjasper Posted October 6, 2006 Author Share Posted October 6, 2006 i tried it but still it overlaps the Text. Here i am attaching the sample picture of it. Here is the code i used it for in the background band. <background> <band height="731" isSplitAllowed="true"> <rectangle> <reportElement key="rectangle" positionType="Float" x="0" y="0" width="572" height="731"/> <graphicElement/> </rectangle> <staticText> <reportElement x="56" y="163" width="452" height="60" mode="Transparent"> <printWhenExpression><![CDATA[new Boolean($F{previewOnly}.equals("PREIVIEW"))]]></printWhenExpression> </reportElement> <textElement textAlignment="Center"> <font fontName="Book Antiqua" isBold="false" isItalic="true" size="48"/> </textElement> <text><![CDATA[PREVIEW ONLY]]></text> </staticText> </band> </background>Post edited by: kumarjasper, at: 2006/10/05 19:07 Link to comment Share on other sites More sharing options...
C-Box Posted October 6, 2006 Share Posted October 6, 2006 You forgot to attach the image!??! Things like this I must see! :woohoo: PS: I do attach a sample that I've made right now... Perhaps it helps!?!??! hthC-Box [file name=BackGroundSample.jrxml size=5940]http://www.jasperforge.org/components/com_joomlaboard/uploaded/files/BackGroundSample.jrxml[/file]Post edited by: CBox, at: 2006/10/05 19:33 Link to comment Share on other sites More sharing options...
kumarjasper Posted October 18, 2006 Author Share Posted October 18, 2006 i attached image in background band. But subreports overlapped on background image. is there any solution to make image transparent. Link to comment Share on other sites More sharing options...
kumarjasper Posted October 20, 2006 Author Share Posted October 20, 2006 does any know how to show background image as transparent image. Fast reply is very much appreciated.ThanksKumar Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now