Skip to main content
Windward

Passing parameters to java engine example

Overview

Passing parameters to java engine example.

Resolution

The template we use for this example is attached. The comments should guide you through this example.

public static void main(String[] args) throws Exception
{
        // Initialize Windward Reports
        ProcessReport.init();

        FileOutputStream out = new FileOutputStream("test.pdf");
        FileInputStream rtf = new FileInputStream("Variable Invoice Sample - Template.docx");

        //sql datasource we are going to be using
        JdbcDataSource data = new JdbcDataSource("com.microsoft.sqlserver.jdbc.SQLServerDriver",
        "jdbc:sqlserver://mssql.windwardreports.co...Name=Northwind",
        "demo", "demo");

        // Create a report process
        ProcessPdfAPI proc = new ProcessPdf( rtf, out );

        // set the subject
        proc.setSubject("An Acme, Inc. Report");

        // parse the template file
        proc.processSetup();

        //This is where we pass in the parameters to the datasource
        Map map = new HashMap();
        map.put("order", "10537");
        //the actual function that gives the datasource our parameters
        data.setMap(map);

        // merge a sql database with the report
        proc.processData(data, "");

        // generate the final report
        proc.processComplete();

        // ensure everything is written out to the stream
        out.flush();
    }

  • Was this article helpful?