PrinterSettings 클래스
정의
중요
일부 정보는 릴리스되기 전에 상당 부분 수정될 수 있는 시험판 제품과 관련이 있습니다. Microsoft는 여기에 제공된 정보에 대해 어떠한 명시적이거나 묵시적인 보증도 하지 않습니다.
Windows Forms 응용 프로그램에서 인쇄할 때 인쇄하는 프린터를 포함하여 문서를 인쇄하는 방법에 대한 정보를 지정합니다.
public ref class PrinterSettings : ICloneable
[System.Runtime.InteropServices.ComVisible(false)]
[System.Serializable]
public class PrinterSettings : ICloneable
[System.Serializable]
public class PrinterSettings : 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.Printing및 System.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을 참조 하세요.
생성자
| Name | Description |
|---|---|
| PrinterSettings() |
PrinterSettings 클래스의 새 인스턴스를 초기화합니다. |
속성
| Name | Description |
|---|---|
| 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 |
인쇄할 마지막 페이지의 번호를 가져오거나 설정합니다. |
메서드
| Name | Description |
|---|---|
| Clone() |
이 PrinterSettings복사본을 만듭니다. |
| CreateMeasurementGraphics() |
를 Graphics 만들 때 유용한 프린터 정보가 들어 있는 값을 반환합니다 PrintDocument. |
| CreateMeasurementGraphics(Boolean) |
Graphics 필요에 따라 여백에서 원본을 지정하여 프린터 정보를 포함하는 값을 반환합니다. |
| CreateMeasurementGraphics(PageSettings, Boolean) |
지정한 Graphics 페이지 설정과 연결되고 선택적으로 여백에 원점 지정을 만듭니다. |
| CreateMeasurementGraphics(PageSettings) |
Graphics 지정된 프린터 정보와 연결된 프린터 정보를 포함하는 값을 반환합니다PageSettings. |
| Equals(Object) |
지정한 개체와 현재 개체가 같은지 여부를 확인합니다. (다음에서 상속됨 Object) |
| GetHashCode() |
기본 해시 함수로 작동합니다. (다음에서 상속됨 Object) |
| GetHdevmode() |
프린터 설정에 |
| GetHdevmode(PageSettings) |
매개 변수를 |
| GetHdevnames() |
프린터 설정에 |
| GetType() |
현재 인스턴스의 Type 가져옵니다. (다음에서 상속됨 Object) |
| IsDirectPrintingSupported(Image) |
프린터에서 지정된 이미지 파일의 인쇄를 지원하는지 여부를 나타내는 값을 가져옵니다. |
| IsDirectPrintingSupported(ImageFormat) |
프린터에서 지정한 이미지 형식의 인쇄를 지원하는지 여부를 나타내는 값을 반환합니다. |
| MemberwiseClone() |
현재 Object단순 복사본을 만듭니다. (다음에서 상속됨 Object) |
| SetHdevmode(IntPtr) |
지정된 핸들에서 관련 정보를 복사하여 .에 복사합니다 PrinterSettings. |
| SetHdevnames(IntPtr) |
지정된 핸들에서 관련 정보를 복사하여 .에 복사합니다 PrinterSettings. |
| ToString() |
문자열 형식에 PrinterSettings 대한 정보를 제공합니다. |