Adding your signature to digital documents isn't too difficult to do but what if you need to automate the process in a certain PDM/PLM system? This PowerShell script is the snippet of code I used to auto sign documents during Windchill publishing.
June 8, 2016: Updated to 1.1 with auto image resize.
1.1: Signature auto resize added, June 8, 2016
1.0: Initial release, June 5, 2016
The below script will automate the process of adding a digital signature image to Word documents.
I needed a way to to automatically add a signature to approved documents when they got published in Windchill. Leaving out the Windchill part for now and making this script a "general use" script, I have trimmed the code to just show the relevant signature part.
(Fixed in version 1.1.) I have yet to find a way to auto-size shapes based on the picture fill so you should make sure to adjust all signature files to have the appropriate ratio as I have talked about in the How to Watermark Word Dcouments with PowerShell guide. Adding white space around the signature image to get the correct ratio if you have multiple names with varying lengths would also work.
Just like the previous watermarking code, I am essentially doing the same thing here. Adding a shape, changing the fill, removing the lines. The new requirements is that I need only one signature on every document and it needs to be in a specific place on the document. I needed to find a way to specifically place the signature on the signature line.
I realized that you can add a title to a shape and then search for the shape via PowerShell so that is what I decided to do. Instead of having my script create the shape, I needed it to already be there and aligned on the signature line. I added the fill manually to check the signature location and also made sure to adjust the shape to be above the signature line.
Once the alignment was complete. I removed the picture fill and ran the code. Here is the final result:
How to Use:
Save the script as "WordSignature.ps1" and run in either one of two ways:
Be sure that all signatures are in a format that removes the background such as .png or .gif. I have made mine via a simple WordArt .png made in PowerPoint. You can similarly use the Shapes -> Scribble option in PowerPoint to allow people to manually draw their signatures via a tablet or mouse before exporting them as .png files.
Notes for Release:
1.1: The size of the initial shape you choose is what defines the max allowable size of the inserted signatures. ($SigMaxH, $SigMaxW)
1.0: (Fixed in version 1.1.) If you are going to use multiple names as signature, make sure to adjust the ratios of all pictures to be the same to avoid shrinking or stretching issues.