How to add a watermark to your ODS PDF output


The sample code in the Full Code section shows how to place an image behind a table in the ODS PDF destination using the style attribute BACKGROUNDIMAGE.

Please note that the size of the image is not controlled by SAS®, and the background image should adhere to the parameters described in SAS Note 46333, "Recommended attributes for images included in PDF files generated by ODS."

When you use PROC TEMPLATE code to add a background image to SAS/GRAPH® output, specify the following graphics option:

goptions transparency;


Full Code

The test code creates a PDF file that uses a background image on the document. For an ODS GRAPHICS procedure like SGPLOT, set transparency within the procedure as there is not a transparency setting within the style definition that will apply.

ods path (prepend) work.template(update) sashelp.tmplmst;
proc template;
   define style watermark_pearl;
     parent=styles.pearl;
      style Table from Table /
         cellpadding = 5pt
         borderspacing = .05pt
         borderwidth = .1pt
         frame = box
         bordercolor = cx919191
         bordercollapse = collapse
         backgroundcolor=_undef_  ;
      class Header /
         color = cx000000
         backgroundcolor = _undef_
         bordercolor = cxB0B7BB
         bordercollapse = collapse;
    class body from document /
          backgroundimage="<directory>\draft.png";
   end;
run;

title;
options nodate nonumber;
ods html close;
ods pdf file="watermark.pdf" style=watermark_pearl notoc;

proc report data = sashelp.class;
run;

goptions transparency;

proc gchart data=sashelp.class;
    vbar age;
run;
quit;

proc sgplot data=sashelp.class noopaque nowall pad=0;
    vbar age / transparency=.5;
run;
    


Output

watermark.pdf