zoukankan      html  css  js  c++  java
  • VB.Net实现打印机纸张类型自动更换的方法

    VB.Net实现打印机纸张类型自动更换的方法
    Dim   ps   As   New   PageSettings   
    Dim   pDocument   as   new   PrintDocument   
    Dim   myPaperSize   As   System.Drawing.Printing.PaperSize   
        
      If     ps.PrinterSettings.InstalledPrinters.Count   >   0   Then       '检测打印机是否存在   
              If   ps.PrinterSettings.IsValid   =   True   Then                           '检测打印机是否有效     
                    For   Each   myPaperSize   In   ps.PrinterSettings.PaperSizes     '检查该当前打印机是否支持A3的纸张   
                            If   myPaperSize.Kind   =   PaperKind.A3   Then   
                                  Exit   For   
                            End   If   
                    next   
                    If   myPaperSize.Kind   <>   PaperKind.A3   Then         '如果当前打印机不支持A3纸张,那么自定义A3大小的纸张   
                          myPaperSize   =   New   System.Drawing.Printing.PaperSize("A3",   1169,   1654)   
                    End   If   
                    ps.PaperSize   =   myPaperSize         '设置为指定的纸张   
                    ps.Landscape   =   False   
                    pDocument.DefaultPageSettings   =   ps   
                    pDocument.PrinterSettings.PrinterName   =   ps.PrinterSettings.PrinterName   
              End   If   

      End   If

     =====================================================================================================================================

    using System.Drawing.Printing.PrintDocument

    using System.Drawing.Printing.PrinterSettings.PaperSizeCollection

    using System.Drawing.Printing.PaperSize

    using System.Drawing.Printing.PageSettings

    /////////需要以上引用

    PrintDocument pd = new PrintDocument();
    PaperSize p=null;
    foreach(PaperSize ps in pd.PrinterSettings.PaperSizes)
    {   if(ps.PaperName.Equals("A3"))
      p = ps;

    pd.DefaultPageSettings.PaperSize = p;

    pd.Print(); 

  • 相关阅读:
    yum只下载不安装的方法
    在VS2008下编译Qt4.4.x
    Linux sh脚本异常:bad interpreter: No such file or directory
    动态链接库dll,静态链接库lib, 导入库lib 转
    Accumulation Buffer(累积缓存)
    mysql中ip和整数的转换
    开车撞人了!
    windows 下getc()返回0x1A表示EOF
    NPC问题
    关于普华永道、麦肯锡和IBM的笑话
  • 原文地址:https://www.cnblogs.com/xiaoL/p/1912597.html
Copyright © 2011-2022 走看看