I need to generate many letters of invitation from a list of people. I thought this would be already asked/answered in this forum, but I can't find anything useful. Basically, I need to write a letter of invitation to different people:

  1. I have the names of the people whom I'm addressing in a list.
  2. The text that is constant for all letters, in text form (Alt+7 in Windows).

Then, I need to export the letter as a PDF using each of the names from the list and the constant text. How can I go about this? I'm open to any general strategy, as I can't find a starting point.

EDIT1: I know how to do basic string manipulation. Here what I mean is to generate an actual letter, so I'd need to export each letter as a PDF with a decent "letter-like" format (it suffices to have the simple formatting that you get with Alt+7 in Windows).




you mean something like this?

"This is " <> # <> "'s invitation" & /@ {"Alice", "Bob", "Mary"}  

{"This is Alice's invitation", "This is Bob's invitation", "This is Mary's invitation"}

here is a way to export these texts to pdf

Export[# <> ".pdf", "This is " <> # <> "'s invitation"] & /@ {"Alice",
"Bob", "Mary"}   

{"Alice.pdf", "Bob.pdf", "Mary.pdf"}

This creates a pdf for every name that you can find in your documents folder

  • 1
    $\begingroup$ Or StringTemplate["This is ``'s invitation"] /@ {"Alice", "Bob", "Mary"}. $\endgroup$ – Carl Lange Apr 1 at 14:38
  • $\begingroup$ @J42161217 I edited my question to be a bit more explicit. What I meant is to export a document that is formatted as a letter, programmatically. So, I'm thinking about combining the "text form" which is the generic text (Alt+7) and mapping of the list of names, to finally do something like Export["letter.pdf", letter], but I can't see how. Thanks for any ideas! $\endgroup$ – PedroSapichu Apr 1 at 14:57
  • $\begingroup$ @PedroSapichu I added the export function. Now every letter is a pdf named after a name and the text in the pdf uses the same name $\endgroup$ – J42161217 Apr 1 at 22:23
  • $\begingroup$ @J42161217 thanks for the edit. It is not exactly what I want, but it is a starting point (which is what I asked for), so I'll accept this as an answer. Thanks again! $\endgroup$ – PedroSapichu Apr 2 at 0:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.