c# - Change printer default paper size -
Many custom paper sizes are set on my printer (printer is set as default) Should be able to choose in the form.
A programmatic (C #) solution would be ideal, but one command line would also be fine.
Right now, I'm able to get a list of the paper size (name / dimension) defined on the printer and I can know which is the default
as the default one To select another format, the only solution to date is by changing the dmPaperSize field to devMode structure; But I match the desired letter format which is not getting the right value. That's why I set dmPaperSize to 0, and extended it, as long as the printer is not the correct format. It takes a lot of time on some printers. Is there any other way to select the default name on the default printer? You are in the right direction to change the default printer settings. .NET does not provide direct support for changing the default settings of a printer. I used the The size of the paper available from the printer can be recovered by using PrinterSettings class from the codeproject article to change printer settings.
PrintDocument.PrinterSettings . To get the paper letter available from the printer, look at the sample code below and try using
PaperSize.RawKind to change the printer's papers.
Public class printer settings DLL: form {PrinterSettings ps = new printer settings (); Button Button 1 = New Button (); Combobox combobox 1 = new combo box (); Public PrinterSettingsDlg () {this.Load + = New EventHeader (Printer Settings Dlg_Load); This.Controls.Add (Button1); This.Controls.Add (ComboBox1); Button 1 Doc = docstyle.bottom; Button1.Text = "Change printer settings"; Button 1 Click + = New Event Handler (button 1_Click); Cambodia 1 Doc = DocStyle. Tap; } Zero Button 1_Click (Object Sender, EventArgs E) {PrinterData PD = ps.GetPrinterSettings (PrinterName); Pd.Size = ((Paper Size) Combobox 1. Selected Etem. RAWKind; Ps.ChangePrinterSetting (PrinterName, pd); } Zero PrinterSettingsDlg_Load (Object Sender, EventArgs E) {PrintDocument PD = New Print Document (); Pd.PrinterSettings.PrinterName = // The name of the printer is combobox1.DisplayMember = "PaperName"; Foreign Currency (Paper Size Items in Paper Printer Settings. Paper Size) {Combo Box 1. ITEM Add (item); }}}
Comments
Post a Comment