Change Master Page width on Report creation

Hi @ all,

I?ve got a Problem in BIRT (v.3.7.2). I need to scale the Master Page of my Report by the width of a Crosstab dynamically by designing the Report. I?ve choose the option ?can shrink? so the Crosstab automatically shrink to the maximum width in the moment the Report is created. Know I need to adapt the width of the Master Page to the width of the Crosstab.

Ill tried the following Script:

beforeFactory:

importPackage(Packages.org.eclipse.birt.report.model.api.elements);

importPackage(Packages.org.eclipse.birt.report.model.api);


reportContext.getReportRunnable().designHandle.getDesignHandle().findMasterPage( "NewSimpleMasterPage").setProperty("width","100 in" );

And it works fine. What can I do to switch the Master Page width dynamically to the width of the Crosstab? Is the beforeFactory the right place for the Script? I am thankful for every kind of help.

Comments

  • mwilliamsmwilliams BIRT Guru
    edited December 1969
    In the beforeFactory, you won't know the width of the crosstab. The beforeFactory is where the masterpage width has to be changed, though, so, you'd have to connect to your data and determine the number of groups you'll have before this. Another option could be to create several masterpages and set your masterpage in the onCreate of your crosstab depending on your determined number of groups. Not exactly what you're wanting, but could be an option. Let me know if you have questions.

    Regards,

    Michael Williams

    eSignLive Evangelism & Community Manager | eSignLive by VASCO
     
    Find me on:
    Twitter
    Facebook
    Blog

    LinkedIn

    eSignLive Developer Community
     
    Email me:
    Google: [email protected]

  • edited December 1969
    Thanks for that. What I exactly want is a dynamic Master Page which is as big as my Cross table, because it depends on the Data how big the cross table will get and sometimes it gets really huge. I want to Display the report in a Web browser not for printing! I Found the Problem, that the width of a Crosstab isn?t calculated at the time of the before Factory, by myself but I haven?t an idea how to handle it.
    My strategy to handle it was to allow the crosstab to resize dynamically with the ?can shrink? Style option by report creation. Than get the width of the crosstab and resize the master page. Ill tried it in the before Factory but at this time the width of the Crosstab is still 0. My actual script looks like this:

    Before Factory:
    importPackage(Packages.org.eclipse.birt.report.model.api.elements);
    importPackage(Packages.org.eclipse.birt.report.model.api);

    var vTable = this.getReportElement( "t" );
    var vTableWidth = vTable.getWidth();

    Packages.java.lang.System.out.println(":" + vTableWidth);
    reportContext.getReportRunnable().designHandle.getDesignHandle().findMasterPage( "NewSimpleMasterPage").setProperty("width", vTableWidth);

    ?t? is the name of the table.
  • mwilliamsmwilliams BIRT Guru
    edited December 1969
    If you go to the property editor and set the report layout to auto, rather than fixed, the output shouldn't depend on a maseterpage size, unless you're outputting to PDF or another fixed page output.

    Regards,

    Michael Williams

    eSignLive Evangelism & Community Manager | eSignLive by VASCO
     
    Find me on:
    Twitter
    Facebook
    Blog

    LinkedIn

    eSignLive Developer Community
     
    Email me:
    Google: [email protected]

  • edited December 1969
    Hey this works fine, many thanks 2 you!! One last question, do you know if it is possible to read out the auto-created width of the report by script and set it to the masterpage after render, so that the export to pdf works too?
  • mwilliamsmwilliams BIRT Guru
    edited December 1969
    So, you want to know how to make it back to fixed when you output to PDF? It should still fit to the PDF page with auto layout. What issue are you having with PDF?

    Regards,

    Michael Williams

    eSignLive Evangelism & Community Manager | eSignLive by VASCO
     
    Find me on:
    Twitter
    Facebook
    Blog

    LinkedIn

    eSignLive Developer Community
     
    Email me:
    Google: [email protected]

  • edited December 1969
    I used the trick you told me the post before to scale the report in the web application. Then I?ll try to catch the width of the cross table in the before factory because this is the last moment to set the master page width but my problem is that the table width always return 0. Maybe BIRT don?t write the width back to the table width parameter after auto scaling the cross table. I?ll add my script below.

    before factory:

    importPackage(Packages.org.eclipse.birt.report.model.api.elements);
    importPackage(Packages.org.eclipse.birt.report.model.api);


    var size = reportContext.getDesignHandle().getElementByID(3181).getPropertyHandle("width").value;
    Packages.java.lang.System.out.println(":" + size);
    reportContext.getReportRunnable().designHandle.getDesignHandle().findMasterPage( "NewSimpleMasterPage").setProperty("width",size);
  • mwilliamsmwilliams BIRT Guru
    edited December 1969
    Unfortunately, the beforeFactory happens prior to the table being created, so the width probably won't be available in time for this. When you output to PDF, are you wanting the page size to be as big as the crosstab? Or could you page break the crosstab when you output to PDF, to fit to your standard page size?

    Regards,

    Michael Williams

    eSignLive Evangelism & Community Manager | eSignLive by VASCO
     
    Find me on:
    Twitter
    Facebook
    Blog

    LinkedIn

    eSignLive Developer Community
     
    Email me:
    Google: [email protected]

  • edited December 1969
    I?ve viewed the pictures from BIRT construction and at normal the table width should be created at the time of the before factory (view following link).

    http://www.eclipse.org/birt/phoenix/deploy/reportScripting.php

    But never the less ill tried to catch the width to a later Moment but it still doesn?t work.

    I want to resize the pdf to the width of my cross table on create. My workaround at the moment is, to set a really huge width of the master page. This works for the most of my tables but not for all.
  • Hi ,

    I am not getting all the columns displayed into PDF,so
    How to display all the columns of the table in PDF? How can we increase the width of the Master page? Please suggest.

Sign In or Register to comment.