How can I add a watermark to a page?
Asked by Daniel Serodio:

How can I add a "Draft" or "Obsolete" watermark to a page in Confluence?


Answers:
author: CharlesH
body: I developed a user macro to do this, using jQuery to position an attached image within the body of the page. You'll see it explained in this presentation I gave at the Atlassian Summit in 2011. Confluence has evolved since then, so it may need tweaking to work with the latest version.<http://www.atlassian.com/company/about/events/summit/2010/presentations/collaboration-and-projects/macros-reports-confluence.jsp>

comments: author: Daniel Serodio
body: Perfect, that's exactly what I was looking for, thanks. Is that macro available for download?


author: CharlesH
body: I've taken the original macro and updated it for Confluence 4.x. You'll find it in the [shared user macro library here](http://confluence.atlassian.com/display/DISC/watermark).


author: Doods Perea
body: Hi Charles - is this macro compatible with Confluence version 5.2? I tried using the macro but the image won't show on the page that contains the watermark image. I tried both providing the full URL and just the actual name of the image.


author: CharlesH
body: Hi Doods,

I just tried the macro with Confluence 5.0 and it works just like it does under 4.x, both for the Documentation theme and the default theme.

In my simple test I uploaded an image file as an attachment to the page where I want the watermark to appear, then just used the image file name and extension in the parameter for the user macro.

If you're doing the same, then it would help to inspect what's going on with the aid of some browser development tools, e.g. Firebug.

The general approach is for the watermark image to be added as a background image using javascript to the main div element which is the container for the page content. For the documentation theme this div element has the class "wiki-content". For the default theme this div is/was identifiable with an ID of "content". It could be that in 5.2 this has changed. I don't have an instance of 5.2 handy though...

Which theme are you using when you try out the macro?

Charles


author: Rethabile Morena
body: Thanks for this macro - works like a charm.

Is it possible to incorporate the ability for the macro to appear when the content is exported (Word/PDF)? Currently it does not.

Regards

Rethabile M


author: Dave Nurney
body: Charles, I know this macro was written some years ago, but we are setting up an enterprise intranet using confluence and we have installed your watermark macros with Confluence 6.8.1 to provide the ability for users to create pages with a watermark or background image.

We have just had the solution pen tested and the report advises that there is a potential vulnerbility with your macro:

*This macro passed the imgsrc parameter unsanitised to the code, so the jQuery function could be broken out of and closed, and malicious JavaScript executed afterwards. In order to do this, the value had to start with http or else it would be manipulated by the pre-processor.*   
*The consultants were able to use this macro with the following payload and get JavaScript execution.*

*http://')} \</script\>\<script\>alert("ptp xss")\</script\>*

Is there anyway you could possibly update your macro to remove this vulnerability?

[@CharlesH1](/t5/user/viewprofilepage/user-id/781632) @\[deleted\]


author: Paulina Riera
body: We are on an older Confluence version. Is this macro compatible with 3.5 and on the documentation theme?

Thanks.

-p

comments: author: CharlesH
body: It should do (especially the code offered in the slideshare presentation) as I created the user macro against that version and theme I think. Give it a try is the best advice I think.


author: Renjith Pillai
body: Somthing similar

<http://wiki.customware.net/repository/display/AtlassianPlugins/Page+Approval+Plugin>


Tags: watermark