Reputation: 507
This is my code
static Connection connHealthInfoSystem = DBConnection.conn("health_info_system");
public static void printDisplayable(String reportPath, Map parameter) {
JasperDesign jd;
try {
jd = JRXmlLoader.load(reportPath);
JasperReport jr = JasperCompileManager.compileReport(jd);
JasperPrint jp = JasperFillManager.fillReport(jr, parameter, connHealthInfoSystem);
JasperViewer.viewReport(jp, false);
} catch (JRException ex) {
Logger.getLogger(JasperPrinting.class.getName()).log(Level.SEVERE, null, ex);
}
}
Based on the current code that I have, how can I increase the size of the width of my report when it pops up?
Upvotes: 1
Views: 758
Reputation: 21710
Don't use the static method JasperViewer.viewReport(jp, false);
, since this way you don't have control of JasperViewer
object instead instance your own JasperViewer
JasperViewer viewer = new JasperViewer(jp, false);
JasperViewer
extends JFrame
so you can set size, location as for any JFrame
, just remember to set it visibile when your done.
Example
JasperViewer viewer = new JasperViewer(jp, false);
viewer.setLocationRelativeTo(null); //You can set location
viewer.setSize(new Dimension(1000,600)); //You can set size or you set preferredSize and the pack it.
viewer.setVisible(true); //When you are ready, you set the frame to be visibile
Upvotes: 2
Reputation: 1133
try jd.setPageWidth(999);
before JasperCompileManager.compileReport(jd);
Upvotes: 1
Reputation: 1699
I have never worked with this but if u look at code only thing which is hardcoded is "health_info_system"
so i suppose you can use some resource folder and fetch it mby.. or just make it a constant.
private static final String HEALTH_INFO_SYSTEM_DB = "health_info_system";
Upvotes: -1