I have this code that only generates one Jasper report at a time to PDF based on a given condition. But what if I want to combine both Jaspers into one PDF file? (i.e. the PDF output should be LoadTagR2R.jasper + LoadTagR2RLandscape.jasper -- which will be one PDF output stream with multiple pages)
if (fullHalfTag.equalsIgnoreCase("Y")){ //Read FULL_HALF_TAG value (if FULL_HALF_TAG == 'Y')
logger.debug("Printing FULL tag...");
reportStream = getServletConfig().getServletContext().getResourceAsStream("/reports/LoadTagR2RLandscape.jasper");
} else {
logger.debug("Printing HALF tag...");
reportStream = getServletConfig().getServletContext().getResourceAsStream("/reports/LoadTagR2R.jasper");
}
//Report parameters
Map parameters = new HashMap();
parameters.put("PLT_NO", pltNo);
parameters.put("TICKET_NO", ticketNo);
try {
Connection conn = ConnectionUtils.getConnection();
JasperRunManager.runReportToPdfStream(reportStream,servletOutputStream, parameters, conn);
response.setContentType("application/pdf");
servletOutputStream.flush();
servletOutputStream.close();
I have tried merging the two input streams as shown below but it didn't work. Thoughts?
new java.io.SequenceInputStream(s1, s2).