com.crystaldecisions.sdk.occa.report.application
Class PrintOutputController

java.lang.Object
  extended by com.crystaldecisions.sdk.occa.report.application.PrintOutputController

public class PrintOutputController
extends java.lang.Object

This object is used to export reports to a specific format, such as Microsoft Excel (97-2003), Rich Text Format (RTF), or PDF and to modify various formatting options. It is also used to print a report with RAS SDK server-side printing.


Method Summary
static IExportOptions createDefaultExportOptions(ReportExportFormat format)
          For internal use only
 java.io.InputStream export(IExportOptions exportOptions)
           Exports this document to the specified format with options.
 java.io.InputStream export(IExportOptions exportOptions, IRequestContext requestContext)
          For internal use only
 void export(IExportOptions exportOptions, IRequestContext requestContext, java.io.OutputStream os)
          For internal use only
 java.io.InputStream export(ReportExportFormat format)
           Exports this document to the specified format.
 void export(ReportExportFormat format, java.io.OutputStream os)
          For internal use only
 java.util.List findAvailableMediaTrays(java.lang.String printerName)
           Gets the list of available java MediaTrays for a give printer name.
 IPrintOptions getPrintOptions()
           Gets the print options.
 java.util.Locale getProductLocale()
           
 XMLExportFormats getSavedXMLExportFormats()
           Gets a collection of all the available XML export format types saved in the report.
 void modifyPageMargins(int left, int right, int top, int bottom)
           Modifies the appropriate properties in the PageMargins object.
 void modifyPaperOrientation(PaperOrientation orientation)
           Modifies the paper orientation.
 void modifyPrinterName(java.lang.String printerName)
           Modifies the printer name.
 void modifyPrintOptions(IPrintOptions printOptions)
           Modifies the print options.
 void modifyUserPaperSize(int height, int width)
           Modifies the custom paper size
 void printReport(java.awt.print.PrinterJob job, java.util.List contexts)
          For internal use only
 void printReport(java.awt.print.PrinterJob job, java.util.List contexts, PrintReportOptions printReportOptions)
           For internal use only.
 void printReport(PrintReportOptions printReportOptions)
           Prints a report to a specified printer that is controlled by RAS SDK server-side printing.
 void setPageMarginFormula(PageMarginConditionFormulaType pageMarginConditionFormulaType, IConditionFormula newPageMarginConditionFormula)
           Modifies the appropriate properties in the PageMargins object.
 void setSavedXMLExportFormats(XMLExportFormats _xmlExportFormats)
          For internal use only
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

export

public java.io.InputStream export(ReportExportFormat format)
                           throws ReportSDKException

Exports this document to the specified format.

Parameters:
format - A ReportExportFormat object that specifies the export format of the report.
Returns:
An InputStream object containing the report document exported to the specified format.
Throws:
ReportSDKException

export

public java.io.InputStream export(IExportOptions exportOptions)
                           throws ReportSDKException

Exports this document to the specified format with options.

Parameters:
exportOptions - The export options that can be specified in the IExportOptions object.
Returns:
An InputStream object containing the report document exported to the specified format.
Throws:
ReportSDKException
See Also:
IExportOptions

export

public java.io.InputStream export(IExportOptions exportOptions,
                                  IRequestContext requestContext)
                           throws ReportSDKException
For internal use only

Throws:
ReportSDKException

export

public void export(ReportExportFormat format,
                   java.io.OutputStream os)
            throws ReportSDKException
For internal use only

Throws:
ReportSDKException

export

public void export(IExportOptions exportOptions,
                   IRequestContext requestContext,
                   java.io.OutputStream os)
            throws ReportSDKException
For internal use only

Throws:
ReportSDKException

createDefaultExportOptions

public static IExportOptions createDefaultExportOptions(ReportExportFormat format)
For internal use only


getPrintOptions

public IPrintOptions getPrintOptions()
                              throws ReportSDKException

Gets the print options.

Returns:
a reference to the IPrintOptions object
Throws:
ReportSDKException

getSavedXMLExportFormats

public XMLExportFormats getSavedXMLExportFormats()
                                          throws ReportSDKException

Gets a collection of all the available XML export format types saved in the report.

Use this method to get an XMLExportFormats collection. Each XMLExportFormat object in the collection represents an XML format saved in the report that the report can be exported to. The XMLExportFormats collection can be iterated through to provide the user with a list of names or descriptions of all the XML export formats. The report can be programmatically exported to one of these formats using the PrintOutputController.Export method.

See XMLExportFormatOptions class for a code example of how to export a report to an XML format.

Returns:
XMLExportFormats
Throws:
ReportSDKPrinterException
ReportSDKException

modifyPrintOptions

public void modifyPrintOptions(IPrintOptions printOptions)
                        throws ReportSDKException

Modifies the print options.

Note: As of the Report Application Server 12 SDK, the PrintOutputController.modifyPageMargins method must be used to set all page margins to the default value 0. Attempts to set all page margins to 0 using the PrintOutputController.modifyPrintOptions method are ignored.

Example:

This sample shows how to set the print options for a report with the PrintOutputController. The PrintOutputController enables you to export reports to a specific format, such as Excel, RTF, or PDF, and to modify various formatting options.

 PrintOutputController printOutputController = clientDoc.getPrintOutputController();
 IPrintOptions printOptions = printOutputController.getPrintOptions();
 IPrintOptions newPrintOptions = (PrintOptions)((PrintOptions)printOptions).clone(true);
 newPrintOptions.setPaperSize(PaperSize.paperLegal);
 newPrintOptions.setPaperOrientation(PaperOrientation.landscape);
 printOutputController.modifyPrintOptions(newPrintOptions);
 

Parameters:
printOptions - the IPrintOptions object to be modified
Throws:
ReportSDKException

modifyPageMargins

public void modifyPageMargins(int left,
                              int right,
                              int top,
                              int bottom)
                       throws ReportSDKException

Modifies the appropriate properties in the PageMargins object. All properties modified in this method are measured in twips.

Parameters:
left - the left margin of the report
right - the right margin of the report. Absolute, not relative to the left property.
top - the top margin of the report
bottom - the bottom margin of the report. Absolute, not relative to the top property.
Throws:
ReportSDKException

setPageMarginFormula

public void setPageMarginFormula(PageMarginConditionFormulaType pageMarginConditionFormulaType,
                                 IConditionFormula newPageMarginConditionFormula)
                          throws ReportSDKException

Modifies the appropriate properties in the PageMargins object. All properties modified in this method are measured in twips.

Example:

This sample shows how to set a page margin condition formula. The formula checks whether a page number is even or odd and sets the margins accordingly: if the page is an even number, the margin is set to one inch; if the page is an odd number, the margin is set to two inches. The formula is applied to the left margin of the report. For more information on the syntax of conditional formulas please refer to Crystal Reports Online Help.

Use this method if you want to modify only the page margin formulas of a report. For an alternate method see setPageMarginConditionFormulas.

 PrintOutputController printOutputController = clientDoc.getPrintOutputController();
 IConditionFormula condFormula = new ConditionFormula();
 String formulaText = "If Remainder(pagenumber,2) = 0 then 1440 else 2880";
 condFormula.setSyntax(FormulaSyntax.crystal);
 condFormula.setText(formulaText);
 printOutputController.setPageMarginFormula(PageMarginConditionFormulaType.left, condFormula);
 

Note: There are 1440 twips in an inch.

Parameters:
pageMarginConditionFormulaType - specifies the margin that the formula will be applied to.
newPageMarginConditionFormula - the page margin formula.
Throws:
ReportSDKException

modifyUserPaperSize

public void modifyUserPaperSize(int height,
                                int width)
                         throws ReportSDKException

Modifies the custom paper size

Parameters:
height - the height of the paper. This value must be greater than the distance between the vertical margins.
width - the width of the paper. This value must be greater than the distance between the horizontal margins.
Throws:
ReportSDKException

modifyPrinterName

public void modifyPrinterName(java.lang.String printerName)
                       throws ReportSDKException

Modifies the printer name.

Parameters:
printerName - the name of the printer to be modified
Throws:
ReportSDKException

modifyPaperOrientation

public void modifyPaperOrientation(PaperOrientation orientation)
                            throws ReportSDKException

Modifies the paper orientation.

Parameters:
orientation - the PaperOrientation object to be modified
Throws:
ReportSDKException

findAvailableMediaTrays

public java.util.List findAvailableMediaTrays(java.lang.String printerName)
                                       throws ReportSDKPrinterException

Gets the list of available java MediaTrays for a give printer name.

Parameters:
printerName - name of the printer.
Returns:
A list of MediaTray objects. Returns null if the printer cannot be found.
Throws:
ReportSDKPrinterException

printReport

public void printReport(java.awt.print.PrinterJob job,
                        java.util.List contexts)
                 throws ReportSDKPrinterException
For internal use only

Throws:
ReportSDKPrinterException

printReport

public void printReport(java.awt.print.PrinterJob job,
                        java.util.List contexts,
                        PrintReportOptions printReportOptions)
                 throws ReportSDKPrinterException

For internal use only.

Throws:
ReportSDKPrinterException

printReport

public void printReport(PrintReportOptions printReportOptions)
                 throws ReportSDKPrinterException

Prints a report to a specified printer that is controlled by RAS SDK server-side printing.

Parameters:
printReportOptions - the PrintReportOptions of the report to be printed by RAS SDK server-side printing
Throws:
java.util.concurrent.CancellationException - if the print job was cancelled
ReportSDKPrinterException

setSavedXMLExportFormats

public void setSavedXMLExportFormats(XMLExportFormats _xmlExportFormats)
                              throws ReportSDKException
For internal use only

Throws:
ReportSDKException

getProductLocale

public java.util.Locale getProductLocale()