Intro
Excerpt |
---|
Dynamically place custom watermarks on a Word document using the WordApplication object. |
This sample uses the WordApplication object to insert watermarks onto a template document.
Code
Code Block |
---|
//The value of this string is the watermark string watermark = "Classified"; public void GenerateDocument() { /*// Create an instance of the WordApplication objectobject */ WordApplication wwApp = new WordApplication(); /*// Open the unclassified document */without watermark Document doc = wwApp.Open(@"..\..\TemplatesWordTemplateFiles/PreWatermark.doc"); /*// Set the watermarkwatermark */ doc.Watermark.Text = watermark; /*// Save the document to the Response streamstream */ wwApp.Save(doc, @"..\..\OutputWordOutputFiles\Watermarked_out.doc"); } } |
Downloads
Initial Document: PreWatermark.doc
Output: Watermark_out.doc