Tip: a dynamic watermark defined by variables!

This forum is for all Flare issues related to PDF, eBook, Microsoft Word, Adobe FrameMaker, XPS, and XHTML book targets.
Post Reply
AlexFox
Sr. Propeller Head
Posts: 149
Joined: Thu Oct 19, 2017 1:56 am

Tip: a dynamic watermark defined by variables!

Post by AlexFox »

Hi all,

I've seen a few threads around adding watermarks easily to PDFs so I thought I'd share what I put together the other day. This is a watermark that you can enable/disable via conditional text and when enabled, you can change the caption, colour, font-size (whatever you like really) via variables.

Step 1:
Create a new Condition Tag/Set and call it Watermark (for example) - I use a several elements in my PageLayouts that I toggle with conditional text, so my tag is Settings_PageLayouts.Watermark
Image

Step 2:
Create a new Variable set called Watermark and add the HTML attributes you'll want to be able to change in the future (note that you don't need to name them per the HTML spec, I just have out of habit):
Image

Step 3:
In the PageLayout you'd like the watermark to appear on, create a new decoration frame and position it as you'd like the watermark to appear.
Edit the frame contents and add a <p> block with the contents [%=Watermark.Caption%] (assuming you called your Variable set 'Watermark' and the definition you wish to use for the content of your watermark 'Caption').
Conditionally tag the <p> block with your newly added condition from step 1.
Save the frame contents and remember to sink it to the bottom of the canvas (Layout > Depth > Sink to Bottom) to ensure the watermark does not appear on top of the body content of your PDF.
Image

Step 4:
Save and close the PageLayout, then re-open it in the Internal Text Editor
Locate the code for the frame you've just added, it will look something like:

Code: Select all

<Frame X="30px" Y="124px" Width="210px" Height="58px" Flow="decoration4" Right="362px" Bottom="749px">
  <Content>
    <xhtml:html xmlns:xhtml="http://www.w3.org/1999/xhtml">
      <xhtml:body>
        <xhtml:p MadCap:conditions="Settings_PageLayouts.Watermark">[%=Watermark.Caption%]</xhtml:p>
      </xhtml:body>
    </xhtml:html>
  </Content>
</Frame>
Edit the <xhtml:p> so that it reads:

Code: Select all

<xhtml:p xhtml:style="text-align: center;text-transform: [%=Watermark.text-transform%];font-weight: [%=Watermark.font-weight%];font-style: [%=Watermark.font-style%];color: [%=Watermark.color%];font-size: [%=Watermark.font-size%];" MadCap:conditions="Settings_PageLayouts.Watermark">
Save the PageLayout and re-open it in the WYSIWYG editor, you may then copy and paste this frame onto any additional pages you may need to (you'll need to sink the body frame to the bottom to be able to select the watermark frame, remember to sink the watermark frame(s) to the bottom before saving).

Save and close the PageLayout, you'll now be able to set up a Print Target to use the selected PageLayout and you'll be able to dynamically change the Watermark each time whenever you need to. I recommend using the Variable settings I posted above, especially the #f0f0f0 colour as it's the closest you'll get to actual transparency.

Hope you find this useful!
AlexFox
Sr. Propeller Head
Posts: 149
Joined: Thu Oct 19, 2017 1:56 am

Re: Tip: a dynamic watermark defined by variables!

Post by AlexFox »

This is a slightly similar solution to this post however with this solution you can edit the attributes of the watermark and not just the text.
daStern
Jr. Propeller Head
Posts: 3
Joined: Wed Jan 10, 2018 4:30 am

Re: Tip: a dynamic watermark defined by variables!

Post by daStern »

Just implemented this for our PDFs - works a treat.

Thanks Alex.
ChoccieMuffin
Senior Propellus Maximus
Posts: 2630
Joined: Wed Apr 14, 2010 8:01 am
Location: Surrey, UK

Re: Tip: a dynamic watermark defined by variables!

Post by ChoccieMuffin »

Gotta say, this solution has just gone into our docs set and I couldn't be happier - thanks to AlexFox for this.

(Note to MadCap if you're reading this - you should include something like this in the Flare docs.)
Started as a newbie with Flare 6.1, now using Flare 2023.
Report bugs at http://www.madcapsoftware.com/bugs/submit.aspx.
Request features at https://www.madcapsoftware.com/feedback ... quest.aspx
Post Reply