rcracel Posted September 21, 2006 Share Posted September 21, 2006 Let me start with a little bit of background... my report generation engine (using jasper of course), when loading a new jasper layout, reads and compiles a master template, which in turn has a subreport that contains the actual report. The master layout contains only header info (company name, date, ...). Most of my layouts use page size letter. But for a few selected reports I need to use custom page sizes. Currently what I do is, whenever the sub-report page size differs from the master layout page size, I do my best to enlarge the master layout in the following way: I get the JasperPrint object and iterate over all objects of all pages. If the object appears to be left aligned, I leave it alone. If the object is centered, I move it so it will still be centered in the new size. If the object appears to be right aligned I move it so it has the same distance to the right border. This almost works. My current problem is that I do NOT want to move elements that came from the sub-report, but rather only move the elements that belong to the master-layout. Is there a way to identify which layout the elements are coming from? I could hardcode the name(or id) of the elements on my master layout page, but that would mean that whenever we change the master layout we would also need to change the code that compiles/generates it. If I could figure out what band the element belongs to then I could just ignore everything inside detail. thanks,RCPost edited by: rcracel, at: 2006/09/21 15:00 Link to comment Share on other sites More sharing options...
Teodor Danciu Posted September 22, 2006 Share Posted September 22, 2006 Hi, The elements in the report template can be marked with a unique key. The problem is that we do not preserve this key value in the generated document (JasperPrint object model). You see, in the generated document we'll end up having multiple elements with the same key because they originated from the same template element.If you think this would help solve your problem, then please post a feature request and we'll see about implementing it. Thank you,Teodor Link to comment Share on other sites More sharing options...
C-Box Posted September 22, 2006 Share Posted September 22, 2006 you could use the "AnchorNameExpression" to mark all your SubReport-Elements with a static text (for example "SR-Element") of course just if you don't use HyperLinks.... this is, how we mark elements that must be modified after the JasperPrint-Object is generated. Works quite well so far! B) just my two centregards from GermanyC-Box Link to comment Share on other sites More sharing options...
rcracel Posted September 22, 2006 Author Share Posted September 22, 2006 Thanks for your answer Teodor and CBox. I like CBox's idea, that would certainly help as long I don't use hyperlinks. But this will not solve my problem as I just noticed that although I can easily move elements around width-wise, it would be very hard to adjust the elements height-wise. Let me try to explain (and maybe someone has an idea on how to overcome this)... I have a master layout letter size (11x8.5)I have a subreport 17x11, and need to final size to be that. At first I thought that I only had to rearrange my elements by moving them to the right or centering them on the page. But after closer inspection, since the JasperPrint object is generated first, when I resize my already populated master layout I noticed that the detail does not go all the way to the bottom of the page, but rather only goes up until it would normaly go on the "11x8.5" page. I looked for a way to change the page size in the JasperReport object but it didn't allow me. Probably for a good reason. :) In the end, I think if there was a way to change the page size in the JasperReport object, before the rows are populated, then I could fully use one single master layout. But until then I am allowing my report writers to define custom master-layouts that match the page sizes they need to use. And if they ever run into a case where they will end up with an odd page size they can just go ahead and write new master layouts for that size. Although we have hundreds of reports on our application, most of them are letter size and this is not going to be such a big deal (although not as nice :)). Thanks for your help again, let me know if I am missing something else in here. :) RC 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