2398411 - Wrong Margins when setting in C# code, the new values are not respected

SAP Knowledge Base Article - Public

2398411 - Wrong Margins when setting in C# code, the new values are not respected

Symptom

The top margin in the report differs from the CR Designer and the CR Runtime.

I am using CR Desginer CR2016 SP3 and CRVS2010SP17 and SP18.

The printing is correct, if I use the print engine PrintToPrinter().

Printing with the RAS results in the wrong margins.

Environment

Crystal Reports for Visual Studio SP 17 and SP 18

Reproducing the Issue

I have printed the report with the following code (not complete)

PrinterSettings printer = new PrinterSettings() { PrinterName = PrinterName };

PageSettings pagesettings = new PageSettings();

PrintOutputController rasPrintOutputController;

rasPrintOutputController = _reportClientDocument.PrintOutputController;

PrintReportOptions printreportoptions = new PrintReportOptions();

printreportoptions.PaperSource = (CrPaperSourceEnum)paperRawKind;

//from printer.PaperSources printreportoptions.PrinterName = printernameforCR2011;

printreportoptions.NumberOfCopies = NumCopies;

printreportoptions.Collated = printer.Collate;

rasPrintOutputController.PrintReport(printreportoptions);

Resolution

The solution is to add a regsitry key:

For 32bit application:

[HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\SAP BusinessObjects\Crystal Reports for .NET Framework 4.0\Crystal Reports\DesignerOptions]

"DealWithMinimalMarginsWhenPrinting"=dword:00000001

For 64bit application:

[HKEY_LOCAL_MACHINE\SOFTWARE\SAP BusinessObjects\Crystal Reports for .NET Framework 4.0\Crystal Reports\DesignerOptions]

"DealWithMinimalMarginsWhenPrinting"=dword:00000001

Keywords

CR for VS, Margins, .NET , KBA , BI-DEV-NET , BI Software Development Kits (SDKs) - .NET or Other , Problem

Product

SAP Crystal Reports, developer version for Microsoft Visual Studio