you don't use the JSP as input to FOP. Instead create an XML document containing the data you want to put in the PDF (so the form data). FOP will use an XSL:FO file to generate your PDF using that data.
You could use the XML to populate the formfields on the JSP as well using the JSTL XML tags. You might even be able to use the XSL:FO to generate HTML, removing the need for JSPs.
What I did was creating a custom tag that writes a "send as pdf" button. The tag stores its body as an xml document as soon as someone asks for the pdf doc.
Next I created a struts action that converts this xml to pdf with the aid of a (partly self written) xsl document. This struts action uses the fop implementation from apache.
The xsl document was the most time consuming to build. I paid most attention to tables in html. For my purpose it works fine.
This approach needs some fiddling around with the format of the jsp tables.
Joined: Jul 18, 2001
Hi , Thanks.I am not able to figure out.
I generated a jsp .(A table with 4 columns and 5 data)
I provided a link n it. PDF Version.
I also generated the xml document in the jsp page. I mean the xml format is in .jsp file and not .xml file. I try to use the xsl on the generated xml. I cant print the data rather it just prints the table header .
Please help me out. I am first trying with simple xsl.Later I can change to xsl:fo. This is my jsp that generate xml format.
You could try something like a) have another JSP page include the XML-generating JSP inside a custom taglib which performs the XSL-FO transformation b) have a servlet do RequestDispatcher#include(req, res) for the XML-generating JSP's URI and let the servlet perform the XSL-FO transformation on whatever the included JSP wrote to the ServletResponse object you passed on.