XML technologies / XSL-FO / Examples of application / Watermarks & background images

 

Watermarks and background images

In this example a watermark is displayed in the background of a page.

It shows how any watermark can be placed in the background of the page. This watermark has to be specified in a page template (<fo:simple-page-master>), if you want to have it on all pages using this page template. Alternatively, a watermark or background image can be embedded in any block.

Source code

<fo:simple-page-master page-height="297mm" page-width="210mm" margin="20mm 15mm 30mm 15mm" master-name="PageMaster.Content"> ❶          
   <fo:region-body margin="25mm 0mm 15mm 0mm" background-image="Images\confidential.EPS" background-position="center"/> ❷
      <fo:region-before .../> 
      <fo:region-after .../> 
</fo:simple-page-master>

❶ A <fo:simple-page-master> is defined. It determines the structure and the layout of a page.

❷ The watermark is embedded in the <fo:region-body> element and is displayed in the body region of the page. The background-image attribute determines the path to the background image to be inserted. With the background-position attribute its position is determined (in this example the background image is centred).

 

back to top