Home > database >  How to set input paper printer in c#
How to set input paper printer in c#

Time:07-21

hi i want print a paper but i want choose a custom input paper in c# i write this code:

PrintDocument pd = new PrintDocument();
                    pd.PrinterSettings.PrinterName = domainUpDown1.SelectedItem.ToString();
                    
                    int i = 1;

                    foreach (int x in consent)
                    {

                        pd.PrintPage  = new PrintPageEventHandler(this.pd_PrintPage);
                        pd.PrinterSettings.Copies = Convert.ToInt16(x);
                        pd.DefaultPageSettings.PaperSource = PaperSourceKind.Upper;
                       // MessageBox.Show(pd.DefaultPageSettings.PaperSource.ToString());
                        if (x != 0)
                        {
                            pd.Print();
                        }
                        i  ;
                    }

but

``` 
pd.DefaultPageSettings.PaperSource = PaperSourceKind.Upper;
```

this have error please help ?

CodePudding user response:

The reason you're getting an error is because you are trying to assign PaperSourceKind.Upper (which is an enum of type PaperSourceKind) to pd.DefaultPageSettings.PaperSource (which is a class of type PaperSource).

Instead, try

pd.DefaultPageSettings.PaperSource = new PaperSource() { RawKind = (int)PaperSourceKind.Upper };
  • Related