views:

603

answers:

9

I want to be able to generate a highly graphical (with lots of text content as well) PDF file from data that I might have in a database or xml or any other structured form.

Currently our graphic designer creates these PDF files in Photoshop manually after getting the content as a MS Word Document. But usually, there are more than 20 revisions of the content; small changes here and there, spelling corrections, etc.

The 2 disadvantages are: 1) The graphic designer's time is unnecessarily occupied. The first version is the only one he/she should have to work on. 2) The PDF file becomes the document which now has the final revised content, and the initial content is out of sync with it. So if the initial content needs to be somewhere else (like on a website), we need to recreate it from the PDF file.

Generating the PDF file will help me solve both these problems. Perhaps some way in which the graphic designer creates a "Template" and then puts in tags/holders and maps these tags/holders to the relevant data.

Thanks :-)

A: 

You could look at doing the workflow in PostScript which is plain text that you can easily compose from fragments. Then you can use any free tool to convert to PDF.

jjrv
+1  A: 

I use the ReportLab python library for this. It could perhaps solve your problem, but you will need to do some work...

edomaur
+1  A: 

In the past I have written scripts that spit out LaTeX then used texi2pdf to solve this kind of problem.

moonshadow
A: 

Take a look at iReport and JasperReports at http://jasperforge.org. iReport lets you design reports, and then you can either programatically fill it with the JasperReports library (Java), or just use iReport to manually create the report.

I have only used it for tabular data, but I don't think there would be any problem for other types of documents.

kigurai
+2  A: 

There are some tools out there for doing this. XSL-FO is useful. Here is a tutorial for creating a pdf from xml (or xhtml) with cocoon. Also see Apache FOP.

You could format your SQL data as XML and still use the same templates this way.

Steve g
A: 

You could create a form and populate the entries programmatically using a pdf library like iText (Java).

Joshua
A: 

Take a look at Prince XML. This tool allows to generate PDF based on XML or HTML and CSS.

Christoph Schiessl
A: 

A possible way is to use a template engine, like FreeMarker or StringTemplate: these are often used to generate HTML, but they are flexible enough to output any format, actually.
The problem is to make a PDF template, I suppose. Perhaps you can take a sample output and edit it to replace data with placeholders to be filled by the template engine. Might not be trivial!

PhiLho
A: 

Sounds like a job that SQL Server Reporting Services can handle quite easily.
Reporting Services allows you to query the data, define the layout, and export to PDF without any intervention. The PDF output can be distributed via email, stored on a file share, and accessed via a page on the report server.
It can handle XML data sources too.

Erick B