0

I am automatically printing an SSRS report after users perform an action and it works great. However, I would like it to print 2 sided. Is this possible? I can't find anything online or in the documentation of the SRSPrintDestinationSettings class

private static client void runOnClient(ProdId _prodId)
{
    controllerEx  reportRunController;
    DCExmaple   parmData;
    Args            args = new Args();
    //get users default printer from User options
    LM_PrinterName printerName = SysUserInfo::find().lm_PrinterName;

    // Create the report run controller
        reportRunController = new controllerEx();
        reportRunController.parmReportName(ssrsReportStr(CMA_Traveller, CHTravellerReportEnhanced));
        reportRunController.parmLoadFromSysLastValue(false);

        // Set printer settings (you can print to file, format, filename, etc).
        reportRunController.parmReportContract().parmPrintSettings().printMediumType(SRSPrintMediumType::Printer);
        reportRunController.parmReportContract().parmPrintSettings().printerName(printerName);

        //More settings to print 2 sided?

        args.record(ProdTable::find(_prodId));
        reportRunController.parmArgs(args);

        parmData = new DCExmaple();
        parmData.parmProdId(_prodId);

        //set the execution mode to Synchronous
        reportRunController.parmExecutionMode(SysOperationExecutionMode::Synchronous);

        reportRunController.parmReportContract().parmRdpContract(parmData);
        // Run the report
        reportRunController.run();
}
joel
  • 156
  • 6

1 Answers1

0

I don't know the exact answer to your question, but I can tell you a good way that you might be able to figure it out.

Create the below job and run it. Then choose the printer duplex settings and things exactly how you want it and then examine the two objects listed below and it should point you in the right direction.

Another option after you choose the settings you like, store the container c in a table somewhere as your "duplex settings", and then just load from the container in your above code.

Make sure to check the Override default settings box or you probably won't be able to configure anything.

static void JobPrinterSettings(Args _args)
{
    SRSPrintDestinationSettings         settings = new SRSPrintDestinationSettings();
    container                           c;
    XML                                 printerXML;

    if (SrsReportRunUtil::showSettingsDialog(settings))
    {
        // Examine this container
        c = settings.pack();

        // Examine this XML
        printerXML = SRSProxy::getDefaultPrinterPageSettingsForPrinter(settings.printerName());

        breakpoint;
    }

}

enter image description here

Alex Kwitny
  • 11,211
  • 2
  • 49
  • 71
  • This is brilliant, thank you. I need nail it down to tag in the printSettings xml, so I think I just need to figure out how to edit that xml output and take it from there. – joel May 09 '19 at 20:26
  • Yup I think so too. The method `\Classes\SRSPrintDestinationSettings\getPrinterPageSettingsValue` and `setPrinterPageSettingsValue` may give you exactly what you need and look at `\Classes\SRSPrintDestinationSettings\getPaperTray` too – Alex Kwitny May 09 '19 at 22:49
  • One thing to note, which you may have already figured out, is the `printerXML` variable in my job just contains the default printer settings, which may not match the settings that are stored in the `settings` variable. This is because the `settings` variable obviously has whatever things you may have tweaked from the default using the pop-up form. – Alex Kwitny May 09 '19 at 22:52