I’m working on a very simple mail merge system with Ruby on Rails. I have 2 models (members and letters).
First I create a html-formatted letter with some special fields (like {NAME}, {ADDRESS} or {CITY}.
Then, I must generate a PDF with one letter per member. So, if I have 100 members in the database, the PDF must have 100 letters, each one customized (replacing the special fields with the data in the database).
I know how to create the letters in html, but I don’t know how to generate the PDF. Can you help me with that? I know there are some gems to create PDFs, but I don’t know how to add the letters on different pages.
Thanks for your help!
I have used Prawn to generate PDFs and it sounds like it would work for you. There’s a wiki article on using Prawn with Rails.
The
go_to_pagemethod will let you position elements on a particular page after you have usedadd_pagesto create them.