• <small id='CtHFa'></small><noframes id='CtHFa'>

      <tfoot id='CtHFa'></tfoot>
      1. <i id='CtHFa'><tr id='CtHFa'><dt id='CtHFa'><q id='CtHFa'><span id='CtHFa'><b id='CtHFa'><form id='CtHFa'><ins id='CtHFa'></ins><ul id='CtHFa'></ul><sub id='CtHFa'></sub></form><legend id='CtHFa'></legend><bdo id='CtHFa'><pre id='CtHFa'><center id='CtHFa'></center></pre></bdo></b><th id='CtHFa'></th></span></q></dt></tr></i><div id='CtHFa'><tfoot id='CtHFa'></tfoot><dl id='CtHFa'><fieldset id='CtHFa'></fieldset></dl></div>
      2. <legend id='CtHFa'><style id='CtHFa'><dir id='CtHFa'><q id='CtHFa'></q></dir></style></legend>
          <bdo id='CtHFa'></bdo><ul id='CtHFa'></ul>

        更改打印机默认纸张大小

        Change printer default paper size(更改打印机默认纸张大小)
      3. <legend id='0Qqof'><style id='0Qqof'><dir id='0Qqof'><q id='0Qqof'></q></dir></style></legend>
        <i id='0Qqof'><tr id='0Qqof'><dt id='0Qqof'><q id='0Qqof'><span id='0Qqof'><b id='0Qqof'><form id='0Qqof'><ins id='0Qqof'></ins><ul id='0Qqof'></ul><sub id='0Qqof'></sub></form><legend id='0Qqof'></legend><bdo id='0Qqof'><pre id='0Qqof'><center id='0Qqof'></center></pre></bdo></b><th id='0Qqof'></th></span></q></dt></tr></i><div id='0Qqof'><tfoot id='0Qqof'></tfoot><dl id='0Qqof'><fieldset id='0Qqof'></fieldset></dl></div>

        <tfoot id='0Qqof'></tfoot>
          <tbody id='0Qqof'></tbody>

        <small id='0Qqof'></small><noframes id='0Qqof'>

          <bdo id='0Qqof'></bdo><ul id='0Qqof'></ul>

                  本文介绍了更改打印机默认纸张大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我在打印机上定义了几种自定义纸张尺寸(打印机设置为默认值).我需要能够选择其中一种格式作为默认格式.

                  I have several custom paper sizes defined on a printer(the printer is set as default). I need to be able to select one of these formats as the default one.

                  编程(C#)解决方案是理想的,但命令行解决方案也可以.

                  A programmatic(C#) solution would be ideal, but a command line one would be ok too.

                  现在,我可以获取打印机上定义的纸张尺寸(名称/尺寸)列表,并且可以找出哪个是默认值.

                  Right now, I am able to get the list of paper sizes(name/dimensions) defined on the printer, and I can find out which one is the default.

                  为了选择另一种格式作为默认格式,我目前唯一的解决方案是更改 devMode 结构上的 dmPaperSize 字段;但是我找不到与所需纸张格式相对应的正确值.所以我将 dmPaperSize 设置为 0,并增加它,直到正确的格式出现在打印机上.这在某些打印机上需要很长时间.

                  In order to select another format as default, the only solution I have so far is by changing the dmPaperSize field on the devMode structure; BUT I cannot find out the correct value that corresponds to the desired paper format. So I set dmPaperSize to 0, and increment it, until the correct format appears on the printer. This takes a very long time on some printers.

                  是否有另一种方法来选择(按名称)默认打印机上的默认纸张格式?

                  Is there another way to select(by name) the default papaer format on the default printer ?

                  推荐答案

                  更改默认打印机设置的方向是正确的..NET 不直接支持更改打印机的默认设置.

                  You are in the right direction in changing the default printer settings. .NET doesn't provide direct support to change the default settings of a printer.

                  我使用了 thisPrinterSettings 类> codeproject 文章更改打印机设置.

                  I used the PrinterSettings class from this codeproject article to change the printer settings.

                  可以使用 PrintDocument.PrinterSettings 检索打印机中可用的纸张尺寸.请参阅下面的示例代码以从打印机中检索可用的纸张尺寸并使用 PaperSize.RawKind 更改打印机的纸张尺寸.

                  The available paper sizes from the printer can be retrieved using the PrintDocument.PrinterSettings. See the sample code below for retrieving the available papersizes from the printer and using the PaperSize.RawKind for changing the papersize of the printer.

                  public class PrinterSettingsDlg : Form
                  {
                      PrinterSettings ps = new PrinterSettings();
                      Button button1 = new Button();
                      ComboBox combobox1 = new ComboBox();
                      public PrinterSettingsDlg()
                      {
                          this.Load += new EventHandler(PrinterSettingsDlg_Load);
                          this.Controls.Add(button1);
                          this.Controls.Add(combobox1);
                          button1.Dock = DockStyle.Bottom;
                          button1.Text = "Change Printer Settings";
                          button1.Click += new EventHandler(button1_Click);
                          combobox1.Dock = DockStyle.Top;
                      }
                  
                      void button1_Click(object sender, EventArgs e)
                      {
                          PrinterData pd = ps.GetPrinterSettings(PrinterName);
                          pd.Size = ((PaperSize)combobox1.SelectedItem).RawKind;
                          ps.ChangePrinterSetting(PrinterName, pd);
                      }
                  
                      void PrinterSettingsDlg_Load(object sender, EventArgs e)
                      {
                          PrintDocument pd = new PrintDocument();
                          pd.PrinterSettings.PrinterName = // printer name
                          combobox1.DisplayMember = "PaperName";
                          foreach (PaperSize item in pd.PrinterSettings.PaperSizes)
                          {
                              combobox1.Items.Add(item);
                          }            
                      }
                  }
                  

                  这篇关于更改打印机默认纸张大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  Multicast delegate weird behavior in C#?(C# 中的多播委托奇怪行为?)
                  Parameter count mismatch with Invoke?(参数计数与调用不匹配?)
                  How to store delegates in a List(如何将代表存储在列表中)
                  How delegates work (in the background)?(代表如何工作(在后台)?)
                  C# Asynchronous call without EndInvoke?(没有 EndInvoke 的 C# 异步调用?)
                  Delegate.CreateDelegate() and generics: Error binding to target method(Delegate.CreateDelegate() 和泛型:错误绑定到目标方法)

                      • <tfoot id='bOvla'></tfoot>
                      • <legend id='bOvla'><style id='bOvla'><dir id='bOvla'><q id='bOvla'></q></dir></style></legend>

                        <small id='bOvla'></small><noframes id='bOvla'>

                          <i id='bOvla'><tr id='bOvla'><dt id='bOvla'><q id='bOvla'><span id='bOvla'><b id='bOvla'><form id='bOvla'><ins id='bOvla'></ins><ul id='bOvla'></ul><sub id='bOvla'></sub></form><legend id='bOvla'></legend><bdo id='bOvla'><pre id='bOvla'><center id='bOvla'></center></pre></bdo></b><th id='bOvla'></th></span></q></dt></tr></i><div id='bOvla'><tfoot id='bOvla'></tfoot><dl id='bOvla'><fieldset id='bOvla'></fieldset></dl></div>

                            <tbody id='bOvla'></tbody>
                            <bdo id='bOvla'></bdo><ul id='bOvla'></ul>