Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » BIRT » Setting Paper Size through an API
Setting Paper Size through an API [message #367177] Tue, 24 February 2009 12:40 Go to next message
Eclipse UserFriend
Originally posted by: bigboxerbig.hotmail.com

Hello,

We have a requirement to be able to be able to select different paper
sizes from within our executing application.

BIRT Master Pages have types of "A4", "US Legal" etc selectable from a
drop list when designing the report. Is there any way of programatically
selecting one of these before the report is generated?

I've had a quick look at SimpleMasterPageHandle, but there's no method
to set the paper "type".

Another way of achieveing this would be to programatically switch the
master page behind the rptdesign file, also prior to the report being
generated. Does anyone know how to do this?

Thanks
Re: Setting Paper Size through an API [message #367183 is a reply to message #367177] Tue, 24 February 2009 23:40 Go to previous messageGo to next message
Scott Rosenbaum is currently offline Scott RosenbaumFriend
Messages: 425
Registered: July 2009
Senior Member
Ben,

This is just a little sample of setting up a page with a variety of custom
options, including the page size.

//I assume you have a ReportDesignHandle
ReportDesignHandle reportDesignHandle

MasterPageHandle masterPageHandle =
reportDesignHandle.getElementFactory().newSimpleMasterPage("Master Page");
reportDesignHandle.getMasterPages().add(masterPageHandle);

// pick an orientation (does not make sense if using custom page sizing)
masterPageHandle.setOrientation(DesignChoiceConstants.PAGE_O RIENTATION_LANDSCAPE);

// Set the margins
masterPageHandle.setProperty(IMasterPageModel.TOP_MARGIN_PRO P, "15pt");
masterPageHandle.setProperty(IMasterPageModel.LEFT_MARGIN_PR OP, "15pt");
masterPageHandle.setProperty(IMasterPageModel.BOTTOM_MARGIN_ PROP, "15pt");
masterPageHandle.setProperty(IMasterPageModel.RIGHT_MARGIN_P ROP, "15pt");

// TODO page background color not support
masterPageHandle.setProperty(IStyleModel.BACKGROUND_COLOR_PR OP, "#FFFFAA");

// You can use a standard Page Size
//masterPageHandle.setPageType(DesignChoiceConstants.PAGE_SI ZE_US_LETTER);

// Or you can use a custom page size
// If you go with a custom page size, need to set the Page Type
masterPageHandle.setPageType(DesignChoiceConstants.PAGE_SIZE _CUSTOM);
masterPageHandle.setProperty(IReportItemModel.HEIGHT_PROP, "5in");
masterPageHandle.setProperty(IReportItemModel.WIDTH_PROP, "10 in");

LabelHandle labelHandle =
reportDesignHandle.getElementFactory().newLabel("titleLabel ");
labelHandle.setText("This is the Title of the Report (MasterPage)");
labelHandle.setStyleName("TitleStyle");
masterPageHandle.addElement(labelHandle, 0);


Scott Rosenbaum

ben boxer wrote:
> Hello,
>
> We have a requirement to be able to be able to select different paper
> sizes from within our executing application.
>
> BIRT Master Pages have types of "A4", "US Legal" etc selectable from a
> drop list when designing the report. Is there any way of programatically
> selecting one of these before the report is generated?
>
> I've had a quick look at SimpleMasterPageHandle, but there's no method
> to set the paper "type".
>
> Another way of achieveing this would be to programatically switch the
> master page behind the rptdesign file, also prior to the report being
> generated. Does anyone know how to do this?
>
> Thanks
Re: Setting Paper Size through an API [message #367187 is a reply to message #367183] Wed, 25 February 2009 10:11 Go to previous message
Eclipse UserFriend
Originally posted by: bigboxerbig.hotmail.com

Many thanks, Scott.

In the end I used DesignChoiceConstants.PAGE_SIZE_<param> (set via a
parameter). This allows us to switch paper sizes depening on the Locale
that our app is deployed in.

I get the handle to the design as part of RunAndRender, following code
demonstrates;

logger.info(" opening report design");
// Open a report design - use design to modify design, retrieve
embedded images etc.

IReportRunnable design = engine.getEngine().openReportDesign(is);

try {

design.getDesignInstance().getMasterPage("designMsterPage").setPageType(pageType);

} catch (SemanticException se) {
logger.error(se.getMessage());
}

logger.info("creating run and render task");
// Create task to run the report and render the report
IRunAndRenderTask task =
engine.getEngine().createRunAndRenderTask(design);
....
....

Many thanks again.



Scott Rosenbaum wrote:
> Ben,
>
> This is just a little sample of setting up a page with a variety of
> custom options, including the page size.
>
> //I assume you have a ReportDesignHandle
> ReportDesignHandle reportDesignHandle
>
> MasterPageHandle masterPageHandle =
> reportDesignHandle.getElementFactory().newSimpleMasterPage("Master Page");
> reportDesignHandle.getMasterPages().add(masterPageHandle);
>
> // pick an orientation (does not make sense if using custom page sizing)
> masterPageHandle.setOrientation(DesignChoiceConstants.PAGE_O RIENTATION_LANDSCAPE);
>
>
> // Set the margins
> masterPageHandle.setProperty(IMasterPageModel.TOP_MARGIN_PRO P, "15pt");
> masterPageHandle.setProperty(IMasterPageModel.LEFT_MARGIN_PR OP, "15pt");
> masterPageHandle.setProperty(IMasterPageModel.BOTTOM_MARGIN_ PROP, "15pt");
> masterPageHandle.setProperty(IMasterPageModel.RIGHT_MARGIN_P ROP, "15pt");
>
> // TODO page background color not support
> masterPageHandle.setProperty(IStyleModel.BACKGROUND_COLOR_PR OP, "#FFFFAA");
>
> // You can use a standard Page Size
> //masterPageHandle.setPageType(DesignChoiceConstants.PAGE_SI ZE_US_LETTER);
>
> // Or you can use a custom page size
> // If you go with a custom page size, need to set the Page Type
> masterPageHandle.setPageType(DesignChoiceConstants.PAGE_SIZE _CUSTOM);
> masterPageHandle.setProperty(IReportItemModel.HEIGHT_PROP, "5in");
> masterPageHandle.setProperty(IReportItemModel.WIDTH_PROP, "10 in");
>
> LabelHandle labelHandle =
> reportDesignHandle.getElementFactory().newLabel("titleLabel ");
> labelHandle.setText("This is the Title of the Report (MasterPage)");
> labelHandle.setStyleName("TitleStyle");
> masterPageHandle.addElement(labelHandle, 0);
>
>
> Scott Rosenbaum
>
> ben boxer wrote:
>> Hello,
>>
>> We have a requirement to be able to be able to select different paper
>> sizes from within our executing application.
>>
>> BIRT Master Pages have types of "A4", "US Legal" etc selectable from a
>> drop list when designing the report. Is there any way of
>> programatically selecting one of these before the report is generated?
>>
>> I've had a quick look at SimpleMasterPageHandle, but there's no method
>> to set the paper "type".
>>
>> Another way of achieveing this would be to programatically switch the
>> master page behind the rptdesign file, also prior to the report being
>> generated. Does anyone know how to do this?
>>
>> Thanks
Previous Topic:NoClassDefFoundError: org/w3c/tidy/Tidy
Next Topic:One page one chart
Goto Forum:
  


Current Time: Sat Apr 20 04:10:36 GMT 2024

Powered by FUDForum. Page generated in 0.05789 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top