novotny75 Posted January 30, 2009 Share Posted January 30, 2009 Hi, I have about 6 JRXML files and I call JasperRunManager.runReportToPdf(...); on all 6 of them and have 6 resulting byte arrays. Naively I thought I could just add them all into one monster byte array but that doesn't seem to work. What is the proper way to merge all PDF byte arrays into one final PDF?Also how can I eliminate blank pages? Some of the rendered PDF pages have an extra blank page. Thanks, Jason Link to comment Share on other sites More sharing options...
lucianc Posted January 30, 2009 Share Posted January 30, 2009 You can concatenate PDFs with iText (do a search to find sample code). Or you can use JasperReports to export multimple reports into a single PDF, see the demo/samples/batchexport sample.Blank pages are usually (but not necessarily) caused by empty bands or empty space at the bottom of report bands.Regards,Lucian Link to comment Share on other sites More sharing options...
suedwxg Posted December 15, 2009 Share Posted December 15, 2009 Lucianc et all,Further of question, if I'd like to keep the bookmark level tree between the jrxmls, how can I make it,?E.g. the AAA.jrxml hold an bookmark: AAAA; and the he BBB.jrxml hold an bookmark: BBBB; CCC.jrxml hold an bookmark: CCCC; if I'd like to make my bookmark tree like this way:+AAAA ----BBBB----CCCC**************from my idea, I have to use XSLT to concat the 3 jrxml to temp one and make the printing this way, but is there any low cost way? Thanks in advance! ballackstonePost Edited by suedwxg at 12/15/2009 06:38 Link to comment Share on other sites More sharing options...
lucianc Posted December 22, 2009 Share Posted December 22, 2009 suedwxgWrote: Further of question, if I'd like to keep the bookmark level tree between the jrxmls, how can I make it,? You can manually iterate all text elements in a JasperPrint and call setBookmarkLevel() to increment the level of the bookmark.Regards,Lucian Link to comment Share on other sites More sharing options...
suedwxg Posted December 25, 2009 Share Posted December 25, 2009 Vialen Danke! Link to comment Share on other sites More sharing options...
smokkydesperado Posted February 11, 2010 Share Posted February 11, 2010 I Couldnt find any link for seeing the demos for Batch export.Please help . Link to comment Share on other sites More sharing options...
ojive Posted January 27, 2011 Share Posted January 27, 2011 you know what, im gonna bump this thread as JasperReports have not been anything else but endless streak of agony and frustrations.In your so called "batchexport sample", there are examples of how you can do it with "jrprint" files. But guess what, there is no, none, zero, zip documentation on how you would create those files. And before you voice your thought about "JasperFillManager.fillReport(jasperreport, params, con)", no, it DOES NOT create any "jrprint" files.So here I am, with "batchexport sample", no way of knowing how i would merge these reports, and im frustrated beyond any limits. edit: taking some of the above back. Make _damn_ sure your iReport and jasper jars are of the same version....version 4.0.0 actually produces ".jrprint" files when "fillReport" is used.You can then go: jasperPrint = JasperFillManager.fillReport(jasperReport, jasperParameter, con);list.add(jasperPrint); exp.setParameter(JRPdfExporterParameter.JASPER_PRINT_LIST, list);exp.setParameter(JRPdfExporterParameter.OUTPUT_FILE, new File("test.pdf"));exp.exportReport();This will export your report to a pdf. If you put this into a for-loop with a query that updates itself, and fills report with new "jasperParameter"s, you will get several pages in your "test.pdf", with one page pr element/query.I had it like this: Code:JRDesignQuery query = new JRDesignQuery();JasperPrint jasperPrint = null;Connection con = db.getConnection(); //my own class that creates a sql connectionList<Object> list = new ArrayList<Object>();JRPdfExporter exp = new JRPdfExporter();for(int k = 0; k < params.size(); k++){String query = "Select * from where somefield = ' " + params.get(k).get(3) + " ' ";query.setText (sqlQuery);JasperDesign jasperDesign = JRXmlLoader.load("GUI2.jrxml");jasperDesign.setQuery(query);jasperReport = JasperCompileManager.compileReport(jasperDesign); HashMap<String, String> jasperParameter = new HashMap<String, String>();jasperParameter.put("foo", params.get(k).get(2).toString()); //where "foo" is a field in your iReport .jrxml type file.jasperPrint = JasperFillManager.fillReport(jasperReport, jasperParameter, con);list.add(jasperPrint);exp.setParameter(JRPdfExporterParameter.JASPER_PRINT_LIST, list);exp.setParameter(JRPdfExporterParameter.OUTPUT_FILE, new File("test.pdf"));exp.exportReport();Post Edited by ojive at 01/27/2011 13:11 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now