I would like to create a template in doc, pdf, odt, docx ... document type does not matter. What I want is to get this document, change some values and convert this document to PDF.
For example:
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 document, using color, background and anything that may have the template:
attention
22/05/2011
Hello NicosKaralis,
Lorem ipsum ....
See you later.
There are any way to do this in Ruby on Rails? preferably using prawn
Thanks in advance
-- EDIT --
1 The owner of the application will create something like this: Original.(odt, doc, pdf)
2 My app database will have a user with this attributes:
title = Welcome to the internet!
name = Jhon Doe
text = Welcome to the internet, i will be your guide
farewell = Hope to see you soon!
3 My app will create a pdf like this: Final.pdf and send it by email
The email part i already have working. I just don`t have the pdf.
P.S.: I now how to create a pdf from scratch, but i dont want that. The point of this application is that you don`t need to be a rails developer to change the pdf that is generated.
To apply a template, you need to provide the Rails generator with the location of the template you wish to apply using the -m option. This can either be a path to a file or a URL. You can use the app:template rails command to apply templates to an existing Rails application.
You could use JRuby and a Java PDF library parser such as ApachePDFBox (https://www.ohloh.net/p/pdfbox). See also http://java-source.net/open-source/pdf-libraries.
Template Method is a behavioral design pattern that allows you to defines a skeleton of an algorithm in a base class and let subclasses override the steps without changing the overall algorithm's structure.
I'm not familiar with prawnto, but I'm pretty familiar with prawn. Since version 0.10.1 they've had the ability to import another pdf for use as a "template" per se. If you check the new manual there's a section on templates. If you look at the page titled templates/page_template.rb you'll see some example code. It takes some text and positions it manually, but there may be a way to do some sort of actual substitution.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With