Forums Register Login

Apache FOP

+Pie Number of slices to send: Send
I have used Apache FOP 2 years earlier last time and now using again. I need to clarify a few points that I could not find out in documentaiton and mailing list after a quick search.
In our Struts based application, I have the beans that hold data and I want to generate reports using that. Now my available options are ----
1. Dump that bean with all its properties and child properties to an XML file. Use FOP's XSLT processor to generate XSL-FO file. Now use that FO file to genereate PDF.
My Query: How am I going to use that XSLT processor? Should I hard code in a java class that will generate the XSL-FO from the XML file? Hard coding is not what I like. Where in FOP's documentaiton I can find the steps needed?
2. Dump the bean in a nice way so that I can directly generate output as XSL-FO file rather than going thru the intermediate translation phase.
My Query: Is it really possible? How? Then where I'll say the rules for FO layout in my code?
Looking forward to your help.
+Pie Number of slices to send: Send
Hei Pals,
I found some examples in fop distributions /examples/embedding/java/embedding dir. I also got to know from the documentaiton that, a good strategy should be
1. Dumping my bean as an XML file. (did it earlier)
2. Write down an XSL file for the generated XML file. (here i was confused)
2. Using Xalan transform the previously generated XML file, following the rules I wrote in XSL file, generate an XSL-FP file.
3. Then using FOP processor, generate pdf file using the just-now genereated XSL-FO file. (did it earlier)
Anyway, I didn't find there any example that hints about generating Obj2FO. ... Is it possible really? (my previous question#2)
+Pie Number of slices to send: Send
I request the moderator to move this post to xml forum.
+Pie Number of slices to send: Send
 

Originally posted by Ashik uzzaman:

1. Dumping my bean as an XML file. (did it earlier)
2. Write down an XSL file for the generated XML file. (here i was confused)
2. Using Xalan transform the previously generated XML file, following the rules I wrote in XSL file, generate an XSL-FP file.
3. Then using FOP processor, generate pdf file using the just-now genereated XSL-FO file. (did it earlier)
Anyway, I didn't find there any example that hints about generating Obj2FO. ... Is it possible really? (my previous question#2)


Ashik, I would suggest to convert your data beans to .FO directly, unless you need to use the data XML for another process. Now you can directly convert fo to pdf using servlet or javabean-jsp
On the other side, its better to out the javabeans data as xml where you can use a xslt to convert xml to fo then to pdf. by this way you can edit xslt seperately.(this will help you to avoid re-compiling your javabeans for correcting any changes in the output report)
xml/FO to pdf converiosn using servlet can be found here http://xml.apache.org/fop/servlets.html
+Pie Number of slices to send: Send
Thank you Balaji for the hints. What I did till now is, prepared both methods to generate PDF through XML+XSL-->XSL-FO-->PDF and directly dumping a bean as an XML-FO through velocity as XSL-FO and thru FOP to PDF. All these are run now thru command prompt and now wokring for web version (in our struts based application).
Now the decision to make is....i can either create the FOP in-memory and display my web clients directly from there or I can save the generated fop to a server directory, say "reports" and use sendRedirect() to display the report. Which one is a better idea and why? Can you refer any sample link or discussion on this?
+Pie Number of slices to send: Send
 

Originally posted by Ashik uzzaman:
Now the decision to make is....i can either create the FOP in-memory and display my web clients directly from there or I can save the generated fop to a server directory, say "reports" and use sendRedirect() to display the report. Which one is a better idea and why? Can you refer any sample link or discussion on this?


Sorry i missed this thread.
Good question, In one of my project, I use to store the generated pdf in temp folder as i have to email them to the user apart from displaying on browser screen. For your case i would suggest to display the PDF stream directly, Because if you store them into a temp folder, then you have to write a method which will read the pdf file using file inputstream reader then give that to printWriter of servlet. WHEREAS with other option you will give the FOP processed stream to printWriter directly.
Make sense ??
+Pie Number of slices to send: Send
Yes, makes sense, thank you Balaji. I am preparing it in a way so that it can be used both from my struts-based applciation and a command prompt tool. I'll finish it by next 2 days, hope to share the outcome.
+Pie Number of slices to send: Send
Well I was using a code similar to the following from my ReportGenerator class that will b used both from my command line tool and struts-based webapp to generaete a PDF from an FO file.

But we want to generaete the file without using shell, rather directly calling FOP's methods that do this file generation staff. May anyone hint which methods can that be in FOP. I am searching around the FOP documentation for some time.
+Pie Number of slices to send: Send
Did you look at the link i gave above ?
AW i will psate the code for you here
+Pie Number of slices to send: Send
here is the full example of servlet-FOP
+Pie Number of slices to send: Send
Ya, got thta just after posting here. Thanks Balaji for your immense help.
+Pie Number of slices to send: Send
Sorry I missed this earlier. Moving to XML forum...
Here you go.
[ March 31, 2004: Message edited by: Barry Gaunt ]
Liar, liar, pants on fire! refreshing plug:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com


reply
reply
This thread has been viewed 1595 times.
Similar Threads
xml mathml pdf FOP
need a dynamic example FOP from a database
using Apache FOP to generate PDF from Java value objects
STX (Joost) and XSL-FO
xml to pdf
looking for tool to convert xml to pdf
More...

All times above are in ranch (not your local) time.
The current ranch time is
Apr 16, 2024 01:40:46.