Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PDF Report generation [closed]

EDIT : I completed this project using ABCpdf. For anyone interested, I love this product and their support is A+. Everything I listed as a 'Con' for the HTML -> PDF solution was easily doable in ABCpdf.


I've been charged with creating a data driven pdf report. After reviewing the plethora of options, I have narrowed it down to 2. I need you all to to help me decide, or offer alternatives I haven't considered. Here are the requirements:
  1. 100% Data driven
  2. Eventually PDF (a stop in HTML is fine, so long as it is converted)
  3. Can be run with multiple sets of data (the layout is always the same, the data is variable)
  4. Contains normal analysis-style copy (saved in DB with html markup)
  5. Contains tables (data for tables is generated at run-time)
  6. Header/Page # on each page
  7. Table of Contents
  8. .NET (VB or C#)
  9. Done quickly

Now, because of the fact that the report is going to be generated with multiple sets of data, I don't think a stamped pdf template will work since I won't know how long or how many pages a certain piece of the report could require.

So, I think my best options are:

  1. Programmatic creation using an iText-like solution.
  2. Generate in HTML and convert to PDF using a third-party application (ABCPdf is the tool I have played with so far)

Both solutions have their pro's and con's.

Programmatic solution:

Pros:

  1. Flexible
  2. Easy page numbering/page header/table of contents
  3. Free

Cons:

  1. Time consuming (to write a layer on top of iText to do what I need and keep maintainable)
  2. Since the copy is already stored in the db with html markup, I would have to parse through the data before I place it into the pdf, ensuring I don't have to break the paragraph into chunks so I can apply bold, italic, underline, etc. to specific phrases. This seems like a huge PITA, and I hope I am wrong about that assumption.

HTML -> PDF

Pros:

  1. Easy to generate from db (no parsing necessary)
  2. Many tools for conversion
  3. Uses technology I am already familiar with
  4. Built-in "Print Preview" - not a req, but nice

Cons:

(Edited after project completion. All of my assumptions were incorrect and ABCpdf is awesome)

1. Almost impossible to generate page headers - Not True
2. Very difficult to generate page numbers Not True
3. Nearly impossible to generate table of contents Not True
4. (Cross-browser support isn't a con; Since its internal, I can dictate what browser to use)
5. Conversion tool quirks - may not convert exactly as rendered in browser Not True
6. Overall, I think it would be very hard to format the HTML exactly as I would want it to appear/convert to PDF. Not True

That's it - I need the communitys help in deciding which way I should go. I might be wrong about some of my Pro/Con assumptions. If I am, please tell me. All thoughts and suggestions are welcome and appreciated.

Thanks

like image 471
IniTech Avatar asked Dec 30 '09 15:12

IniTech


2 Answers

Decided on using an approach similar to the one used at http://alistapart.com/articles/boom

Using ABCPdf instead of Prince for the eventual HTML -> PDF generation.

Anyone who is interested in the same thing, feel free to message me about this approach.

like image 134
IniTech Avatar answered Sep 25 '22 11:09

IniTech


I think that if you have a full version of Adobe Acrobat Pro, it comes with Adobe Live Cycle. You should be able to produce reports generated from a database from it. It will give you everything you need in formatting since you will create the report from scratch.

You can create a database connection to an OLE database that will feed data to your form fields. You select the tables to be used, any stored procedures that will run, any queries, and then the data will appear on one of the pallettes in the designer.

You can also use Web Services (WDSL) to receive and process commands and return the results to the form.

Either way, you would bind fields to your data source and then the data would be displayed in your form.

If you're willing to do a little .NET work there's this:

http://www.dotnetvj.com/2009/05/populating-pdf-from-aspnet-using.html

like image 45
tahdhaze09 Avatar answered Sep 24 '22 11:09

tahdhaze09