Retrieve an instance of the report
print options and create a copy.
PrintOutputController printOutputController = rcd.getPrintOutputController();
IPrintOptions printOptions = printOutputController.getPrintOptions();
IPrintOptions newPrintOptions = (IPrintOptions)printOptions.clone(true);
Dissociate the report page size from
the printer page sizes.
newPrintOptions.setDissociatePageSizeAndPrinterPaperSize(true);
Set the report print size.
newPrintOptions.setPaperSize(PaperSize.paperLegal);
Set the orientation of the report.
newPrintOptions.setPaperOrientation(PaperOrientation.landscape);
Modify the print options.
printOutputController.modifyPrintOptions(newPrintOptions);
Note: Non-standard paper sizes can be set using
the
PrintOutputController.modifyUserPaperSize
method.
Get a
ReportDefController object, an
IReportDefinition object, and a
ReportAreaController object .
ReportDefController reportDefController = rcd.getReportDefController();
IReportDefinition reportDefinition = reportDefController.getReportDefinition();
ReportAreaController reportAreaController = reportDefController.getReportAreaController();
Set the number of data records to
paginate on.
IArea detailArea = reportDefinition.getDetailArea();
IAreaFormat areaFormat = detailArea.getFormat();
areaFormat.setVisibleRecordNumberPerPage(1);
reportAreaController.setProperty(detailArea, ReportAreaPropertyEnum.format, areaFormat);
Enable the clamp page footer.
IArea footerArea = reportDefinition.getPageFooterArea();
IAreaFormat footerFormat = footerArea.getFormat();
footerFormat.setEnableClampPageFooter(true);
reportAreaController.setProperty(footerArea, ReportAreaPropertyEnum.format, footerFormat);
Set the orientation of the report
header section.
ReportSectionController reportSectionController = reportDefController.getReportSectionController();
ISection section = reportDefinition.getReportHeaderArea().getSections().getSection(0);
ISectionFormat newSectionFormat = section.getFormat();
newSectionFormat.setPageOrientation(PaperOrientation.landscape);
reportSectionController.setProperty(section, ReportSectionPropertyEnum.format, newSectionFormat);
Example:
This sample shows you how to set different page
sizes for print and web in the same report, set the number of data records to
paginate on, enable the clamp page footer, and change the orientation of a
section.
void setWebPagination(ReportClientDocument rcd) throws ReportSDKException
{
PrintOutputController printOutputController = rcd.getPrintOutputController();
IPrintOptions printOptions = printOutputController.getPrintOptions();
IPrintOptions newPrintOptions = (IPrintOptions)printOptions.clone(true);
newPrintOptions.setDissociatePageSizeAndPrinterPaperSize(true);
newPrintOptions.setPaperSize(PaperSize.paperLegal);
newPrintOptions.setPaperOrientation(PaperOrientation.landscape);
printOutputController.modifyPrintOptions(newPrintOptions);
ReportDefController reportDefController = rcd.getReportDefController();
IReportDefinition reportDefinition = reportDefController.getReportDefinition();
ReportAreaController reportAreaController = reportDefController.getReportAreaController();
IArea detailArea = reportDefinition.getDetailArea();
IAreaFormat areaFormat = detailArea.getFormat();
areaFormat.setVisibleRecordNumberPerPage(3);
reportAreaController.setProperty(detailArea, ReportAreaPropertyEnum.format, areaFormat);
IArea footerArea = reportDefinition.getPageFooterArea();
IAreaFormat footerFormat = footerArea.getFormat();
footerFormat.setEnableClampPageFooter(true);
reportAreaController.setProperty(footerArea, ReportAreaPropertyEnum.format, footerFormat);
ReportSectionController reportSectionController = reportDefController.getReportSectionController();
ISection section = reportDefinition.getReportHeaderArea().getSections().getSection(0);
ISectionFormat newSectionFormat = section.getFormat();
newSectionFormat.setPageOrientation(PaperOrientation.landscape);
reportSectionController.setProperty(section, ReportSectionPropertyEnum.format, newSectionFormat);
}This list includes the classes used by the sample
code:
com.crystaldecisions.sdk.occa.report.application.PrintOutputController
com.crystaldecisions.sdk.occa.report.application.ReportAreaController
com.crystaldecisions.sdk.occa.report.application.ReportClientDocument
com.crystaldecisions.sdk.occa.report.application.ReportDefController
com.crystaldecisions.sdk.occa.report.application.ReportSectionController
com.crystaldecisions.sdk.occa.report.application.ReportAreaPropertyEnum
com.crystaldecisions.sdk.occa.report.application.ReportSectionPropertyEnum
com.crystaldecisions.sdk.occa.report.definition.IArea
com.crystaldecisions.sdk.occa.report.definition.IAreaFormat
com.crystaldecisions.sdk.occa.report.definition.ISection
com.crystaldecisions.sdk.occa.report.definition.ISectionFormat
com.crystaldecisions.sdk.occa.report.definition.IReportDefinition
com.crystaldecisions.sdk.occa.report.document.IPrintOptions
com.crystaldecisions.sdk.occa.report.document.PaperSize
com.crystaldecisions.sdk.occa.report.document.PaperOrientation
com.crystaldecisions.sdk.occa.report.lib.ReportSDKException