Printer Settings

Posted by: paulywally on 3 August 2017, 3:20 pm EST

  • Posted 3 August 2017, 3:20 pm EST

    Hi,



    How do I assign the printer settings to a report in the viewer when printing? Basically, they want to have a different default printer for reports of certain types.



    Thanks,

    Pauly
  • Replied 3 August 2017, 3:20 pm EST

    Yes, I understand that. I just want it to default to something else. Is that possible programmatically?



    Thanks,

    Pauly
  • Replied 3 August 2017, 3:20 pm EST

    For instance, if I print programmatically, I can set the printer settings. How can I do that with the viewer?



    NameValueCollection settings = ((IConfigurable)_renderer).GetSupportedSettings().GetSettings();



    if (_printerSettings == null)

    {

    System.Windows.Forms.PrintDialog printDialog = new System.Windows.Forms.PrintDialog();

    if (printDialog.ShowDialog() != System.Windows.Forms.DialogResult.OK)

    return;



    _printerSettings = printDialog.PrinterSettings;

    }



    settings["PrinterName"] = _printerSettings.PrinterName;



    _reportRuntime.Render(_renderer, null, settings);



    _renderer.Document.PrinterSettings = _printerSettings;
  • Replied 3 August 2017, 3:20 pm EST

    Hello,

    Unfortunately, I am still not able to understand your requirement, could you please elaborate it further. Do you want to reset the default printer to a different printer in the print dialog, when the user clicks on the print button. Please let me know what exactly are you looking for, so that I can guide you ahead in the same direction.

    Thanks,
    Manpreet Kaur
  • Replied 3 August 2017, 3:20 pm EST

    Yes.



    We have our own tool bar with our own print button as well, so I was hoping it was easy to change the default printer based on the report type (like a label).



    It is a time saver that some of our users have been asking for.
  • Replied 3 August 2017, 3:20 pm EST

    Hello,

    You can customize the printer settings using the following piece of code:

                     using DataDynamics.Reports;
                     using DataDynamics.Reports.Rendering.Graphics;


                    FileInfo fileInfo = new FileInfo(Application.StartupPath + @"\..\..\Report1.rdlx");
                    ReportDefinition reportDef = new ReportDefinition(fileInfo);
                    ReportRuntime runtime = new ReportRuntime(reportDef);


                    PrintDocumentRenderingExtension renderer = new PrintDocumentRenderingExtension();
                    NameValueCollection settings = renderer.GetSupportedSettings().GetSettings();

                    // render the report using the print renderer

                    runtime.Render(renderer, null, settings);

                    // configure the PrintDocument before printing
                    PrintDocument printDocument = renderer.Document;
                    printDocument.PrinterSettings.PrinterName = "Microsoft XPS Document Writer";


                    // set the print controller
                    printDocument.PrintController = new StandardPrintController();
                    printDocument.Print();

    You can add this code to your print button to change the default printer depending on which report is to be printed.

    Thanks,
    Manpreet Kaur
     
  • Replied 3 August 2017, 3:20 pm EST

    Hello,

    When you preview the report in the viewer, the toolbar displayed at the top has a print button. Clicking on the print button displays the Print Dialog, which would enable you to select a different printer for each report. You can select the printer you need from this dialog. Hope it will help you. Please let me know if you are looking for something else.

    Thanks,
    Manpreet Kaur
Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels