Jump to content
Changes to the Jaspersoft community edition download ×

How to handle landscape/portrait, etc?

2004 IR Help

Recommended Posts

By: Phil - timelord2004

How to handle landscape/portrait, etc?

2005-02-20 03:21


I noted in the "tips & tricks" some of the justification for using absolute positioning in Jasper Reports. Ok... but is there /any/ way to tell jasper reports that some field is xx% of the page width, and have fields resize dynamically?


Ok, html, xls situations aside, what happens if I design a report for Letter paper, but the users default paper size is A4? A4 is narrower so the report may be uncomfortably close to the sides of the paper, or the printer may not be able to print close enough to the edges to print the page. (Luckily our default page size happens to be A4.)


So anyway, I've set up a report for portrait mode. The report is as wide as practicable, and infact some data cannot fit. (The layout is meant to be a reflection of a list on the screen and it needs to be this wide.) So when I go to print it, I select landscape, but the report still prints in portrait.

I also have a dialog with the JRViewer on it, select print from that and select landscape, but again the report still prints in portrait.

Given the earlier arguments in the "tips & tricks" section, it would seem that even if the report printed in landscape mode, it would not be re-rendered, and still print in the portrait width.


Is there any way to print in landscape mode (by selecting landscape in the print dialog), or does Jasper Reports always ignore this?


It is very common for a user - when they see that the page is too narrow in portrait mode - to switch to landscape mode to get a wider page, so it's not unreasonable to let them do so.


The only way I can see to print in landscape mode is to set the report up that way before it's compiled, right? That means giving the user the choice to select landscape before they can even see a preview? And the landscape/portrait option in the print dialog is ignored (a little krufty)?


Or have I missed something major entirely?


What is the feeling out there, is there a desire for being able to size components as a percentage width of the target page? I haven't looked at the JR source and not sure how complex this'd be, but it'd be a worthwhile feature, no? This could also have benefits when saving the report as html, etc. etc., but make the modifications more daunting!









By: David Lim - aberrant80

RE: How to handle landscape/portrait, etc?

2005-02-21 20:20

I understand what you mean. But unfortunately, you have to hardcode the size in XML. The only way to resize it is to do it dynamically. You'll have to dig in to the JasperDesign elements and manually calculate and set the dimensions based on paper size and margins.





By: T Elisabeth Schmitz - netbeans

RE: How to handle landscape/portrait, etc?

2005-02-22 02:48

There was a brief discussion a few days ago about adjusting page sizes dynamically: https://sourceforge.net/forum/forum.php?thread_id=1229887&forum_id=113530


My problem was a bit less complex though: I just wanted to adjust the page height to the number of detail lines (I am printing till receipts on rolls of paper).


I did this by loading and copying the JasperReport object to a subclass of JasperReport, which gives you access to page height and width. There I modified the page height *prior* to filling the report.


But what you want to achieve is rather more complex because you would need to fit the elements on the page.

I agree, the percentage width would be a desirable feature, particularly if the application should be able to print on Letter and A4.

Link to comment
Share on other sites

  • Replies 0
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

Top Posters In This Topic

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 account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Create New...