import java.datasource.dom4j.Dom4jDataSource; import java.xmlreport.ProcessPdf; import java.xmlreport.ProcessReport; import java.io.*; /** * Generate a PDF report using an XML file as the datasource. For this use case this is the entire set of code needed * to use Windward Reports. For different output formats and/or different datasources, the code will change. */ public class GeneratePdfReport { /** * Generate a PDF report using an XML file as the datasource. * @param template The report template. * @param report The generated report. * @param xmlData The XML data file. */ public static void generatePdfReport(String template_filename, String report_filename, String xmlData_filename) throws Exception { InputStream template = new FileInputStream(template_filename); OutputStream report = new FileOutputStream(report_filename); InputStream xmlData = new FileInputStream(xmlData_filename); // generally called once when your app starts, not in here. ProcessReport.init(); // create the report. ProcessPdf proc = new ProcessPdf(template, report); proc.processSetup(); proc.processData(new Dom4jDataSource(xmlData), ""); proc.processComplete(); } public static void main(String []args) throws Exception{ String template_filename = "/path/PurchaseOrderTemplate.rtf"; String report_filename = "/path/order.pdf"; String xmlData_filename= "/path/order.xml"; GeneratePdfReport myTest = new GeneratePdfReport(); myTest.generatePdfReport( template_filename, report_filename, xmlData_filename ); } }