• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Junilu Lacar
  • Liutauras Vilda
Sheriffs:
  • Paul Clapham
  • Jeanne Boyarsky
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Piet Souris
  • Carey Brown
Bartenders:
  • Jesse Duncan
  • Frits Walraven
  • Mikalai Zaikin

printing report in PDF

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi all
my query is i want to print a report in PDF consisiting of Static and Dynamic fields. How to insert the dynamic fields in the PDF document.

thanks in advance
Sumeet
 
Sheriff
Posts: 4313
Android IntelliJ IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Check out these two open source tools:
JasperReports:
Free Java report-generating library. XML report templates are used to generate ready to print documents using data from customizable data sources, including JDBC. The output can be delivered to the screen, printer, or stored in PDF, HTML or XML format.
iText, a JAVA-PDF library:
This library contains classes that generate documents in the Portable Document Format (PDF) and/or HTML.
 
author
Posts: 11962
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
First of all, which PDF library are you using?
- iText
- BigFaceless
- PDFlib
- GNUjpdf
- Some other?
There are also some commercial products specialized in generating PDF reports based on database tables, XML documents, etc.
 
Sheriff
Posts: 6450
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have done this using xsl-fo and FOP. I've been quite pleased with the results.
 
Ranch Hand
Posts: 15304
6
Mac OS X IntelliJ IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Jason Menard:
I have done this using xsl-fo and FOP. I've been quite pleased with the results.


Have you used iText? If so, how does it compare with FOP? Or is it similar enough that there is a comparison. I find iText pretty easy. Do just looking for opinions.
 
Jason Menard
Sheriff
Posts: 6450
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Gregg Bolinger:
Have you used iText? If so, how does it compare with FOP? Or is it similar enough that there is a comparison. I find iText pretty easy. Do just looking for opinions.


I haven't used iText so I really can't offer a comparison. I will point out that FOP is just an xsl-fo processor programmed in Java, which can be used stand-alone but also has an API which you can use to call it from within your code. It takes an xsl-fo document and can ouput pdf or a few other outputs.
Is an fo based solution for you? If you want a non-proprietary solution, yes. Since xsl-fo is a w3c standard, any FO processor would be able to render an fo document, not just FOP. If you have a particular reason that using XML technologies would make sense for your project, then using something like FOP would be a good direction to head in.
Our requirements were to make a complex multi-page printer-friendly version requiring precise layout of some web-based material. The basic flow we used was to produce a DOM (using JDOM) of a heirarchy of Java objects. Once we had our DOM, we transformed it using an xsl stylesheet to provide the proper xsl-fo markup, as well as a sprinkling of svg. We took the transformed DOM, and fed it to a servlet (in this case acting as a view for a Struts application) which rendered the pdf using FOP and produced an output stream of type application/pdf.
The upside for us was that we will be able to re-use portions of that, particularly marshalling the objects to xml, for other requirements we have coming down the road. Additionally it is a relatively simple thing to do to change the xsl stylesheet if we have any tweaks we need to make, and we have maintained separation of our data and presentation.
 
Lasse Koskela
author
Posts: 11962
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Just as a side note, I was wondering whether any of these mentioned libraries (especially iText) are capable of streaming PDF files? I mean, pushing out blocks instead of creating the whole document in-memory and then flushing that out.
I had to come up with an export feature for XLS and none of the available libraries supported true streaming so I had to write a simple report generator, which wrote the BIFF8 blocks one by one (they had to be written in a certain order required by the spec, which kind of made the code unreusable but...)
 
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Jason Menard:
I have done this using xsl-fo and FOP. I've been quite pleased with the results.


I'll second that. FOP was easy to use and learn. But watch out for memory consumption. I've heard this is a problem with a lot of these tools. FO has some techniques for reducing the memory footprint that should be followed.
Cheers,
Ron
 
pie. tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic