The SAS Output Delivery System and reporting techniques

Using ODS RTF to add a watermark

Reply
Occasional Contributor
Posts: 16

Using ODS RTF to add a watermark

Is there a SAS style attribute or RTF control string that will add a watermark to an RTF document? If not, has anyone heard of this being done and could you suggest an approach?
SAS Super FREQ
Posts: 8,868

Re: Using ODS RTF to add a watermark

Hi:
A watermark attribute does exist. But, it only works for the HTML destination (not RTF). In ODS HTML, the watermark attribute allows you to "specify whether or not to make the image that is specified by BACKGROUNDIMAGE= into a "watermark." A watermark appears in a fixed position as the window is scrolled." (this description is straight from the documentation.) The value for WATERMARK is either ON or OFF (because it works in conjunction with BACKGROUNDIMAGE).
However, there is one thing you can try. Since Microsoft Word can read an HTML file, you could create an HTML file using BACKGROUNDIMAGE and WATERMARK (as shown below) and then open the HTML file with Microsoft Word. Once it's in Word, you can either save it as a .DOC file or save it as an RTF file. The image will be tiled in the browser and will also be tiled when Word opens it. Therefore, you should try to make the image very close in size to what you want the watermark to be in order to minimize tiling.

Here's the sample code...where I have kermit.jpg specified below, you would insert the name of your image file to be the watermark. You need the change to the style template because the table (in this case, from PROC REPORT), sits on the BODY of the HTML document. Therefore, you want to modify the BACKGROUNDIMAGE for the BODY of the document.
[pre]
ods path work.wmark(update)
sashelp.tmplmst(read);

proc template;
define style styles.water;
parent=styles.sasweb;
style body from body /
backgroundimage='kermit.jpg'
watermark=on;
end;
run;

ods msoffice2k path='c:\temp' (url=none)
file='test_watermark.doc' style=styles.water;

proc report data=sashelp.class nowd;
column name age height;
run;
ods msoffice2k close;

[/pre]

I do not know whether there's a way using RTF control strings to specify a watermark.

In the Microsoft Word help (I start there because Microsoft wrote the RTF specification) -- it says that watermarks are intended for a PRINTED document. MS Word help says:
"On the Format menu, point to Background, and then click Printed Watermark"
If I follow those instructions and insert a picture to be used as a watermark AND then save the file as an RTF file, it looks to me like my picture has been converted to RTF format and is inserted with a \pict control string. However, \pict does NOT point to my original picture...it is followed by the RTF graphics version of the picture. According to the RTF 1.5 spec, which I found here,
[pre]http://www.biblioscape.com/rtf15_spec.htm
[/pre]
"An RTF file can include pictures created with other applications. These pictures can be in hexadecimal (the default) or binary format. Pictures are destinations, and begin with the \pict control word. The \pict keyword is preceded by \*\shppict destination control keyword as described in the following example."

So if you can live with creating an HTML file and then instructing folks to open the HTML file with Word, this may be a solution that works for you. If you need to generate an RTF file with a watermark, then I do not believe that ODS can help you right now. I do not know whether future plans for RTF (or some other MS Word Markup Language) include plans for Watermark support.

cynthia
SAS Employee
Posts: 20

Re: Using ODS RTF to add a watermark

Cynthia asked me to reply.


Currently, there is no watermark support in the RTF files created by SAS.

The 1.6 RTF Specification supported by MS Word does not mention watermarks. But, you can apply a watermerk using the Format pulldown in Word and selecting "Background". You can follow the arrows from that point and all is good.

You can even save the DOC file as RTF and have the watermark preserved. When you re-open the RTF file, the watermark remains.

This is done by combination of techniques. Word embeds the image a hex translation with a \pict syntax, but makes it a a shape object with specific characteristics. It is placed in various parts of the section information and makes use of stored name and value pairs to pass information back to Word. The stored name/value pairs are part of Visual Basic.

The 1.6 RTF spec is careful about supporting older syntax in newer versions. We prefer to not support techniques we cannot be certain will be carried forward.

The best way to put a watermark on the document is currently in Word and saving as either an RTF file or DOC file. There are modifications that can be done in Word but will be lost when saved to an RTF file. This is not one of them.
Contributor
Posts: 23

Re: Using ODS RTF to add a watermark

Posted in reply to wayne_sas
I wonder if there is a way to call a VBA macro when producing some RTF. It is pretty easy to make a VBA macro in word to add a watermark. Can we tell ODS/RTF to call this macro somehow? I know we can do it from windows by opening word with DDE, loading the RTF and calling the macro - but is there another way?
SAS Super FREQ
Posts: 8,868

Re: Using ODS RTF to add a watermark

Posted in reply to PhilMason
Hi, Phil:
My question would be: what happens if SAS is out of the picture.?

In other words, if you create a little file by manually typing in Word and then define a macro in that document to load the watermark. If you then save that Word file as an RTF file, do the macro instructions carry over into the RTF version or do you get that snarky message that some features in the Word doc will be lost?

Just curious. I don't -do- VBA or Word macros because I'd have to jettison something in my brain to make room for a new language.

cynthia

(I suspect that you'll get the \pict image in the RTF file and not the instruction to use the macro -- but that's just speculation on my part.)
Super Contributor
Super Contributor
Posts: 3,174

Re: Using ODS RTF to add a watermark

Posted in reply to Cynthia_sas
Suggest checking the SAS support website for technical and conference paper resources on ODS and calling a VBA macro. Here is a Google advanced search argument (limited to searching the SAS.COM site only) which yielded some matches:

ods rtf call vba macro site:sas.com

Scott Barry
SBBWorks, Inc.
Ask a Question
Discussion stats
  • 5 replies
  • 1309 views
  • 0 likes
  • 5 in conversation