Home › Forums › DITA and XMetaL Discussion › watermark in PDF output › Reply To: watermark in PDF output
Reply to: watermark in PDF outputSeptember 22, 2010 at 1:15 am
The thread at that yahoo group might be a little hard to translate for use with the “XMetaL Enhanced PDF via RenderX XEP” deliverable type (assuming that is the one being used) because the suggestion there is actually for PDF2 (which in our UI is exposed as the deliverable “Book via RenderX”). “XMetaL Enhanced PDF via RenderX XEP” parameterizes a number of things that the other one doesn't and so it differs significantly in this particular area.
There are going to be various ways to solve this: you could parameterize parts of this solution yourself, or extract the path to the image file you wish to embed from some attribute value in the DITA map content, or perhaps do something in ANT, or even insert the text directly using FO statements. I won't try to guess what the best way to do those are (they will vary depending on your requirements). Instead I will just provide the bare minimum to get this working. If you need something more complex you could build on the code here.
1. You have installed an unmodified version of XMetaL Author Enterprise 6.0 (if changes have been made then you will need to take those into account).
2. You are generating output using the deliverable called “XMetaL Enhanced PDF via RenderX XEP”.
3. You wish to keep your PDF file sizes to a minimum.
4. You wish to embed the word “DRAFT” behind all other content centered on every page.
5. You want this to be easily modified and have access to an application you can use to create “PDF images” (single page PDF documents) or images of other types in case you are not happy with my “artwork”.
1. Locate your DITA OT folder. If you are not sure how deployment works or which DITA OT to modify you should see these:
2. Copy one of the attached “PDF images” (after unzipping the ZIP archive) into the following folder in our plug-in inside your copy of the
3. Open the following file inside our plug-in:
4. Make these additions (listed in blue) inside xm_layout_masters_overrides.xsl
match="fo:region-body[contains(parent::*/@master-name,'odd')] | fo:region-body[contains(parent::*/@master-name,'first')]"
match="fo:region-body[contains(parent::*/@master-name,'even')] | fo:region-body[contains(parent::*/@master-name,'last')]"
5. Save the XSL file.
How it Works:
1. When you generate output the DITA OT copies the “artwork” (all files) from
2. The FO file is generated in the output folder.
3. A link to the background image is inserted into the FO file by the modified XSLT above along with appropriate attributes so that the FO contains something like this:
4. When RenderX reads the FO file it finds the PDF image relative to it and digs down into the path specified in url('Customizationcommonartworkwatermark_draft_gold_outline.pdf').
If you do not like the sample “PDF images” I have provided here you may make your own with a suitable application.
Other file types can also be embedded, including JPG, however, because PDF images like these consist of just “text” and a few PDF codes they are very tiny. See RenderX XEP documentation for all file types you can embed into PDF documents.
“PDF images” (of this type) are infinitely “zoom-able” and so should look nice at any resolution vs embedding JPG or other raster (bitmap) image type.
Keep in mind that if an image is too large to fit into a given FO region it may simply not appear in the PDF generated by RenderX XEP. If yours is not appearing try a smaller image (width x height) to eliminate that possibility before checking the FO for correct paths and filenames, etc.
RenderX has extensions for scaling and resizing background images. These are not part of standard XSL-FO so not discussed here. Consult RenderX XEP documentation if this is a need.
http://www.renderx.com/tutorial.html (search for “background-image” on that page)