A simple script that automates the watermarking of documents in Word. Summary: The below script will automate the process of watermarking documents in Word. Problem Overview: I needed a way to automatically create watermarks on Word documents without any user interaction as part of a larger script. Limitations Encountered: Although Word has a built in ribbon button for watermarking, I have not been able to find a way to call it in PowerShell. When adding a picture in a document, you are not given the ability to alter the transparency like a true watermark. Solution: In order to add a picture and control its transparency, you have to first create a shape and then fill that shape with an image. Because you can control the transparency of the shape's fill, you can now control the transparency of the watermark image. To make it look like a shape is not even there, the default outlines of the shape should also be hidden/removed. How to Use: Save the script as "WordWatermarking.ps1" and run in either one of two ways:
A watermark looks better when the image has no background. If the image used has a background, then you will get the block look which seems unprofessional. Because we are not all image experts, the easiest way to create a watermark image that does not have a background is to use WordArt and shapes in PowerPoint. Simply create the design, select all objects, right click, Save as Picture. This creates a .png file with the background removed that you can use for your watermarks. The shape does not automatically change size based on the size of the picture. You should adjust the shape size manually below (the 500, 125 numbers) to be the same ratio as the image you are going to use. i.e. if I have a watermark that is 1.6" x .9" (or even 160 pixels by 90 pixels), I would size the shape to be 160 x 90 or 320 x 180 or 80 x 45. This prevents the image from looking like it is being stretched or shrunk. WordWatermarking.ps1
4 Comments
Jain
1/23/2019 05:55:50 pm
Hi Erik, first of all great post on using powershell to watermark docs, i need one small help, the above script works well with images, but i want to fill text instead, inside the shape, do i have to use any other object like TextEffect or something and then i want to save this file as pdf, thanks waiting for your reply.
Reply
Sripal
1/24/2019 02:02:49 am
Hi Erik, I have used TextFrame and it works now and manage to save it as pdf. one issue is for 44pages document it can takes about 3 to 4minutes to watermark. do you have any other suggestion how to process this much faster, in python i have done using template and then merge this template with all the pages of the document. thanks, waiting for your reply
Reply
Lutz
2/6/2020 12:52:27 pm
HI Erik, thanks for this great post. The script works great on a single Word document, but could you also explain how I can run it on a whole bunch of documents?
Reply
Leave a Reply. |
AuthorPLM engineer while "on the clock", programmer, designer, dreamer all other times. ArchivesCategories
All
|