DITA and XMetaL Discussion
XMetaL Community Forum › DITA and XMetaL Discussion › watermark in PDF output
IF September 20, 2010 at 5:54 pm
watermark in PDF outputSeptember 20, 2010 at 5:54 pmParticipants 6Replies 7Last Activity 12 years, 6 months ago
Is there a way to add a watermark to a PDF output directly from XMetal 6.0, e.g., configure the output to have the word “DRAFT” appear on every page? thanks. isabelleDerek Read September 20, 2010 at 6:48 pm
Reply to: watermark in PDF outputSeptember 20, 2010 at 6:48 pm
No. The DITA OT and / or RenderX XEP settings would need to be modified to accomplish this.Su-Laine Yeo September 20, 2010 at 11:37 pm
Reply to: watermark in PDF outputSeptember 20, 2010 at 11:37 pm
I believe you can set up Acrobat Distiller to automatically add a watermark to PDF files. When creating a PDF in XMetaL, use the “XMetaL Enhanced PDF via RenderX XEP and Acrobat Distiller” option, and whatever settings you've configured for Acrobat Distiller should be picked up.
If you want to go the route of modifying the DITA Open Toolkit, the dita-users group on Yahoo! has a thread which might be helpful: http://tech.groups.yahoo.com/group/dita-users/message/16373 .
Su-LaineDerek Read September 22, 2010 at 1:15 am
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
demoxmfoCustomizationcommonartworkto the output folder in the following subfolder structure:
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)IF September 24, 2010 at 12:04 am
Reply to: watermark in PDF outputSeptember 24, 2010 at 12:04 am
Thank you very much for taking the time to write such clear instructions. This worked flawlessly. I especially appreciate the “how it works” section. Thanks. isabelletxvia September 16, 2011 at 2:52 pm
Reply to: watermark in PDF outputSeptember 16, 2011 at 2:52 pm
Hi Derek: I have a similar question related to this: If I just want to add a background image only on the cover page and that no other pages should have it, how can I do it? Furthermore, I'd like the background image to fill up my entire cover page, what parameters should I set to make that happen? Thanks for your help.Bonie March 23, 2016 at 9:40 am
Reply to: watermark in PDF outputMarch 23, 2016 at 9:40 am
Hi Derek: I have a similar question related to this [url=http://www.phanyc.org/]Testogen blog post here[/url]: If I just want to add a background image only on the cover page and that no other pages should have it, how can I do it? Furthermore, I'd like the background image to fill up my entire cover page, what parameters should I set to make that happen? Thanks for your help.
I'd like to set an image that covers the entire first page too without any white border space in a PDF doc.
And then on the rest of the pages have it as the background but very translucent so it's barely visible. Is there any way to do this guys?barbwire March 24, 2016 at 9:48 am
Reply to: watermark in PDF outputMarch 24, 2016 at 9:48 am
Hi Derek: I have a similar question related to this: If I just want to add a background image only on the cover page and that no other pages should have it, how can I do it? Furthermore, I'd like the background image to fill up my entire cover page, what parameters should I set to make that happen? Thanks for your help.
If XSL developer has been expert, there are usually separate XSL templates for cover page and “common” pages. So in other words: it is possible to do such thing to the XSL style sheets.
For image to fill up whole page… I think, that you can do maybe fo:block-container which has absolute position. And then give the block-container correct values for top, left, height, width.
- You must be logged in to reply to this topic.