This question already has an answer here:
I'm very new to JasperReports
. I have an implementation where JasperViewer
is used to preview and save reports. The first saving format offered by the viewer is .jrprint
and I'm trying to change that to pdf
. I'm employing the following method to help me with that
private static void promotePdfSaveFormat(JasperViewer jasperViewer) {
/* get via reflection the parameter JasperViewer object's member viewer (of type JRViewer) */
JRViewer viewer = on(jasperViewer).call("viewer").get();
/* get via reflection JRViewer object's member tlbToolBar (of type JRViewerToolbar) */
JRViewerToolbar tlbToolBar = on(viewer).call("tlbToolBar").get();
/* call tlbToolBar's getSaveContributors() */
Arrays.stream(tlbToolBar.getSaveContributors()).forEach(
e -> {
/* Find the one that is of type JRPdfSaveContributor (using instanceof) */
if (e instanceof JRPdfSaveContributor){
/* set JRViewerToolbar object member lastSaveContributor value to the instance of JRPdfSaveContributor */
on(tlbToolBar).call("lastSaveContributor").get();
}
}
);
}
Everytime a new Object is created inside the class like JasperViewer viewer = new JasperViewer(...)
, I'm adding promotePdfSaveFormat(viewer)
immediately after it. When I run the app, I get an error at JRViewer viewer = on(jasperViewer).call("viewer").get();
The error is as follows
org.joor.ReflectException: java.lang.NoSuchMethodException: No similar method viewer with params [] could be found on type class net.sf.jasperreports.view.JasperViewer.
I could use some help with this!
Aucun commentaire:
Enregistrer un commentaire