Crystal Reports Online Training

Learn Online, Anytime, Anywhere

Step-by-step online tutorials.

14.11 Modifying Print Options

Modifying the Printing Options

The PrintOptions class stores the options for how a report is sent to the printer. This can consist of the destination printer, the paper orientation or the page margins. This is normally set during design mode. While the majority of an application’s reports will use the same settings, you can override the default settings for specific reports. Table 14-4 lists the properties.

Table 14-4. PrintOptions properties.

Property Description
ApplyPageMargins( Sets new page margins.
CustomPaperSourc Sets the current printer paper source.
PageMargin Gets the page margins.
PaperOrientat Switches between Landscape and Portrait.
PaperSiz Sets the paper size using pre-defined size constants.
PaperSourc Sets the tray that the paper is printed from.
PrinterDuple Sets the current printer duplex option.
PrinterNam Change the printer by passing a string that exactly matches the printer name listed in the Printers Control Panel.

Each of these properties is easy to modify. In some cases, you will have to use a predefined constant to set the property (e.g. PaperOrientation and PaperSize).

Changing the printer name can cause the report output to be scrambled. Each printer uses a unique printer language for producing output. If the new printer doesn’t use the same printer language as the default printer that the report was designed to use, the report will not print correctly. For example, if a report was designed for use with an HP printer, it is okay to switch between similar models of an HP printer. But printing this report to Acrobat PDFWriter will result in an unreadable PDF file.

Listing 14-9. Change a report’s printer settings.
[VB.NET]
Dim MyReport As New CrystalReport1
MyReport.PrintOptions.PaperOrientation = CrystalDecisions.[Shared].PaperOrientation.Landscape
MyReport.PrintOptions.PrinterName = "HP LaserJet510"
MyReport.PrintToPrinter(1, False, 0, 0)
[C#]
CrystalReport1 MyReport = new CrystalReport1();
MyReport.PrintOptions.PaperOrientation = CrystalDecisions.Shared.PaperOrientation.Landscape;
MyReport.PrintOptions.PrinterName = "HP LasterJet510";
MyReport.PrintToPrinter(1, false, 0, 0);

Question: How do I set the report to use the “No Printer” option?

Answer: Set the PrinterName property to an empty string.