• 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:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Tim Cooke
  • Devaka Cooray
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
Bartenders:
  • Carey Brown
  • Roland Mueller

using Apache FOP to generate PDF from Java value objects

 
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I am trying to explore Apche FOP library to create PDF documents and gone through all the examples.

In my application, we query database and get the value objects (java beans) and out of this we need to create PDF files. I looked at ExampleJavatoPDF, for me it looks too much of code (with SAXSource). I was thinking to use JAXB annotations (jaxb is shipped with JDK1.6) and generate XML stream on the fly and apply XSL to generate PDF.

The code looks as below.



It works fine. My question is, is it best practice to generate PDF files from Java Objects? Is there a better way? Can we generate XSL-FO from Java objects?

Thanks in advance.

Regards,
Prashant
 
Ranch Hand
Posts: 93
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello.

I'm no expert but I've been playing around with Xml to Pdf like you and from what I have seen you can generate XSL-FO document automatically but you have to have an XSLT document with the :fo directives embedded into it. The XSLT document can be used in a java program to output the XSL-FO document and then you need to use then Apache FOP driver to run the FO document against your Xml to produce the Pdf. It's a two stage process.XSLT to XSL-FO and XSL-FO to PDF. I'm sorry I have no examples right now but I have seeen this in the book 'PRO XML DEVELOPMENT WITH JAVA TECHNOLOGY' by Apress.

Colm
 
So you made a portal in time and started grabbing people. This tiny ad thinks that's rude:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic