This post is a continuation of Part I, which you can find here.
As a quick recap, in Part I we took a look at how Adobe Acrobat and Reader import and export data to and from PDF forms. We also discussed how you can export sample data from any given form in order to determine how data should be formatted for importing.
So, now that you know what how your xml file should look, it’s time to figure out how to get your data into that xml file so that it can be imported into your form. If you are following along from Part I, you can go ahead and close the xml file if you still have it open in a web browser. Okay, let’s get started.
Part II: Creating a Mail Merge Document that can be imported into a PDF Form
As the title suggests, what we are going to do is create a mail merge document that will take our data and merge it with the xml framework we exported from our form. As with Part I, I will still be working with the declaration form for a patent application that includes an application data sheet (SB01A). Once we have created the mail merge document for the declaration form, we can use it each time we need to fill out a new declaration.
I’ll be working with Microsoft Word, but this can be done with other word processors that have a mail merge feature.
Okay, so the first thing to do is to create a Word document that includes the xml text that we exported from our declaration form during Part I. However, don’t open the xml file directly using Word. Instead, we will need to copy the xml text and past it into a new Word document using “Paste Special – unformatted text.” Here’s the process in detail:
- Open the xml file in a text editor. I use Notepad, but other text editors can be used.
- Select and copy everything.
- Open a new Word document.
- In Word, find and click on “Paste Special” (in Word 2007, click the down-arrow under Paste), then select “Unformatted Text” and click okay.
- Save your Word document as a Word document file (I recommend selecting “Word 97-2003 Document” as the file type).
Okay, so at this point you should have a Word document that looks something like this:
Now that we have a Word document, we can make a mail merge document that will allow us to import information that we want in the form. If you are familiar with how to create a mail merge document, then you can scan down past this part of the discussion.
Mail merge is a powerful feature of Word that allows you to import information from a data source into a Word document. The data source can be a database, a spreadsheet, a plain text document, or a number of other types of files.
So in order to make our Word document into a mail merge document, we are going to need a data source. Our data source should include all of the information that goes into the form. Scanning through the Word document we just created, you can see that we need to create a data source that includes such things as a title, inventor name, inventor citizenship, application number, etc. Note that it’s okay to leave out any of the information that we don’t have. For example, if we wanted to use this for an application that had not yet been filed, we could just leave the application number blank, and it won’t create any problems when we import this into the PDF form later on.
For the purposes of this explanation, I’ll use a plain text file as a data source. Many docketing systems have the capability of exporting data as a plain text file, so I’m using this file type as an example. I’ll add a Part III to this series that includes an example where a spreadsheet is used as a data source.
For example, I use CTS, which allows me to create documents from that I create or that come stock with the CTS software. The CTS forms are mail merge documents. When I create a document from within CTS, CTS opens the mail merge document, generates a plain text file (the data source) containing information that goes into the form, and then merges the mail merge document with the information from the plain text file. This means that I can use the Word document created above and set it up as a form in CTS. If you are a CTS user, instructions for doing this are in the software manual and beyond the scope of this entry. (However, if you would like more details about how to set this up, feel free to contact me by comment or by email at the email address in the footer.)
There are many ways in which you can create your data source file. You can export it from your docketing system, which I recommend, or you can create it manually. For example, you can create a spreadsheet that includes all of the information for each of your patent cases, and use that spreadsheet as a data source each time you need to complete a mail merge document.
If your data source is automatically generated by your docketing software, it may not necessary to examine your data source file. But you will need to know column and row delimiters (more on that in a moment), and if you can’t find it in your docketing software documentation, you can open up the exported file in a text editor and find out that way. My file was exported by CTS, and here’s what it looked like:
You can think of this file as being arranged like a table that has two rows (or “records”) and eight columns (or “fields”), where columns are separated by pipes “|” (I circled a couple of them in red) and a new row is indicated by a caret “^” (circled in green). So in this example, my field delimiter is | and my record delimiter is ^.
So now that I have a data source file, I can set up my mail merge. To do this in Word 2007, go to the Mailings tab and select Start Mail Merge > Letters. Next, click on Select Recipients > Use Existing List. Browse to your data source file and click Okay. You may be prompted to select the field and record delimiters, or Word may figure it out on it’s own. If prompted, just pick the delimiters you found in your text file:
Here, I select | as my Field delimiter, and ^ as my Record delimiter, then click OK. Now, upon returning to Word, you will see that you now have some new menu items to work with. You can now click on Insert Merge Field and see a list of data types that you can insert into your mail merge document:
So all that’s left to do is to go through the mail merge document and replace our sample text with the appropriate Merge Field. For example, where I see “INVENTOR ONE NAME” (which is what I originally wrote in the PDF before I exported the xml file), I highlight that text:
Then I replace it with the two Inventor 1 fields (first and last names):
This tells Word where to insert the inventor’s first and last name in the mail merge document. Repeat this for each form field that you want in your document.
Now that we have the mail merge document created, we need to get it in shape for importing into a PDF file.
First, we need to get rid of all of the paragraph returns in the document. In the screenshot shown below, I have Word set up to show paragraph marks (circled in red). We need to get rid of all of those. The easiest way is to do a Replace All (Ctrl+H) and replace all paragraph returns (^p = ¶) with nothing:
Your document should now look like one long string of text (click to enlarge):
Save this document somewhere you can easily find it each time you want to fill out a declaration form. You may want to create a directory where you store all of these mail merge documents, one for each form.
If you are scanning past how to create a mail merge document, start reading again here.
Now that we have our mail merge document, we can follow these remaining steps to fill out the pdf form.
First, import your data into the mail merge form by clicking on “Preview Results” under the Mailings tab. This should replace your data fields with the actual data from your data source.
Next, save your document as a text file [Save as type: Plain Text (*.txt)]. A file conversion dialog will open. It’s okay to go with Windows (Default) text encoding, which is probably already selected, so just click OK.
Now, open your PDF file, select Import, and this is important:
Do not select “Text” as the file type! You must select “All Files (*.*)” for this import to work:
Presto! Your PDF form is completed.
I’ve covered alot of ground here, and I’ve had to include sparse explanations for a few things for the sake of brevity. I plan to continue this series to expand on a few points, such as how to set up an excel file as a data source.
This may seem like alot of work, and it is at first if you aren’t used to the process. But I think you’ll find that once you get a library of these mail merge documents created, it can be a huge time-saver to simply import your information into your mail merge document, then import your mail merge document into your PDF form.
This is especially true for longer forms, such as application data sheets and IDS’s. I’ll use the IDS form as an example in Part III, and I’ll show you how you can fill in an IDS form using a list of references you have stored in a spreadsheet.
If you have any questions, as always feel free to ask in the comments or by email at the email address in the footer.