views:

6889

answers:

5

I often get a PDF from our designer (built in Adobe InDesign) which is supposed to be sent out to thousands of people.

I've got the list with all the people, and it's easy doing a mail merge in OpenOffice.org. However, OpenOffice.org doesn't support the advanced PDF. I just want to output some text onto each page and print it out.

Here's how I do it now: print out 6.000 copies of the PDF, then put all of them into the printer again and just print out name, address and other information on top of it. But that's expensive.

Sadly, I can't make the PDF to an image and use that in OpenOffice.org because it grinds the computer to a halt. It also takes extremely long time to send this job to the printer.

So, is there an easy way to do this mail merge (preferably in Python) without paying for third party closed solutions?

+2  A: 

You could probably look at a PDF library like iText. If you have some programming knowledge and a bit of time you could write some code that adds the contact information to the PDFs

Conrad
A: 

If you cannot get the template in another format than PDF a simple ad-hoc solution would be to

  • convert the PDF into an image
  • put the image in the backgroud of your (OpenOffice.org) document
  • position mail merge fields on top of the image
  • do the mail merge and print
0xA3
The print job gets HUGE and it will never finish.
Well, then the easiest would be to ask your designer to provide the template in a viable format (or to get a copy of Adobe Acrobat Professional, I think there should be some possibility to use convert the PDF into a form). Seems the ROI of delivering 6000 letters should justify such an investment.
0xA3
A: 

Probably the best way would be to generate another PDF with the missing text, and overlay one PDF over the other. A quick Google found this link showing how to do it in Acrobat, and I'm sure there are other methods as well.

http://forums.macrumors.com/showthread.php?t=508226

Mark Ransom
+1  A: 

For a no-mess, no-fuss solution, use iText to simply add the text to the pdf. For example, you can do the following to add text to a pdf document once loaded:

PdfContentByte cb= ...;
cb.BeginText();
cb.SetFontAndSize(font, fontSize);
float x = ...;
float y = ...;
cb.SetTextMatrix(x, y);
cb.ShowText(fieldValue);
cb.EndText();

From there on, save it as a different file, and print it.

However, I've found that form fields are the way to go with pdf document generation from templates.

If you have a template with form fields (added with Adobe Acrobat), you have one of two choices :

  • Create a FDF file, which is essentially a list of values for the fields on the form. A FDF is a simple text document which references the original document so that when you open up the PDF, the document loads with the field values supplied by the FDF.
  • Alternatively, load the template with with a library like iText / iTextSharp, fill the form fields manually, and save it as a seperate pdf.

A sample FDF file looks like this (stolen from Planet PDF) :

%FDF-1.2
%âãÏÓ
1 0 obj
<<<
 /F(Example PDF Form.pdf)
 /Fields[
  <<
  /T(myTextField)
  /V(myTextField default value)
  >>
  ]
 >>
>> endobj trailer
<>
%%EOF

Because of the simple format and the small size of the FDF, this is the preferred approach, and the approach should work well in any language.

As for filling the fields programmatically, you can use iText in the following way :

PdfAcroForm acroForm = writer.AcroForm;
acroForm.Put(new PdfName(fieldInfo.Name), new PdfString(fieldInfo.Value));
rhanekom
But can I put 6000 names into one FDF, or do I have to make 6000 FDF files and then output 6000 5MiB PDF-files (which would be HUGE and take forever)?
A: 

Now I've made an account. I fixed it by using the ingenious pdftk.

In my quest I totally overlook the feature "background" and "overlay". My solution was this:

pdftk names.pdf background boat_background.pdf output out.pdf

In case anyone else ever has this problem. I also wrote about it on my web page

Velmont