java - Loading exported file to view -
i use jasperreports library 5.6.0
i tire programing:
viewer (jrviewer) pdf ---> xml ---> pdf viewer (jrviewer)
- step - export generated raport view xml file
- step - exported file xml convert pdf , showing jrviewer
but have problem step 2,
// file variable xml file generated step 1 jasperdesign design = jrxmlloader.load(file); jasperreport report = jaspercompilemanager.compilereport(design); jasperprint print = jasperfillmanager.fillreport(report, new hashmap(), new jrbeancollectiondatasource(b)); jasperprintmanager.printreport(print, false);
i got error:
java.lang.nullpointerexception @ net.sf.jasperreports.engine.xml.jrxmlloader.loadxml(jrxmlloader.java:323) @ net.sf.jasperreports.engine.xml.jrxmlloader.loadxml(jrxmlloader.java:284) @ net.sf.jasperreports.engine.xml.jrxmlloader.load(jrxmlloader.java:273) @ net.sf.jasperreports.engine.xml.jrxmlloader.load(jrxmlloader.java:218) @ net.sf.jasperreports.engine.xml.jrxmlloader.load(jrxmlloader.java:202) @ pl.opencare.wydruki.printfunctions$1.actionperformed(printfunctions.java:460) @ javax.swing.abstractbutton.fireactionperformed(abstractbutton.java:1995) @ javax.swing.abstractbutton$handler.actionperformed(abstractbutton.java:2318) @ javax.swing.defaultbuttonmodel.fireactionperformed(defaultbuttonmodel.java:387) @ javax.swing.defaultbuttonmodel.setpressed(defaultbuttonmodel.java:242) @ javax.swing.plaf.basic.basicbuttonlistener.mousereleased(basicbuttonlistener.java:236)
code step 1:
// p report jasperprint p = .......... stringbuffer xml = new stringbuffer(); jrxmlexporter xmlexporter = new jrxmlexporter(); xmlexporter.setparameter(jrexporterparameter.jasper_print, p); xmlexporter.setparameter(jrexporterparameter.output_string_buffer, xml); xmlexporter.exportreport(); file file = file.createtempfile("temp", ".xml"); bufferedwriter bw = new bufferedwriter(new filewriter(file)); bw.write(xml.tostring()); bw.close();
the file not empty can show tempolary directory.
in step 2 sbove error java.lang.nullpointerexception ,netbeans show line
jasperdesign design = jrxmlloader.load(file);
Comments
Post a Comment