Word Hacks [Electronic resources]

Andrew Savikas

نسخه متنی -صفحه : 162/ 47
نمايش فراداده

Hack 24 Create a Custom Text Watermark

Instead of using Word's predefined options, you can create your own watermark text with a few lines of PostScript slipped inside your document.

Word includes a neat feature for inserting a watermark behind a document. You can either choose a picture to use as the watermark, or choose from among a list of text options.

To see the available options for text watermarks, select FormatBackgroundPrinted Watermark to display the dialog shown in Figure 3-43.

Figure 3-43. You must choose from a predefined list of text watermarks

But what if the text you'd like to use for a watermark isn't on that list? Or how about including the date or document author as part of the watermark?

Fortunately, you can use a PRINT field and a few lines of PostScript to create your own custom watermark.

You can also use the PRINT field to put crop marks on a document [Hack #26] .

The PRINT field embeds PostScript instructions within a document. PostScript is a computer language that tells a printer how to draw a page. Most modern printers have a built-in PostScript interpreter that can translate PostScript instructions into a printed page.

If you go to FilePrint and choose "Print to file" instead of sending the file to a printer, the file may have a .prn extension, but it's really a PostScript file.

A PRINT field works only if you print to a PostScript-compatible printer. See [Hack #23] for one method of determining if your printer is a PostScript printer.

To print crop marks, you need to include the PostScript instructions for drawing the marks on a page within the PRINT field.

There are some important things to note about PostScript before diving in:

The comment character in PostScipt is %. The interpreter ignores any line that begins with a %.

PostScript uses standard (X,Y) coordinates to refer to each page, with 0,0 at the bottom left and 612,792 at the top right on a standard letter page. The numbers represent points measuring 1/72 of an inch.

Unlike most computer languages, the arguments to a PostScript function come before the function itself. For example, to move to the point 10,10 on a page, you would type 10 10 moveto, not moveto 10 10.

For a detailed reference on PostScript, see the PostScript Language Tutorial & Cookbook located at http://www-cdf.fnal.gov/offline/PostScript/BLUEBOOK.PDF.

3.12.1 The Field Code

To insert a watermark with the text "Super Secret," press Ctrl-F9 to create a new, blank field in your document and enter the following text between the field braces, as shown in Figure 3-44:

PRINT \p page "% Watermark
/Helvetica findfont
54 scalefont
setfont
200 350 moveto
45 rotate
.75 setgray
(SUPER  SECRET) show
"

Figure 3-44. A PRINT field including PostScript code to create a watermark

The field produces the watermark shown in Figure 3-45.

Figure 3-45. A watermark created with a PRINT field

To create a watermark that appears on every page in a document, place the PRINT field within the document's header.

To include dynamic content in the watermark, you can nest another field, such as a DATE field, within the PRINT field, as shown in Figure 3-46.

Figure 3-46. Nesting fields inside the PRINT fields is a way to include dynamic content in a text watermark