Create a PDF from a template in Ruby on Rails

I would like to create a template in doc, pdf, odt, docx ... the type of the document does not matter. I want to get this document, change some values ​​and convert this document to PDF.

For instance:

Take this template:

<Title> <Date> Hello <Name>, <Text> <Farewell> 

And with this information:

 Title: attention Date: 22/05/2011 Name: NicosKaralis Text: Lorem ipsum ... Farewell: See you later 

generate this pdf using color, background and everything the template can have:

 attention 22/05/2011 Hello NicosKaralis, Lorem ipsum .... See you later. 

Is there any way to do this in Ruby on Rails? preferably using shrimp

Thank you in advance

- EDIT -

1 The application owner will create something like this: Original. (odt, doc, pdf)

2 In my application database there will be a user with the following attributes:

title = Welcome to the Internet!

name = Jhon Doe

text = Welcome to the Internet, I will be your guide

Goodbye = Hope to see you soon!

3 My application will create such a pdf file: Final.pdf and send it by email

I'm already working in email. I just don't have pdf.

PS: I now how to create a PDF from scratch, but I do not want this. The fact is that you do not need to be a rails developer to modify the created pdf.

+4
source share
3 answers

I am not familiar with shrimp, but I am well acquainted with shrimp. Starting with version 0.10.1, they had the opportunity to import another pdf file for use as a "template" as such. If you check out the new manual , you will see a section on templates. If you look at a page called templates / page_template.rb, you will see a sample code. It requires some text and its position manually, but there may be a way to do some kind of actual substitution.

+4
source

This parameter may concern the first half of the problem. Then use something like wicked_pdf to create.

+2
source

Here's a very good screencast from Ryan Bates explaining the trick from PDF :: Writer. I think you want :)

0
source

All Articles