Re: Question about watermarking in FOP.
[EMAIL PROTECTED] forwarded: I saw you answer on the FOP-user forum about using an image in REGION-BEFOR as a substitution for watermark. I tried this technique and it worked. But I still have a problem, because the image appears on the top of text in the main body, i.e. I cannot see text behind the image. It seems the recommended technique for generating watermarks is still postprocessing with iText, unless background image is fully working. http://www.lowagie.com/iText/ Here is a demonstration how to achive this. The iText code is manly lifted directly from the iText tutorial. Pass the name of the .fo file as parameter 1, the target file name as parameter 2 and the x and y offset for the watermark as parameters 3 and 4 respectively. import java.io.*; import com.lowagie.text.*; import com.lowagie.text.pdf.*; class rendtest1 { public static void main(String args[]) { try { ByteArrayOutputStream fopout=new ByteArrayOutputStream(); FileOutputStream outfile=new FileOutputStream(args[1]); Driver driver =new Driver(new org.xml.sax.InputSource(args[0]),fopout); driver.setRenderer(Driver.RENDER_PDF); driver.run(); PdfReader reader = new PdfReader(fopout.toByteArray()); int n = reader.getNumberOfPages(); Document document = new Document(reader.getPageSizeWithRotation(1)); PdfWriter writer = PdfWriter.getInstance(document, outfile); Watermark watermark = new Watermark(Image.getInstance("g.jpg"), Integer.parseInt(args[2]),Integer.parseInt(args[3])); document.add(watermark); document.open(); PdfContentByte cb = writer.getDirectContent(); PdfImportedPage page; int rotation; int i = 0; while (i < n) { i++; document.setPageSize(reader.getPageSizeWithRotation(i)); document.newPage(); page = writer.getImportedPage(reader, i); rotation = reader.getPageRotation(i); if (rotation == 90 || rotation == 270) { cb.addTemplate(page, 0, -1f, 1f, 0, 0, reader.getPageSizeWithRotation(i).height()); } else { cb.addTemplate(page, 1f, 0, 0, 1f, 0, 0); } System.out.println("Processed page " + i); } document.close(); } catch( Exception e) { e.printStackTrace(); } } } J.Pietschmann
Re: Question about watermarking in FOP.
I'm afraid I don't know the answer to that one but I have forwarded your enquiry to the fop-user mailing list. You should join in, perhaps. Trev "Todeush, Serhiy" To: "'[EMAIL PROTECTED]'" [EMAIL PROTECTED]> cc: Subject: Question about watermarking in FOP. 25/05/2002 02:55 AM Hello, Trevor! My name is Serhiy Todeush. I am using FOP 0.20.3 to generate PDFs. Couple of days ago I run into problem with watermark in my documents because current version of FOP does not support BACKGROUND-IMAGE. I saw you answer on the FOP-user forum about using an image in REGION-BEFOR as a substitution for watermark. I tried this technique and it worked. But I still have a problem, because the image appears on the top of text in the main body, i.e. I cannot see text behind the image. (I use GIF file with transparent background as the image). Dou you know by any chance how to resolve the issue? Is there any way to bring main body text to foreground? May be you have some working example which you can share with me? I really appreciate your attention to my request. Thank you in advance, Serhiy
Re: AW: watermarking
Yes. The region-before and main body areas can fully overlap if required. "S. Jayaraman" <[EMAIL PROTECTED] To: <[EMAIL PROTECTED]> nsor.ch> cc: Subject: AW: watermarking 06/03/2002 08:37 PM Please respond to fop-user Will I be still able to put a watermark across the middle of my page ? Rgds Jay *** Use the region-before. Make it large enough to contain your image and then include a block (and if required an absolutely positioned block-container) with your image in the static-content for the region-before. (BTW this is the same technique as used in MS Word). Trev ** hello all Is there any way of adding some kind of watermark to a PDF document generated with FOP ? I am using FOP in a JSP environment. Thanks Chris
AW: watermarking
Will I be still able to put a watermark across the middle of my page ? Rgds Jay *** Use the region-before. Make it large enough to contain your image and then include a block (and if required an absolutely positioned block-container) with your image in the static-content for the region-before. (BTW this is the same technique as used in MS Word). Trev ** hello all Is there any way of adding some kind of watermark to a PDF document generated with FOP ? I am using FOP in a JSP environment. Thanks Chris
Re: watermarking
Use the region-before. Make it large enough to contain your image and then include a block (and if required an absolutely positioned block-container) with your image in the static-content for the region-before. (BTW this is the same technique as used in MS Word). Trev Chris Faulkner <[EMAIL PROTECTED] To: [EMAIL PROTECTED] world.com> cc: Subject: watermarking 05/03/2002 08:44 PM Please respond to fop-user hello all Is there any way of adding some kind of watermark to a PDF document generated with FOP ? I am using FOP in a JSP environment. Thanks Chris
Re: watermarking
I've heard some people using FOP for generating PDFs, then using iText afterwards to add watermarking to their dynamically FOP-generated PDFs. But I havent tested it myself. Good luck. Guillaume - Original Message - From: Chris Faulkner To: [EMAIL PROTECTED] Sent: Tuesday, March 05, 2002 10:44 AM Subject: watermarking hello allIs there any way of adding some kind of watermark to a PDF document generated with FOP ? I am using FOP in a JSP environment.ThanksChris
watermarking
hello all Is there any way of adding some kind of watermark to a PDF document generated with FOP ? I am using FOP in a JSP environment. Thanks Chris