當前位置: 首頁>>代碼示例>>C#>>正文


C# PrintDocument.DefaultPageSettings屬性代碼示例

本文整理匯總了C#中System.Drawing.Printing.PrintDocument.DefaultPageSettings屬性的典型用法代碼示例。如果您正苦於以下問題:C# PrintDocument.DefaultPageSettings屬性的具體用法?C# PrintDocument.DefaultPageSettings怎麽用?C# PrintDocument.DefaultPageSettings使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在System.Drawing.Printing.PrintDocument的用法示例。


在下文中一共展示了PrintDocument.DefaultPageSettings屬性的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: Printing

public void Printing()
{
   try
   {
      streamToPrint = new StreamReader (filePath);
      try
      {
         printFont = new Font("Arial", 10);
         PrintDocument pd = new PrintDocument(); 
         pd.PrintPage += new PrintPageEventHandler(pd_PrintPage);
         pd.PrinterSettings.PrinterName = printer;
         // Set the page orientation to landscape.
         pd.DefaultPageSettings.Landscape = true;
         pd.Print();
      } 
      finally
      {
         streamToPrint.Close() ;
      }
   } 
   catch(Exception ex)
   { 
      MessageBox.Show(ex.Message);
   }
}
開發者ID:.NET開發者,項目名稱:System.Drawing.Printing,代碼行數:25,代碼來源:PrintDocument.DefaultPageSettings

示例2: Main

//引入命名空間
using System;
using System.Drawing.Printing;

namespace DefPrintSettings_c
{
    public class DefPrintSettings
    {
        [STAThread]
        static void Main(string[] args)
        {
      PrintDocument pd = new PrintDocument();
      PageSettings pg = pd.DefaultPageSettings;
      PrinterSettings ps = pg.PrinterSettings;

      Console.WriteLine("Printer Settings");
      Console.WriteLine("PrinterName = " + pd.PrinterSettings.PrinterName);
      Console.WriteLine("Is default Printer = " +
                         ps.IsDefaultPrinter.ToString());
      Console.WriteLine("Is plotter = " + ps.IsPlotter.ToString());
      Console.WriteLine("Is printer valid = " + ps.IsValid.ToString());
      Console.WriteLine("Can Duplex = " + ps.IsValid.ToString());
      Console.WriteLine("Num copies = " + ps.Copies.ToString());
      Console.WriteLine("Max Copies = " + ps.MaximumCopies.ToString());
      Console.WriteLine("Max Page = " + ps.MaximumPage.ToString());
      Console.WriteLine("Min Page = " + ps.MinimumPage.ToString());
      Console.WriteLine("Supports Color = " + ps.SupportsColor.ToString());
      foreach (PaperSize p in ps.PaperSizes)
        Console.WriteLine("Supports Paper Size: " + p.PaperName);
      foreach (PaperSource p in ps.PaperSources)
        Console.WriteLine("Supports Paper Source: " + p.SourceName);

      Console.WriteLine("\nPage Settings");
      Console.WriteLine("Is Color = " + pg.Color.ToString());
      Console.WriteLine("Top Bound = " + pg.Bounds.Top.ToString());
      Console.WriteLine("Bottom Bound = " + pg.Bounds.Bottom.ToString());
      Console.WriteLine("Left Bound = " + pg.Bounds.Left.ToString());
      Console.WriteLine("Right Bound = " + pg.Bounds.Right.ToString());
      Console.WriteLine("Top Margin = " + pg.Margins.Top.ToString());
      Console.WriteLine("Bottom Margin = " + pg.Margins.Bottom.ToString());
      Console.WriteLine("Left Margin = " + pg.Margins.Left.ToString());
      Console.WriteLine("Right Margin = " + pg.Margins.Right.ToString());
      Console.WriteLine("Landscape = " + pg.Landscape.ToString());
      Console.WriteLine("PaperSize = " + pg.PaperSize.PaperName);
      Console.WriteLine("PaperSource = " + pg.PaperSource.SourceName);
      Console.WriteLine("PrinterResolution = " + 
                        pg.PrinterResolution.Kind.ToString());
      Console.WriteLine("PrinterResolution X = " + 
                        pg.PrinterResolution.X.ToString());
      Console.WriteLine("PrinterResolution Y = " + 
                        pg.PrinterResolution.Y.ToString());

      Console.ReadLine();

    }
    }
}
開發者ID:C#程序員,項目名稱:System.Drawing.Printing,代碼行數:57,代碼來源:PrintDocument.DefaultPageSettings


注:本文中的System.Drawing.Printing.PrintDocument.DefaultPageSettings屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。