title: Search and replace for text within a pdf, in Python
body: <p>I am writing mailmerge software as part of a Python web app.</p>
  <p>I have a template called <code>letter.pdf</code> which was generated from a MS Word file and includes the text {name} where the resident's name will go. I also have a list of c. 100 residents' names.</p>
  <p>What I want to do is to read in <code>letter.pdf</code> do a search for <code>&quot;{name}&quot;</code> and replace it with the resident's name (for each resident) then write the result to another pdf. I then want to gather all these pdfs together into a big pdf (one page per letter) which my web app's users will print out to create their letters.</p>
  <p>Are there any Python libraries that will do this? I've looked at pdfrw and pdfminer but I couldn't see where they would be able to do it.</p>
  <p>(NB: I also have the MS Word file, so if there was another way of using that, and not going through a pdf, that would also do the job.)</p>