I am unable to print black and white using Crystal reports .NET object model.
I am using 'Cute PDF' printing driver which is able to print B&W/color correctly using Windows API directly (with DEVMODE/dmColor+dmFields). Trying to do the same via Crystal does not work. Two attempts have been made:
- using SetDevMode (PrinterSettings::SetHdevmode() and PageSettings::SetHdevmode() with DEVMODE structure filled as in case of direct Windows API direct call)
- using PrinterSettings/PageSettings Color field
None of these seem to work and the report is printed in color regardless of parameters set.
Powershell script used for test:
#load the assemblies
[reflection.assembly]::LoadWithPartialName('System.Drawing.Printing')
[reflection.assembly]::LoadWithPartialName('CrystalDecisions.Shared')
[reflection.assembly]::LoadWithPartialName('CrystalDecisions.CrystalReports.Engine')
$ReportLocation = "C:\Test\chequereport.rpt"
$PrinterName = "CutePDF Writer"
#setup Crystal Document object
$Report = New-Object CrystalDecisions.CrystalReports.Engine.ReportDocument
#load the Crystal Report
$Report
.Load($ReportLocation)
#create the required printer and page settings
$PrintOptions = New-Object System.Drawing.Printing.PrinterSettings
$PageOptions = New-Object System.Drawing.Printing.PageSettings
#add the desired printer or it will print to the default printer
$PrintOptions.PrinterName = $PrinterName
$PrintOptions.Copies = 1
$PageOptions.Color = $false
$PrintOptions.DefaultPageSettings.Color = $false
$Report.PrintToPrinter($PrintOptions, $PageOptions, $false)
$Report.Dispose()