Issues with multi-tray printers

Posted by: dinman on 25 April 2018, 5:25 pm EST

    • Post Options:
    • Link

    Posted 25 April 2018, 5:25 pm EST

    I have a multi-tray printer that has two profiles/printers configured, each profile/printer points to a different tray. The following is how i am assigning the printer to my report.

        
    Private Sub btnPrintDefaultTestReport_Click(sender As Object, e As EventArgs) Handles btnPrintDefaultTestReport.Click
            rpt.Run()
    
            Dim Printer As New PrinterSettings
            Printer.PrinterName = cmbPrinters.SelectedItem.ToString
    
            rpt.Document.Printer.PrinterSettings = Printer
    
            GrapeCity.ActiveReports.PrintExtension.Print(rpt.Document, False, False)
        End Sub
    
    

    cmbPrinters is a combo box of installed printer’s name

    I select my printer that is pointing to tray 2 in the combo box and press print

    “Currently this printer is not my default printer” and it prints my section report out of Tray 1.

    Now if i choose the printer that is pointed to tray 2 and make it my default printer and choose that printer from my combo box it prints to tray 2 perfectly fine.

    I was wondering if anyone knew how to get a non default printer to print to tray 2?

    note: i have tried to manually assign the papersource tray 2 to this report and if the printer that i choose is not the default printer then it will still print it to tray 1

    Also, this issue seems to happen with orientation as well. If the printer you are using to print a section report is not the default printer than my report always prints portrait even if the actual printer setting on the printer is set to landscape.

    The color/greyscale settings and scaling settings work fine whether you use the default printer or not

    Tested this on Windows 7 and Windows 10

    Active Reports 11 is what i am using

    Visual Studio 2017 and is my IDE

  • Posted 27 April 2018, 5:09 am EST

    Hello,

    You need to set “Orientation” and “PaperSource” of the printer in your code. Please add the following line of code in your method:

    
    
    Private Sub btnPrintDefaultTestReport_Click(sender As Object, e As EventArgs) Handles btnPrintDefaultTestReport.Click
            rpt.Run()
    
            Dim Printer As New PrinterSettings
            Printer.PrinterName = cmbPrinters.SelectedItem.ToString
    
            rpt.Document.Printer.PrinterSettings = Printer
            rpt.Document.Printer.DefaultPageSettings.Landscape = True
    // Please change according to your printer
            rpt.Document.Printer.DefaultPageSettings.PaperSource = sectionReport.Document.Printer.PrinterSettings.PaperSources.Item(2) 
            GrapeCity.ActiveReports.PrintExtension.Print(rpt.Document, False, False)
        End Sub
    
    

    Also, please refer the attached sample.

    Hope it helps.

    Thanks,

    Mohit

    prj_PrinterName.zip

  • Posted 27 April 2018, 8:52 am EST

    Thank you for the reply mohitg! I have attempted the code source you posted and it seems the only way i can actually get the printer to print correctly is if i assign the report a empty string paper name first.

    
    	rpt.Document.Printer.PrinterSettings.PrinterName = ""
            Dim Printer As New PrinterSettings
            Printer.PrinterName = cmbPrinters.SelectedItem.ToString
    
            rpt.Document.Printer.PrinterSettings = Printer
    
    

    If i do the above first it seems it prints to paper tray 2 just fine.

    What would cause the empty string printer name to allow it to work properly

  • Posted 30 April 2018, 2:37 am EST

    Hello,

    Empty string printer name prevents ActiveReports from making a call to the default printer driver. That’s why it is necessary to set PrinterName blank to print on non-default printer.

    Hope it clarifies.

    Thanks,

    Mohit

  • Posted 30 April 2018, 8:44 am EST

    Thank you Mohitg, that seems to fix my issue!

Need extra support?

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

Learn More

Forum Channels