Discussions
Categories
Groups
Community Home
Categories
INTERNAL ENABLEMENT
POPULAR
THRUST SERVICES & TOOLS
CLOUD EDITIONS
Quick Links
MY LINKS
HELPFUL TIPS
Back to website
Home
Intelligence (Analytics)
how can i shrink the table
alexAf
Hello,
I am using birt 2.5.1. Can't understand how I can make a table fit on one page when generating PDF from eclipse designer...
I've set up table Hight to be 297 mm (which is A4), tick Can shrink box, set Page break interval to 0.
Still didn't manage to squeeze the table.
Could you please help? In previous birt versions table shrinking was done by default.
Find more posts tagged with
Comments
mwilliams
Hi alexAf,
Are you going to be deploying this report with the birt viewer? If so, I believe there is a URL parameter still called fittopage that you can set to true in your URL to fit a PDF to the page. This option is also there, I believe, if you run the report in the viewer and export the report to PDF, you can choose the fit to page radio button.
alexAf
Don't really understand, what does mean deploy the report with birt viewer?
I just wanted to check that my report looks correctly from the birt viewer.
I've added the parameter 'fittopage' to the birt design, set default value to be true. Now every time when I try to preview the report in birt viewer parameter is checked but still can't get my table to by shrinked...
mwilliams
alexAf,
I was talking about a URL parameter for the birt viewer, not a report parameter. Sorry if I confused you on that. If you deploy the birt viewer to an application server, like Tomcat, for your users to be able to access the reports, they are called by a URL which you could append the line &&__fittopage=true to the end of the URL to make it fit to the page in PDF. A way you can check whether this will do what you're wanting is to view the report in the web viewer. Then, choose export report from the toolbar and choose the "fit to page" radio button.
alexAf
Thank you for explanation mwilliams but we are not planning to deploy birt viewer. Sorry, i didn't understood that. Java class will use birt engine to generate pdfs.
Do you know if there is a way to adjust report design parameters or just table properties so I that the table would shrink into page?
mwilliams
alexAf,<br />
<br />
Take a look at the following page in the doc:<br />
<br />
<a class='bbc_url' href='
http://www.birt-exchange.org/documentation/BIRT_220/EngineJavadoc/engine/api/org/eclipse/birt/report/engine/api/IPDFRenderOption.html'>IPDFRenderOption
(Birt Engine API)</a><br />
<br />
It may help with setting the fittopage variable in java for you.
alexAf
So, there is no way i can configure it in the design report?
It just funny that in previous birt versions it was a default behavior but now some dodgy things need to be done to make it work
mani_03
You Have To Do A Very Simple Task Change Your Page Type As Custome & Set The Margin
alexAf
No, didn't work for birt 2.5.1 (latest version currently)
If I understood you right, the following simple actions should be done:
Go to the Master page properties, in the general tab change type to be "Custom". On the same tab adjust Width and Height, say, 100mmx100mm
Add Text item on the layout, add some text in it. Preview in birt viewer.
Unfortunatelly doesn't work...
mwilliams
alexAf,
Setting the custom page size doesn't even fit your table fit onto one page? Is your table very, very large or something? What version of BIRT were you using before that automatically fit the contents to a PDF page? I think this was back in 2.2 and most people considered it a bug. Is your table fitting on your page widthwise and just not heightwise?
alexAf
the table contains dynamic data. Some time this data can be quite large and may not fit on A4. But report requirement is that everything should fit within one page.
The problem is very easy to reproduce. Create a report with custom type master page. Adjust margins and add a table with some data in it which should be big enough in order not to fit on one page.
We were using birt version 2.2.2.
You mean that in the latest version it's impossible to specify that this particular table or custom table should shrink and fit on one page?
In the options of the Master page or table you can see shrink attribute.Do you know what this shrink attribute does?
mwilliams
alexAf,
Personally, I've never used the can shrink option. I'll have to investigate that a bit and let you know if I find anything out about it. As for being able to fit your report to the page in PDF, the fit to page option in the link I sent you takes care of that, I believe. This is what was a problem in 2.2.2, I think, that this variable was set automatically to true. That worked out for your requirements in 2.2.2 even though it was "a bug". So, all you should need to do to get your required output is to set this.
alexAf
Thank you mwilliams for spending your time helping people and making this world more stable)
I found a suitable solution to my problem:
in the following createPDFRenderOption method of the ReportEngineService class we can see how render options are set up depending on the pageOverflow input parameter:
ReportEngineService.java:
private PDFRenderOption createPDFRenderOption( String servletPath,
HttpServletRequest request, int pageOverflow, boolean isDesigner )
......
// page overflow setting
switch ( pageOverflow )
{
case IBirtConstants.PAGE_OVERFLOW_AUTO :
renderOption.setOption( PDFRenderOption.PAGE_OVERFLOW, Integer
.valueOf( PDFRenderOption.OUTPUT_TO_MULTIPLE_PAGES ) );
break;
case IBirtConstants.PAGE_OVERFLOW_ACTUAL :
renderOption.setOption( PDFRenderOption.PAGE_OVERFLOW, Integer
.valueOf( PDFRenderOption.ENLARGE_PAGE_SIZE ) );
break;
case IBirtConstants.PAGE_OVERFLOW_FITTOPAGE :
renderOption.setOption( PDFRenderOption.FIT_TO_PAGE,
Boolean.TRUE );
break;
default :
renderOption.setOption( PDFRenderOption.PAGE_OVERFLOW, Integer
.valueOf( PDFRenderOption.OUTPUT_TO_MULTIPLE_PAGES ) );
}
.........
pageOverflow parameter value is evaluated in getPageOverflow method depending on InputOptions.OPT_PAGE_OVERFLOW report option variable
private int getPageOverflow( InputOptions inputOptions )
{
Integer pageOverflowInt = (Integer) inputOptions
.getOption( InputOptions.OPT_PAGE_OVERFLOW );
int pageOverflow = ( pageOverflowInt != null ) ? pageOverflowInt
.intValue( ) : 0;
return pageOverflow;
}
And example on how InputOptions.OPT_PAGE_OVERFLOW is beeing set up from context we can find in AbstractBaseActionHandler class in method createInputOptions
AbstractBaseActionHandler:
protected InputOptions createInputOptions( BaseAttributeBean bean, boolean svgFlag )
{
InputOptions options = new InputOptions( );
.....
options.setOption( InputOptions.OPT_PAGE_OVERFLOW, ParameterAccessor.getPageOverflow( context.getRequest() ) );
.....
}
getPageOverflow method in ParameterAccessor class shows what should be the name of the report parameter and which values it may has.
ParameterAccessor :
public static int getPageOverflow( HttpServletRequest request )
{
int pageOverflow = getParameterAsInt( request, PARAM_PAGE_OVERFLOW );
if ( pageOverflow < 0 )
pageOverflow = IBirtConstants.PAGE_OVERFLOW_AUTO;
return pageOverflow;
}
/**
* URL parameter name to indicate the page overflow when render report as
* PDF.
*/
public static final String PARAM_PAGE_OVERFLOW = "__pageoverflow";
In the IBirtConstants class we have:
/**
* Page overflow mode when render report as PDF/PS
*/
public static final int PAGE_OVERFLOW_AUTO = 0;
public static final int PAGE_OVERFLOW_ACTUAL = 1;
public static final int PAGE_OVERFLOW_FITTOPAGE = 2;
So if you want the content of your page to fit within one page then in the report design file you need to add report parameter "__pageoverflow" with default value 2
mwilliams
Excellent! Glad it's all working now! Let us know whenever you have questions.
mani_03
hi alexAf,
first see in layout that what size your report is taking then go to the master page there are many option at the size , with take it one of them as in, mm % pix.. i think you have to choose in according to your rptdesign that how many inch its with is ....