Quantcast
Channel: SCN : Discussion List - SAP Crystal Reports, version for Visual Studio
Viewing all articles
Browse latest Browse all 3636

Cannot print B&W with Crystal Reports API

$
0
0

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:

  1. using SetDevMode (PrinterSettings::SetHdevmode() and PageSettings::SetHdevmode() with DEVMODE structure filled as in case of direct Windows API direct call)
  2. 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

 

#print

$Report.PrintToPrinter($PrintOptions, $PageOptions, $false)

 

$Report.Dispose()


Viewing all articles
Browse latest Browse all 3636

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>