SAP Knowledge Base Article - Public

1220481 - How to change the printer for server-side printing when using the RAS Java SDK

Symptom

A Java web application uses the Report Application Server (RAS) SDK to print a Crystal report server side. At run time, how do you change the printer to which the output is sent?

Resolution

Use the following sample code to specify the printer, specifying the name of a printer that is accessible from your Java web application:

 

PrintReportOptions printReportOptions = new PrintReportOptions();

printReportOptions.setPrinterName("YOUR_PRINTER_NAME");

reportClientDocument.getPrintOutputController().printReport(printReportOptions);

 

====================

NOTE:

 

" Ensure that the Java web application server is running under an account that has the required permissions to access the printer.

 

" For server-side printing, the Java RAS SDK uses the Java Print Service, which was introduced with Java SDK 1.4. You will not be able to change the printer using Java SDK 1.3.

 

" To obtain the names of all accessible printers, create a JSP page that executes the following code snippet:

 

javax.print.PrintServce[] ps = javax.print.PrintServiceLookup.lookupPrintServices(null, null);

for(int i = 0 ; i < ps.length ; i++ ) {

out.println(ps[i].getName() + "<br>");

}

 

See Also

For information on changing the printer using the .NET RAS SDK, refer to Note 1216937.

Keywords

SWITCHING ALTERING CHANGING PRINTER RUN-TIME ON SERVER SERVER-SIDE PRINTING Crystal Reports Server XI Release 2 Changing Printer , c2019507 , KBA , BI-BIP , Business intelligence platform , Problem

Product

Crystal Reports Server XI R2 ; Crystal Reports Server XI R2, OEM edition ; SAP Crystal Server XI