C # controls the printer by a different tray / paper feed print paper feed port

Normally we are operating the printer to print through the program we set up good content, but the basic are the default printer paper imports printing; recently had a C # program control two feed ports, respectively, into a piece of paper for printing needs through, through loss compensation to find a solution as follows:

About C # method calls the printer to print, on-line a lot of relevant information, will not be discussed here only describes how to control the printing paper through a different paper tray

 PrintDocument pdDocument = new PrintDocument();
/*
** some basic settings for printing, do not make much introduction
*/

Setting the paper source, such as I set here by the paper input tray 1, note the different names of different types of printer tray

 pdDocument.DefaultPageSettings.PaperSource = GetPaperSource("纸盒 1");

To find the source of the following paper tray by the name of the method

         ///  <Summary> 
        /// Find tray by name
         ///  </ Summary> 
        ///  <param name = "sorceName"> </ param> 
        ///  <Returns> </ Returns> 
        Private PaperSource GetPaperSource ( String sorceName)
        {
            PaperSource pageSorce = new PaperSource();
            PrinterSettings ps = new PrinterSettings();
            for (int i = 0; i < ps.PaperSources.Count; i++)
            {
                if (ps.PaperSources[i].SourceName == sorceName)
                {
                    return ps.PaperSources[i];
                }
            }
            return null;
        }

After completion of the above tray can be called print settings, if you want to enter different each printing paper tray, and then repeated call set the paper source to the printing;

Guess you like

Origin www.cnblogs.com/yx007/p/11926066.html
Recommended