We use the FOP driver class to accomplish pdf creation. The Configuration class allows us to set the baseDir property for external images. Below is another code snippet that shows how we do this.
The String baseDir would contain something like, "C:/images"; If this directory had an image called draft.jpg in it, such as in my first code snippet, the image would be rendered in the pdf. myDriver = new Driver(); // Tell the FOP Driver what logger to use. // This must be done in the order it is here. Log4JLogger log4j = new Log4JLogger(dora); MessageHandler.setScreenLogger(log4j); myDriver.setLogger(log4j); // What other kinds can be rendered? // AWT, MIF, PCL, PDF, PRINT, PS, SVG, TXT, XML myDriver.setRenderer(Driver.RENDER_PDF); Configuration.put("baseDir", baseDir); InputSource is = new InputSource(fo); myDriver.setInputSource(is); myDriver.setOutputStream(pdf); myDriver.run(); /** * Contact information. */ public class INFO { static final String NAME = "Derrick Koes"; String title = "Senior Software Engineer"; String company = "Smith & Nephew Endoscopy"; URL companyURL = new URL(" http://www.smith-nephew.com/index-flash.html"); String aolIM = "codeauthor2001"; String EMAIL = "[EMAIL PROTECTED]"; String PHONE = "(978) 474-6302"; String FAX = "(978) 749-1487"; String QUOTE = "No, try not, do or do not, there is no try." } -----Original Message----- From: David Beck [mailto:[EMAIL PROTECTED] Sent: Friday, April 16, 2004 3:35 PM To: Koes, Derrick Subject: Re: RE: add watermark to generated PDF using FOP Derrick, Thanks for your info. I am quite new to XSL. So, just bear with me. You use the element <xsl:text> to refer to an external image. I do not know exactly how it works. Would you please tell me how to refer to an external image using the following snip codes given the image watermark_draft.gif which is stored int the directory "C:/image/" ? thanks, Dave <fo:layout-master-set> <fo:simple-page-master page-width="21cm" page-height="29.7cm" master-name="left"> <fo:region-body margin-top="1cm" margin-bottom="1cm"> <xsl:attribute name="background-image"> <xsl:text>watermark_draft.gif</xsl:text> </xsl:attribute> </fo:region-body> </fo:simple-page-master> </fo:layout-master-set> ---- On Fri, 16 Apr 2004, Koes, Derrick ([EMAIL PROTECTED]) wrote: > > I use a "watermark" for generated "draft" pdf documents. > I accomplished this with a background image, which isn't a true watermark, > but is adequate for the purpose. > > Snip... > > <fo:simple-page-master master-name="formal" xsl:use-attribute-sets="master"> > <fo:region-body margin-top="2.8in" margin-bottom="0.75in"> > <xsl:if test="$status = 'draft'"> > <xsl:attribute name="background-image"> > <xsl:text>draft.jpg</xsl:text> > </xsl:attribute> > </xsl:if> > </fo:region-body> > > If you need an overlay on the image itself, you'll like need to use svg. We > did this to "annotate" images with shapes and text. > > Derrick > > > > > -----Original Message----- > From: David Beck [mailto:[EMAIL PROTECTED] > Sent: Friday, April 16, 2004 1:07 PM > To: [EMAIL PROTECTED] > Subject: add watermark to generated PDF using FOP > > Good Friday! > > I have a problem with adding watermark. Hopefully someone can > help me with this. > > I use FOP and xsl to display a tiff image with multipage in PDF > format in the browser. I have done this part. Now what I need is > that I want to add a watermark(say, COPY ONLY or SAMPLE) to each > generated PDF before I display them in the browser. So,when > users view those PDFs in browser, the watermark appears either > as foreground or background to protect those images from being > stolen. > > Can I do something directly in XSL file? or I have to use FOP to > do this task? I searched our archives and haven't got an answer > yet. Does anyone have this experience? Any help will be > appreciated. Thanks a lot. > > Dave > > > > ________________________________________________ > Get your own "800" number > Voicemail, fax, email, and a lot more > http://www.ureach.com/reg/tag > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > This electronic transmission is strictly confidential to Smith & Nephew and > intended solely for the addressee. It may contain information which is > covered by legal, professional or other privilege. If you are not the > intended addressee, or someone authorized by the intended addressee to > receive transmissions on behalf of the addressee, you must not retain, > disclose in any form, copy or take any action in reliance on this > transmission. If you have received this transmission in error, please > notify the sender as soon as possible and destroy this message. > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > > ________________________________________________ Get your own "800" number Voicemail, fax, email, and a lot more http://www.ureach.com/reg/tag --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] This electronic transmission is strictly confidential to Smith & Nephew and intended solely for the addressee. It may contain information which is covered by legal, professional or other privilege. If you are not the intended addressee, or someone authorized by the intended addressee to receive transmissions on behalf of the addressee, you must not retain, disclose in any form, copy or take any action in reliance on this transmission. If you have received this transmission in error, please notify the sender as soon as possible and destroy this message. --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]