Data Mailer
So, now let's take a look at the template file. In this example we want to send a customized postcard to different recipients. Notice the /N /F1 /F2 .... We will replace these words with customized strings. These words do not have to begin with a / character.
Also, you'll see this on the second page:
abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ 0123456789 `~!@#$%^&*()-=_+[]{};':",./<>?
What is all this garbage? Well, I created this template using Adobe Acrobat Distiller. Distiller likes to subset and embed fonts, even if you ask it not to. So, in order to get it to embed all the characters that may appear in substituted strings, I had to actually put all the characters into the document. If I had not put all these letters into the document, then when I substituted strings into the page, some of the letters would be missing. If you create your template without embedded fonts, then adding all the characters like this is not necessary.
Now, let's take a look at the data we will substitute into the postcard:
# FORMAT:# NAME, FEATURE1, FEATURE2, FEATURE3, FEATURE4,# FEATURE5, FEATURE6, PICTUREFILEdata=(('Jeffrey','3 Bedrooms','2 Bathrooms','A Swimming Pool','','','','house1.pdf'),('Gary','5 Large Bedrooms','3 Bathrooms','3-Car Garage',"Lot's of Shady Trees",'Satelite Dish','Hot Tub','house2.pdf'))
This is just a simple format I have defined for this demonstration. Your Python script can pull data from anywhere. Python has all the features you need to pull data from a comma separated file (CSV), an extended mark-up languge file (XML), or a database. If you download the COM extensions from ActiveState, you can even use COM objects.