markrgli Posted April 27, 2009 Share Posted April 27, 2009 Hi guys,I have some reports where the page orientation is determined by some user input. The report design files (jrxml) use a portrait orientation but I need to be able to change them before the reports are generated. I have the code that sets the page orientation but it doesn't seem to be working.Any ideas on this one?Thank you in advance. Code: Post Edited by markrgli at 04/28/2009 02:44 Link to comment Share on other sites More sharing options...
lucianc Posted May 5, 2009 Share Posted May 5, 2009 Changing the orientation on the JasperPrint object does not change the width or height of the generated pages. In order to do that you'd need to do it before filling the report, i.e. on the JasperDesign object (which would then need to compile).Regards,Lucian Link to comment Share on other sites More sharing options...
markrgli Posted May 7, 2009 Author Share Posted May 7, 2009 Hi Lucian, I did what you suggested and it worked.Thanks a lot. One headache down. Best regards,Mark Link to comment Share on other sites More sharing options...
sujan Posted September 8, 2010 Share Posted September 8, 2010 Hello Lucian, Can you please let me know in detail what I need to do. I stuck with the same problem. I have 6 subreports. 4 of them need to be printed in portrait and remaining in landscape. Can you please let me know how to do it ?Thanks in advance. Regards,-Sujan Link to comment Share on other sites More sharing options...
markrgli Posted September 13, 2010 Author Share Posted September 13, 2010 Hi Sujan, I attached the code I used to solve the problem. I hope it will be useful to you. Regards,Mark sujanWrote: Hello Lucian, Can you please let me know in detail what I need to do. I stuck with the same problem. I have 6 subreports. 4 of them need to be printed in portrait and remaining in landscape. Can you please let me know how to do it ? Thanks in advance. Regards, -Sujan Code:public static void setPageSizeAndOrientation(JasperDesign design, ReportConfig config) { // ReportConfig, PaperInfo.Size, PaperInfo.Orientation are custom classes/enums PaperInfo.Size size = ReportBuilder.getPaperSize(config); PaperInfo.Orientation orientation = ReportBuilder.getOrientation(config); if (size == PaperInfo.Size.LEGAL) { // Size of Legal is 8.5x14 in. At 72dpi, this translates to // 8.5*72x14*72 = 612x1008. if (orientation == PaperInfo.Orientation.LANDSCAPE) { design.setPageWidth(1008); design.setPageHeight(612); } else { design.setPageWidth(612); design.setPageHeight(1008); } } else if (size == PaperInfo.Size.LETTER) { // Size of Letter is 8.5x11 in. At 72dpi, this translates to // 8.5*72x11*72 = 612x792. if (orientation == PaperInfo.Orientation.LANDSCAPE) { design.setPageWidth(792); design.setPageHeight(612); } else { design.setPageWidth(612); design.setPageHeight(792); } } else { // Default is A4. // Size of A4 is 8.27x11.69 in. At 72dpi, this translates to // 8.27*72x11.69*72 = 595x842. if (orientation == PaperInfo.Orientation.LANDSCAPE) { design.setPageWidth(842); design.setPageHeight(595); } else { design.setPageWidth(595); design.setPageHeight(842); } }} 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