Support Center

How to specify the printer used when printing with ImageMan.Net

Last Updated: May 09, 2013 09:45AM EDT
ImageMan.Net uses the standard .Net printing model using the PrintDocument object to print images. The PrintDocument by default prints to the Windows Default printer.

To programmatically specify a printer using code you need to set the PrinterDocument's  .PrinterSettings.PrinterName property to the name of the printer to use before printing like this:

                pd.PrinterSettings.PrinterName = "HP Laserjet 5";
 

You can also use the .Net PrinterDialog control to display the standard Windows printer selection dialog. To do that, create the PrinterDialog control and then call the ShowDialog() method. If that method returns DialogResult.OK then you can set the PrinterDocument.PrinterSettings property to the PrinterDialog's PrinterSettings property like this:
 
            PrintDocument pd = new PrintDocument();
 
            if( printDialog1.ShowDialog() == System.Windows.Forms.DialogResult.OK ) {
 
                // save current page viewed
                int currentPage = viewer1.Images.CurrentImageIndex;
                viewer1.Images.MoveFirst();
 
                pd.PrinterSettings = printDialog1.PrinterSettings;  // Update the PrinterSettings from the user selected values
 
                pd.PrintPage += new PrintPageEventHandler(pd_PrintScaledPage);

 

Contact Us