Thursday, July 24, 2014

DynamicReports set the title, zoom ratio, page fit to frame width of JasperViewer

When report.show() is called, the JasperViewer will display your report on the screen. By default, the title of the JasperViewer is "JasperViewer", and the zoom ratio is 100%. Follwing is some sample code for setting the title of the JasperViewer and setting the zoom ratio of the report to allow it to fit the width of the frame.

JasperReportBuilder report = DynamicReports.report();
report.columns(col.column("Column 1", "col1", DataTypes.stringType(),
                        . . . . . .
                       );
report.setDataSource(<dataSource>);

//Create the JasperViewer frame
JasperViewer reportViewer = new JasperViewer(report.toJasperPrint(), false);
//Without the second boolean argument, parent frame closes when the JasperViewer is closed
//JasperViewer reportViewer = new JasperViewer(report.toJasperPrint();

//Set the title to your choice
reportViewer.setTitle("<your title>");

//Set the zoom ratio, here it is 110%
//reportViewer.setZoomRatio(new Float(1.10));

//The page fit frame width zoom ration is 89.49%
reportViewer.setZoomRatio(new Float(0.8949)); //the frame fit ratio

reportViewer.setVisible(true);
       
---------------------------------------------------------------------------------------------------------

                        
If you have ever asked yourself these questions, this is the book for you. What is the meaning of life? Why do people suffer? What is in control of my life? Why is life the way it is? How can I stop suffering and be happy? How can I have a successful life? How can I have a life I like to have? How can I be the person I like to be? How can I be wiser and smarter? How can I have good and harmonious relations with others? Why do people meditate to achieve enlightenment? What is the true meaning of spiritual practice? Why all beings are one? Read the book free here.

No comments:

Post a Comment