Data Mailer
I'm getting tired of writing the full path to the PDF files all the time, so let's write a function that will do it for us. See the Python documentation for more details about sys and os.path.
importsysimportos.pathdefFindTutorialFile(sFileName):sThisScriptFilePath=sys.argv[0]sTutorialDirectory=os.path.split(sThisScriptFilePath)[0]returnos.path.join(sTutorialDirectory,sFileName)
Now it's time to add the picture of the house. To do this, we have
to first have the pictures prepared as PDF files. You can drag nearly
any image file into Adobe Acrobat to convert it to a PDF file. Don't
worry about the dimensions of the resulting PDF file, because we'll
handle that all later. Anyway, the pictures are imaginatively named
house1.pdf and house2.pdf.
So, let's write the basic function:
The most interesting line here is:
This line copies the contents of the first page of the house document,
containing the picture of the house, onto our template page.
So, putting everything together so far we get this whole script.
Now copy and run this file and look at the results. But where are
the pictures of the houses? Take a
closer look at the file by removing all the crop boxes, and you'll
find the houses in the bottom left corner of the page.
doc