DITA and XMetaL Discussion

XMetaL Community Forum DITA and XMetaL Discussion watermark in PDF output

  • IF

    watermark in PDF output

    Participants 6
    Replies 7
    Last 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. isabelle

    Reply

    Derek Read

    Reply to: watermark in PDF output

    No. The DITA OT and / or RenderX XEP settings would need to be modified to accomplish this.

    Reply

    Su-Laine Yeo

    Reply to: watermark in PDF output

    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-Laine

    Reply

    Derek Read

    Reply to: watermark in PDF output

    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.

    Assumptions:
    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”.

    Required Changes:
    1. Locate your DITA OT folder. If you are not sure how deployment works or which DITA OT to modify you should see these:
    http://forums.xmetal.com/index.php/topic,1008.0.html
    http://forums.xmetal.com/index.php/topic,237.0.html

    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 :
    demoxmfoCustomizationcommonartwork

    Example:
    demoxmfoCustomizationcommonartworkwatermark_draft_gold_outline.pdf

    3. Open the following file inside our plug-in:
    demoxmfoCustomizationfoxslxm_layout_masters_overrides.xsl

    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')]"
          mode="layout-masters-processing">
               
             
             
                   
             

       
      url('Customization/OpenTopic/common/artwork/watermark_draft_gold_filled.pdf')
      no-repeat
      center
      center

         
       

              match="fo:region-body[contains(parent::*/@master-name,'even')] | fo:region-body[contains(parent::*/@master-name,'last')]"
          mode="layout-masters-processing">
               
             
             
                   
             

       
      url('Customization/OpenTopic/common/artwork/watermark_draft_gold_filled.pdf')
      no-repeat
      center
      center

     
         
       

    5. Save the XSL file.

    How it Works:
    1. When you generate output the DITA OT copies the “artwork” (all files) from demoxmfoCustomizationcommonartwork to the output folder in the following subfolder structure:
    Customizationcommonartwork

    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:
             background-image="url('Customization/OpenTopic/common/artwork/watermark_draft_gold_outline.pdf')"
          background-position-horizontal="center"
          background-position-vertical="center"
          background-repeat="no-repeat"
          margin-bottom="1in"
          margin-left="0.75in"
          margin-right="1.25in"
          margin-top="1in"/>

    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').

    Additional Notes:
    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.

    External References:
    http://www.w3schools.com/xslfo/obj_region-body.asp
    http://www.renderx.com/tutorial.html (search for “background-image” on that page)

    Reply

    IF

    Reply to: watermark in PDF output

    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. isabelle

    Reply

    txvia

    Reply to: watermark in PDF output

    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.

    Reply

    Bonie

    Reply to: watermark in PDF output

    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?

    Reply

    barbwire

    Reply to: watermark in PDF output

    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.

    Reply

  • You must be logged in to reply to this topic.

Lost Your Password?

Products
Downloads
Support