package demo; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.File; import java.io.FileNotFoundException; import java.io.FileOutputStream; import com.elixirtech.net.NetException; import java.util.Properties; import java.nio.file.Files; import java.nio.file.StandardCopyOption; import com.elixirtech.ers2.client.ERSClient; import com.elixirtech.report2.runtime.IJobInfo; public class ersclientdemo { public static void main(String[] args) throws Exception { ERSClient c = new ERSClient("localhost", 8080, "eno", "admin", "sa"); try { c.connect(); ByteArrayOutputStream baos = new ByteArrayOutputStream(); IJobInfo jobInfo = c.renderReport("/ElixirSamples/Report/RML/Master-Detail Report.rml", "application/pdf", baos, new java.util.Properties()); byte[] bytes = baos.toByteArray(); File output = new File("tmp/output.pdf"); output.getParentFile().mkdirs(); Files.copy(new ByteArrayInputStream(bytes),output.toPath(),StandardCopyOption.REPLACE_EXISTING); //Get individual IJobInfo messages System.out.println("Report logged at "+jobInfo.getString(IJobInfo.LOG_FILE) +" with " + jobInfo.getLong(IJobInfo.PAGE_COUNT) + " pages rendered to "+jobInfo.getString(IJobInfo.MIME_TYPE)); //Get the whole set of results in an array System.out.println("Rendering results : "+jobInfo.toString()); } finally { c.close(); } } }