PrintDocument.DefaultPageSettings 속성

정의

인쇄할 모든 페이지에 대해 기본값으로 사용되는 페이지 설정을 가져오거나 설정합니다.

public:
 property System::Drawing::Printing::PageSettings ^ DefaultPageSettings { System::Drawing::Printing::PageSettings ^ get(); void set(System::Drawing::Printing::PageSettings ^ value); };
[System.ComponentModel.Browsable(false)]
public System.Drawing.Printing.PageSettings DefaultPageSettings { get; set; }
[<System.ComponentModel.Browsable(false)>]
member this.DefaultPageSettings : System.Drawing.Printing.PageSettings with get, set
Public Property DefaultPageSettings As PageSettings

속성 값

문서의 기본 페이지 설정을 지정하는 PageSettings입니다.

특성

예제

다음 코드 예제에서는 문서의 페이지 방향을 가로로 설정하고 문서를 인쇄합니다. 이 예제에서는 라는 filePath 변수가 인쇄할 파일의 경로로 설정되어 있고, 이벤트를 처리하는 PrintPage 라는 pd_PrintPage메서드가 정의되었으며, 라는 printer 변수가 프린터 이름으로 설정되었다고 가정합니다.

이 예제에서는 System.Drawing, System.Drawing.PrintingSystem.IO 네임스페이스를 사용합니다.

public:
   void Printing()
   {
      try
      {
         streamToPrint = gcnew StreamReader( filePath );
         try
         {
            printFont = gcnew System::Drawing::Font( "Arial",10 );
            PrintDocument^ pd = gcnew PrintDocument;
            pd->PrintPage += gcnew PrintPageEventHandler(
               this, &Form1::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 );
      }
   }
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);
   }
}
Public Sub Printing()
    Try
        streamToPrint = New StreamReader(filePath)
        Try
            printFont = New Font("Arial", 10)
            Dim pd As New PrintDocument()
            AddHandler pd.PrintPage, AddressOf pd_PrintPage
            pd.PrinterSettings.PrinterName = printer
            ' Set the page orientation to landscape.
            pd.DefaultPageSettings.Landscape = True
            pd.Print()
        Finally
            streamToPrint.Close()
        End Try
    Catch ex As Exception
        MessageBox.Show(ex.Message)
    End Try
End Sub

설명

속성을 통해 DefaultPageSettings 몇 가지 기본 페이지 설정을 지정할 수 있습니다. 예를 들어 속성은 PageSettings.Color 페이지가 색으로 인쇄되는지 여부를 지정하고, 속성은 PageSettings.Landscape 가로 또는 세로 방향을 지정하고 PageSettings.Margins , 속성은 페이지의 여백을 지정합니다.

페이지 단위로 설정을 지정하려면 또는 이벤트를 처리 PrintPage 하고 또는 QueryPageSettingsEventArgsQueryPageSettings 에 포함된 인수를 PrintPageEventArgs 각각 수정 PageSettings 합니다.

참고

인쇄가 시작되면 속성을 통해 DefaultPageSettings 페이지 설정을 변경해도 인쇄되는 페이지에는 영향을 미치지 않습니다.

적용 대상

추가 정보