PrinterSettings 클래스

정의

Windows Forms 애플리케이션에서 인쇄할 때 인쇄할 프린터 등 문서 인쇄 방법에 대한 정보를 지정합니다.

public ref class PrinterSettings : ICloneable
public class PrinterSettings : ICloneable
[System.Runtime.InteropServices.ComVisible(false)]
[System.Serializable]
public class PrinterSettings : ICloneable
[System.Serializable]
public class PrinterSettings : ICloneable
type PrinterSettings = class
    interface ICloneable
[<System.Runtime.InteropServices.ComVisible(false)>]
[<System.Serializable>]
type PrinterSettings = class
    interface ICloneable
[<System.Serializable>]
type PrinterSettings = class
    interface ICloneable
Public Class PrinterSettings
Implements ICloneable
상속
PrinterSettings
특성
구현

예제

다음 코드 예제에서는 지정한 프린터에 문서를 인쇄합니다. 이 예제에는 다음 세 가지 필수 구성 요소가 있습니다.

  • 라는 filePath 변수가 인쇄할 파일의 경로로 설정되었습니다.

  • 이벤트를 처리하는 라는 pd_PrintPage메서드가 PrintPage 정의되었습니다.

  • 라는 printer 변수가 프린터 이름으로 설정되었습니다.

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

public:
   void Printing( String^ printer )
   {
      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 );
            // Specify the printer to use.
            pd->PrinterSettings->PrinterName = printer;
            if ( pd->PrinterSettings->IsValid )
            {
               pd->Print();
            }
            else
            {
               MessageBox::Show( "Printer is invalid." );
            }
         }
         finally
         {
            streamToPrint->Close();
         }
      }
      catch ( Exception^ ex ) 
      {
         MessageBox::Show( ex->Message );
      }
   }
public void Printing(string printer) {
  try {
    streamToPrint = new StreamReader (filePath);
    try {
      printFont = new Font("Arial", 10);
      PrintDocument pd = new PrintDocument(); 
      pd.PrintPage += new PrintPageEventHandler(pd_PrintPage);
      // Specify the printer to use.
      pd.PrinterSettings.PrinterName = printer;

      if (pd.PrinterSettings.IsValid) {
         pd.Print();
      } 
      else {	
         MessageBox.Show("Printer is invalid.");
      }
    } 
    finally {
      streamToPrint.Close();
    }
  } 
  catch(Exception ex) {
    MessageBox.Show(ex.Message);
  }
}
Public Sub Printing(printer As String)
    Try
        streamToPrint = New StreamReader(filePath)
        Try
            printFont = New Font("Arial", 10)
            Dim pd As New PrintDocument()
            AddHandler pd.PrintPage, AddressOf pd_PrintPage
            ' Specify the printer to use.
            pd.PrinterSettings.PrinterName = printer

            If pd.PrinterSettings.IsValid then
               pd.Print()
            Else
               MessageBox.Show("Printer is invalid.")
            End If
        Finally
            streamToPrint.Close()
        End Try
    Catch ex As Exception
        MessageBox.Show(ex.Message)
    End Try
End Sub

설명

일반적으로 를 통해 PrintDocument.PrinterSettings 또는 PageSettings.PrinterSettings 속성에 PrinterSettings 액세스하여 프린터 설정을 수정합니다. 가장 일반적인 프린터 설정은 인쇄할 프린터를 지정하는 입니다 PrinterName.

Windows Forms를 사용 하 여 인쇄에 대 한 자세한 내용은 참조는 System.Drawing.Printing 네임 스페이스 개요. Windows Presentation Foundation 애플리케이션에서 인쇄 하려는 경우 참조는 System.Printing 네임 스페이스입니다.

참고

.NET 6 이상 버전에서는 이 형식을 포함하는 System.Drawing.Common 패키지가 Windows 운영 체제에서만 지원됩니다. 플랫폼 간 앱에서 이 형식을 사용하면 컴파일 시간 경고 및 런타임 예외가 발생합니다. 자세한 내용은 Windows에서만 지원되는 System.Drawing.Common을 참조하세요.

생성자

PrinterSettings()

PrinterSettings 클래스의 새 인스턴스를 초기화합니다.

속성

CanDuplex

프린터에서 양면 인쇄를 지원하는지 여부를 나타내는 값을 가져옵니다.

Collate

문서가 한 부씩 인쇄되는지 여부를 나타내는 값을 가져오거나 설정합니다.

Copies

인쇄할 문서의 매수를 가져오거나 설정합니다.

DefaultPageSettings

이 프린터의 기본 페이지 설정을 가져옵니다.

Duplex

양면 인쇄에 대한 프린터 설정을 가져오거나 설정합니다.

FromPage

인쇄할 첫 페이지의 페이지 번호를 가져오거나 설정합니다.

InstalledPrinters

컴퓨터에 설치된 모든 프린터의 이름을 가져옵니다.

IsDefaultPrinter

사용자가 명시적으로 PrinterName을 설정할 때를 제외하고 PrinterName 속성이 기본 프린터를 지정하는지 여부를 나타내는 값을 가져옵니다.

IsPlotter

프린터가 플로터인지 여부를 나타내는 값을 가져옵니다.

IsValid

PrinterName 속성이 올바른 프린터를 지정할지 여부를 나타내는 값을 가져옵니다.

LandscapeAngle

세로 방향이 가로 방향으로 회전되는 각도를 가져옵니다.

MaximumCopies

프린터에서 한 번에 인쇄할 수 있는 최대 매수를 가져옵니다.

MaximumPage

FromPage에서 선택할 수 있는 최대 ToPage 또는 PrintDialog를 가져오거나 설정합니다.

MinimumPage

FromPage에서 선택할 수 있는 최소 ToPage 또는 PrintDialog를 가져오거나 설정합니다.

PaperSizes

이 프린터에서 지원하는 용지 크기를 가져옵니다.

PaperSources

프린터에서 사용할 수 있는 용지 공급함을 가져옵니다.

PrinterName

사용할 프린터 이름을 가져오거나 설정합니다.

PrinterResolutions

이 프린터에서 지원하는 모든 해상도를 가져옵니다.

PrintFileName

파일로 인쇄하는 경우 파일 이름을 가져오거나 설정합니다.

PrintRange

인쇄되도록 지정한 페이지 번호를 가져오거나 설정합니다.

PrintToFile

인쇄 출력이 포트 대신 파일에 전달되는지 여부를 나타내는 값을 가져오거나 설정합니다.

SupportsColor

이 프린터에서 컬러 인쇄를 지원하는지 여부를 나타내는 값을 가져옵니다.

ToPage

인쇄할 마지막 페이지 번호를 가져오거나 설정합니다.

메서드

Clone()

PrinterSettings의 복사본을 만듭니다.

CreateMeasurementGraphics()

Graphics를 만들 때 유용한 프린터 정보를 포함하는 PrintDocument를 반환합니다.

CreateMeasurementGraphics(Boolean)

여백의 원점을 선택적으로 지정하여 프린터 정보를 포함하는 Graphics를 반환합니다.

CreateMeasurementGraphics(PageSettings)

지정된 Graphics와 연결된 프린터 정보를 포함하는 PageSettings를 반환합니다.

CreateMeasurementGraphics(PageSettings, Boolean)

지정된 페이지 설정과 연결된 Graphics를 만들고 여백의 원점을 선택적으로 지정합니다.

Equals(Object)

지정된 개체가 현재 개체와 같은지 확인합니다.

(다음에서 상속됨 Object)
GetHashCode()

기본 해시 함수로 작동합니다.

(다음에서 상속됨 Object)
GetHdevmode()

프린터 설정에 해당하는 DEVMODE 구조체에 대한 핸들을 만듭니다.

GetHdevmode(PageSettings)

pageSettings 매개 변수를 통해 지정된 프린터 및 페이지 설정에 해당하는 DEVMODE 구조체에 대한 핸들을 만듭니다.

GetHdevnames()

프린터 설정에 해당하는 DEVNAMES 구조체에 대한 핸들을 만듭니다.

GetType()

현재 인스턴스의 Type을 가져옵니다.

(다음에서 상속됨 Object)
IsDirectPrintingSupported(Image)

프린터에서 지정된 이미지 파일 인쇄를 지원하는지 여부를 나타내는 값을 가져옵니다.

IsDirectPrintingSupported(ImageFormat)

프린터에서 지정된 이미지 형식 인쇄를 지원하는지 여부를 나타내는 값을 반환합니다.

MemberwiseClone()

현재 Object의 단순 복사본을 만듭니다.

(다음에서 상속됨 Object)
SetHdevmode(IntPtr)

지정된 핸들에 있는 관련 정보를 PrinterSettings에 복사합니다.

SetHdevnames(IntPtr)

지정된 핸들에 있는 관련 정보를 PrinterSettings에 복사합니다.

ToString()

PrinterSettings에 대한 정보를 문자열 형식으로 제공합니다.

적용 대상

추가 정보