How to get Page setup information (margins, paper size, output direction) from the Birt report file

Source: Internet
Author: User

Report printing, especially the set of reports, page setup information is very important, such as page margins, paper size, output direction, etc., and the relevant parameters of each report may be different, so the relevant parameters from the specific report is a very normal and reasonable idea.

If using Birt as the development tool for the report, Report Designer is responsible for the production of the report, the Birt runtime is responsible for processing the report file, for the browser, the Birt backend output is a Web page, does not include page settings related information, the browser has its own print settings options, and does not read from the Web page, However, Report Designer provides a Setup interface for page setup information at report design time, so we need to manually write code from the runtime API to get page setup information from a specific report, and then pass the parameters to the printer in other ways (the operating printer is not covered in this article). This article provides the relevant sample code through the research of Birt source code.

The page setup information for the Birt Report Designer is reflected in the properties panel for the Home tab, and is no longer mentioned, directly on the code:

ireportengine birtengine = ...; Map moduleoptions = new hashmap (); Moduleoptions.put (Imoduleoption.resource_folder_key, Sc.getrealpath ("/")); Ireportrunnable runnable = birtengine.openreportdesign (reportFileName,null , moduleoptions); Imasterpage  simplemasterpage = runnable.getdesigninstance (). GetReport (). Getmasterpage ("Simple masterpage"); string pagetype = (String)  simplemasterpage.getuserproperty ("type");//paper Type Double height  = 0.0;double width =0.0;//If you have a custom paper type, you need to obtain the width and height of the paper ("Custom"). Equalsignorecase (PageType)) {     DimensionValue heightDV  =  (Dimensionvalue)   Simplemasterpage.getuserproperty ("height");     dimensionvalue widthdv  =   (Dimensionvalue)  simplemasterpage.getuserproperty ("width");     height =  heightdv.getmeasure ();     width   = widthdv.getmeasure ();} string orientation =  (String)  simplemasterpage.getuserproperty ("orientation");//Print output direction  landscape: Transverse, Portrait: longitudinal dimensionvalue topmargindv =  (Dimensionvalue) Simplemasterpage.getuserproperty ("TopMargin");d ouble topmargin = topmargindv.getmeasure ();// Top margin string unit = topmargindv.getunits ();//Unit

There is a strange feeling in this place, that is, the home page of the property editor has a name, the name can be modified, the default is simple MasterPage, if you want to get this page configuration information, the Getmasterpage method will also be the name as a parameter passed in, This is very strange, there is only one page configuration scheme, what is the use of this name?



How to get Page setup information (margins, paper size, output direction) from the Birt report file

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.