1810294 - Setting printer to Simplex does not work in PrintOutputController ( RAS )

SAP Knowledge Base Article - Public

1810294 - Setting printer to Simplex does not work in PrintOutputController ( RAS )

Symptom

Setting printer to Simplex does not work in PrintOutputController ( RAS )

Environment

Crystal Reports Developer for Visual Studio

Reproducing the Issue

Below are both PrintToPrinter and PrintOutputController.

P2P works, POC does not.

Using one of our internal Printers that by default is set to Duplex ( double sided printing ) through code and setting to Simplex, single sided printing, works in P2P but the setting is ignore in POC.

private void btnPOController_Click_1(object sender, System.EventArgs e) // Print To P button
{
 System.Drawing.Printing.PrintDocument pDoc = new System.Drawing.Printing.PrintDocument();   
 CrystalDecisions.ReportAppServer.Controllers.PrintReportOptions rasPROpts = new CrystalDecisions.ReportAppServer.Controllers.PrintReportOptions();
    CrystalDecisions.Shared.PrintLayoutSettings PrintLayout = new CrystalDecisions.Shared.PrintLayoutSettings();
    CrystalDecisions.ReportAppServer.ReportDefModel.PrintOptions RASPO = new CrystalDecisions.ReportAppServer.ReportDefModel.PrintOptions();

    RASPO.PrinterDuplex = CrPrinterDuplexEnum.crPrinterDuplexSimplex;


    PrintLayout.Scaling = PrintLayoutSettings.PrintScaling.DoNotScale;
    if (pDoc.PrinterSettings.SupportsColor)
    {
        MessageBox.Show("Printer Supports Color", pDoc.PrinterSettings.SupportsColor.ToString());
    }

    if (rdoCurrent.Checked)
    {

        //newOpts.DissociatePageSizeAndPrinterPaperSize = false;

        rasPROpts.PrinterName = cboCurrentPrinters.Text;
        rasPROpts.PaperSize = (CrPaperSizeEnum)cboCurrentPaperSizes.SelectedIndex;
        rasPROpts.PaperSource = (CrPaperSourceEnum)cboCurrentPaperTrays.SelectedIndex;
        rasPROpts.NumberOfCopies = 1;
               
        //rasPROpts.PrinterDuplex = (CrPrinterDuplexEnum)pDoc.PrinterSettings.Duplex;

        //rptClientDoc.PrintOutputController.ModifyPrintOptions((CrPrinterDuplexEnum).crPrinterDuplexSimplex);

        rasPROpts.PrinterDuplex = CrPrinterDuplexEnum.crPrinterDuplexSimplex;

        System.Drawing.Printing.Duplex myDup = new Duplex();
        myDup = Duplex.Simplex;
        rasPROpts.PrinterDuplex = (CrPrinterDuplexEnum)myDup;

        string MyRptName = rpt.FileName.ToString();
        MyRptName = MyRptName.Substring(MyRptName.LastIndexOf(@"\") + 1, (rpt.FileName.Length - 3) - (MyRptName.LastIndexOf(@"\") + 2));
        rasPROpts.JobTitle = MyRptName;
    }
    else
    {
        rasPROpts.PrinterName = cboDefaultPrinters.Text;
        rasPROpts.PaperSize = (CrPaperSizeEnum)cboDefaultPaperSizes.SelectedIndex;
        rasPROpts.PaperSource = (CrPaperSourceEnum)cboDefaultPaperTrays.SelectedIndex;
        rasPROpts.NumberOfCopies = 1;
        //rasPROpts.PrinterDuplex = (CrPrinterDuplexEnum)pDoc.PrinterSettings.Duplex;
        string MyRptName = rpt.FileName.ToString();
        MyRptName = MyRptName.Substring(MyRptName.LastIndexOf(@"\") + 1, (rpt.FileName.Length - 3) - (MyRptName.LastIndexOf(@"\") + 2));
        rasPROpts.JobTitle = MyRptName;
    }

    try
    {
        rptClientDoc.PrintOutputController.PrintReport(rasPROpts);
    }
    catch (Exception ex)
    {
        MessageBox.Show ("More than 1 copy requested - Only supports 1 copy - ERROR: " + ex.Message);
        return;
    }
 MessageBox.Show("Printing report.", "RAS", MessageBoxButtons.OK,MessageBoxIcon.Information );
}

private void btnPrintToPrinter_Click(object sender, EventArgs e)
{
    System.Drawing.Printing.PrintDocument pDoc = new System.Drawing.Printing.PrintDocument();
    CrystalDecisions.Shared.PrintLayoutSettings PrintLayout = new CrystalDecisions.Shared.PrintLayoutSettings();
    System.Drawing.Printing.PrinterSettings printerSettings = new System.Drawing.Printing.PrinterSettings();

    printerSettings.PrinterName = cboCurrentPrinters.SelectedItem.ToString();

    PrintLayout.Scaling = PrintLayoutSettings.PrintScaling.DoNotScale;

    System.Drawing.Printing.PageSettings pSettings = new System.Drawing.Printing.PageSettings(printerSettings);

    rpt.PrintOptions.DissociatePageSizeAndPrinterPaperSize = false;
    rpt.PrintOptions.PrinterDuplex = PrinterDuplex.Simplex;

    System.Drawing.Printing.PageSettings pageSettings = new System.Drawing.Printing.PageSettings(printerSettings);
   
    ////not required . CR setting simplex works
    //System.Drawing.Printing.Duplex myDup = new Duplex();
    //myDup = Duplex.Simplex;
    //printerSettings.Duplex = myDup;

    // XPS printer only allows 1 copy
    //pDoc.PrinterSettings.Copies = 2;

    rpt.PrintToPrinter(printerSettings, pSettings, false, PrintLayout);
}

Cause

The issue has been identified and logged under Problem Report ID ADAPT01629225

Resolution

This issue has now been resolved in Service Pack 5

Keywords

Simplex, CR for VS 2010, Crystal Reports developer for Visual Studio , KBA , BI-DEV-NET , BI Software Development Kits (SDKs) - .NET or Other , Problem

Product

SAP Crystal Reports, developer version for Microsoft Visual Studio