How to use PowerShell and iTextSharp to modify PDF files with text fields
In this blog post, we will go over how to create New Hire Welcome letters using PowerShell and iTextSharp.dll. You can have the iTextSharp.dll on the server that will be building the New Hire Welcome letters, and Adobe software is not needed to create the New Hire Welcome Letter.
You will need Microsoft Word and Adobe Standard if you want to make edits to your New Hire Welcome Letter.
-Microsoft Word - Used to create Template Welcome Letter
-Adobe Standard - Used to add Text fields on top of Template Welcome Letter
-iTextSharp.dll - You can download the iTextSharp.dll from the itext GitHub Project.
-Get-RandomUser Function - You can download the Get-RandomUser Function from my Blog Post.
I first started off by creating a IT Welcome Letter in Microsoft Word. I made sure to leave blank spaces where I want to add my text fields using Adobe Standard.
Once you open the file in Adobe Standard you should see a button on right side to Prepare Form
Click on Prepare Form
On the tool bar you should see a button to add a text field.
Click on "Add a text field" button
Click on the location where you want the text field to be added.
Enter the Field Name
Once your done Entering the Field Name it should look like this.
Fill your Template with text fields, once done it should look something like this.
Keep note of each of the Field Names, we will need it for the PowerShell code.
Here is a example of the code: