PDF Report generation
Posted
by
IniTech
on Stack Overflow
See other posts from Stack Overflow
or by IniTech
Published on 2009-12-30T15:57:26Z
Indexed on
2012/12/20
5:03 UTC
Read the original article
Hit count: 281
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:
- 100% Data driven
- Eventually PDF (a stop in HTML is fine, so long as it is converted)
- Can be run with multiple sets of data (the layout is always the same, the data is variable)
- Contains normal analysis-style copy (saved in DB with html markup)
- Contains tables (data for tables is generated at run-time)
- Header/Page # on each page
- Table of Contents
- .NET (VB or C#)
- 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:
- Programmatic creation using an iText-like solution.
- 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:
- Flexible
- Easy page numbering/page header/table of contents
- Free
Cons:
- Time consuming (to write a layer on top of iText to do what I need and keep maintainable)
- 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:
- Easy to generate from db (no parsing necessary)
- Many tools for conversion
- Uses technology I am already familiar with
- 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
© Stack Overflow or respective owner