The user can generate a pdf file using Apache FOP.(http://xmlgraphics.apache.org/fop/)
FOP (Formatting Objects Processor) is from the apache group.It is said to be the worlds first print formatter driven by XSL formatting objects (XSL-FO) and the world's first output independent formatter. Actually it isn’t a tool specifically meant for PDF conversion or creation.FOP can be downloaded here.
FOP converts the XSL files (*.fo) to PDF format.
Following is a sample for generating a pdf.
Create a Driver instance and set the necessary inputs.
Driver driver = new Driver();
Logger logger = new ConsoleLogger(ConsoleLogger.LEVEL_DEBUG);
MessageHandler.setScreenLogger(logger);
driver.setLogger(logger);
driver.setRenderer(Driver.RENDER_PDF);// Output type
driver.setInputSource(new InputSource(new java.io.StringReader(fo)));
// fo is the xsl-fo format string which is generated after transforming the xml with xsl.
driver.setOutputStream(new FileOutputStream(outputFile));
driver.run();
driver.reset();
Using the above snippet you can generate a PDF file.:-)