C#에서 인쇄를 위한 종이 방향 설정 방법
종이 방향은 문서를 세로(길이방향) 또는 가로(넓이방향) 모드로 인쇄할지를 제어합니다. 세로는 대부분의 편지, 청구서, 보고서에 적합합니다. 가로는 넓은 테이블, 스프레드시트, 대시보드, 프레젠테이션 슬라이드에 더 좋습니다. 프로그램적으로 방향을 설정하여 사용자의 기본 프린터 구성에 관계없이 일관된 출력을 보장합니다.
IronPrint는 PaperOrientation 속성을 PrintSettings 클래스에 노출합니다. 우리는 그것을 Portrait 또는 Landscape로 설정하고, 설정을 Printer.Print()에 전달하면, 문서가 지정된 레이아웃으로 인쇄됩니다.
- NuGet를 통해
IronPrint설치:Install-Package IronPrint - 파일에
using IronPrint;추가 PrintSettings객체 생성PaperOrientation를Portrait또는Landscape로 설정- 설정을
Printer.Print()또는Printer.ShowPrintDialog()에 전달
-
1IronPrint를 NuGet Package Manager로 설치하십시오
-
2다음 코드 조각을 복사하여 실행하세요.
using IronPrint; // Print a document in landscape orientation Printer.Print("report.pdf", new PrintSettings { PaperOrientation = PaperOrientation.Landscape });Imports IronPrint ' Print a document in landscape orientation Printer.Print("report.pdf", New PrintSettings With { .PaperOrientation = PaperOrientation.Landscape })Imports IronPrint ' Print a document in landscape orientation Printer.Print("report.pdf", New PrintSettings With { .PaperOrientation = PaperOrientation.Landscape }) -
3실제 운영 환경에서 테스트할 수 있도록 배포하세요.
오늘 프로젝트에서 IronPrint 사용을 시작해보세요 무료 체험
최소 워크플로우(5단계)
- IronPrint C# 인쇄 라이브러리 설치
PrintSettings객체 생성PaperOrientation을Portrait또는Landscape로 설정- 설정을
Printer.Print()에 전달 - 프로젝트를 실행하여 지정된 방향으로 인쇄
인쇄를 위해 종이 방향을 어떻게 설정합니까?
PaperOrientation 속성은 PrintSettings에서 세 가지 값을 수용합니다:
PaperOrientation.Portrait- 세로 레이아웃 (대부분의 프린터에서 기본값). 편지, 계약서, 청구서 같은 단일 열 문서에 가장 적합합니다.PaperOrientation.Landscape- 가로 레이아웃. 데이터 테이블, 간트 차트, 스프레드시트, 슬라이드 데크 같은 넓은 내용에 가장 적합합니다.PaperOrientation.Automatic- 프린터의 기본 설정을 따름.
우리는 PrintSettings 객체를 생성하고 원하는 방향을 지정한 후, 비교형 인쇄를 위해 Printer.Print()에 또는 대화형 인쇄를 위해 Printer.ShowPrintDialog()에 전달합니다.
using IronPrint;
// Configure portrait orientation
var portraitSettings = new PrintSettings
{
PaperOrientation = PaperOrientation.Portrait
};
// Print the invoice in portrait
Printer.Print("invoice.pdf", portraitSettings);
// Configure landscape orientation
var landscapeSettings = new PrintSettings
{
PaperOrientation = PaperOrientation.Landscape
};
// Print the dashboard in landscape
Printer.Print("quarterly-dashboard.pdf", landscapeSettings);using IronPrint;
// Configure portrait orientation
var portraitSettings = new PrintSettings
{
PaperOrientation = PaperOrientation.Portrait
};
// Print the invoice in portrait
Printer.Print("invoice.pdf", portraitSettings);
// Configure landscape orientation
var landscapeSettings = new PrintSettings
{
PaperOrientation = PaperOrientation.Landscape
};
// Print the dashboard in landscape
Printer.Print("quarterly-dashboard.pdf", landscapeSettings);Imports IronPrint
' Configure portrait orientation
Dim portraitSettings As New PrintSettings With {
.PaperOrientation = PaperOrientation.Portrait
}
' Print the invoice in portrait
Printer.Print("invoice.pdf", portraitSettings)
' Configure landscape orientation
Dim landscapeSettings As New PrintSettings With {
.PaperOrientation = PaperOrientation.Landscape
}
' Print the dashboard in landscape
Printer.Print("quarterly-dashboard.pdf", landscapeSettings)Imports IronPrint
' Configure portrait orientation
Dim portraitSettings As New PrintSettings With {
.PaperOrientation = PaperOrientation.Portrait
}
' Print the invoice in portrait
Printer.Print("invoice.pdf", portraitSettings)
' Configure landscape orientation
Dim landscapeSettings As New PrintSettings With {
.PaperOrientation = PaperOrientation.Landscape
}
' Print the dashboard in landscape
Printer.Print("quarterly-dashboard.pdf", landscapeSettings)기본 .NET System.Drawing.Printing 접근 방식에서는 방향이 DefaultPageSettings.Landscape = true라는 불리언으로 PrintDocument에 숨겨져 있으며, 이는 PrintPage 이벤트 처리, 그래픽 렌더링 및 수동 페이지 관리를 추가로 요구합니다. IronPrint는 설정 객체의 단일 속성으로 전체 파이프라인을 대체합니다.
다른 인쇄 설정과 방향을 어떻게 결합합니까?
방향은 전체 인쇄 레이아웃을 정의하기 위해 종이 크기, DPI 및 여백과 결합될 때 가장 유용합니다. PrintSettings 클래스는 이를 한 객체에서 모두 구성할 수 있게 합니다.
using IronPrint;
// Combine orientation with paper size, DPI, and margins
var settings = new PrintSettings
{
PaperOrientation = PaperOrientation.Landscape,
PaperSize = PaperSize.A4,
Dpi = 300,
NumberOfCopies = 1,
PaperMargins = new Margins(15, 15, 15, 15),
Grayscale = false
};
// Print the financial report
Printer.Print("financial-report.pdf", settings);using IronPrint;
// Combine orientation with paper size, DPI, and margins
var settings = new PrintSettings
{
PaperOrientation = PaperOrientation.Landscape,
PaperSize = PaperSize.A4,
Dpi = 300,
NumberOfCopies = 1,
PaperMargins = new Margins(15, 15, 15, 15),
Grayscale = false
};
// Print the financial report
Printer.Print("financial-report.pdf", settings);Imports IronPrint
' Combine orientation with paper size, DPI, and margins
Dim settings As New PrintSettings With {
.PaperOrientation = PaperOrientation.Landscape,
.PaperSize = PaperSize.A4,
.Dpi = 300,
.NumberOfCopies = 1,
.PaperMargins = New Margins(15, 15, 15, 15),
.Grayscale = False
}
' Print the financial report
Printer.Print("financial-report.pdf", settings)Imports IronPrint
' Combine orientation with paper size, DPI, and margins
Dim settings As New PrintSettings With {
.PaperOrientation = PaperOrientation.Landscape,
.PaperSize = PaperSize.A4,
.Dpi = 300,
.NumberOfCopies = 1,
.PaperMargins = New Margins(15, 15, 15, 15),
.Grayscale = False
}
' Print the financial report
Printer.Print("financial-report.pdf", settings)PaperSize 및 PaperOrientation의 협력으로 - A4 가로 방향으로 설정하면 297 × 210 mm 출력 영역이 제공되며, A4 세로 방향은 210 × 297 mm를 제공합니다. Dpi 속성은 출력 해상도를 제어하며 (비즈니스 문서의 표준은 300), PaperMargins 값은 밀리미터 단위입니다.
인쇄 대화 상자에서 사용자에게 방향 선택을 허용하는 방법은 무엇인가요?
PrintSettings를 Printer.ShowPrintDialog()에 전달하면 대화 상자가 미리 설정된 방향으로 열립니다. 사용자는 이를 수락하거나 인쇄 전에 세로 방향과 가로 방향을 전환할 수 있습니다.
using IronPrint;
// Pre-configure landscape orientation for the dialog
var settings = new PrintSettings
{
PaperOrientation = PaperOrientation.Landscape,
PaperSize = PaperSize.Letter
};
// Open the dialog with pre-selected orientation
Printer.ShowPrintDialog("wide-report.pdf", settings);using IronPrint;
// Pre-configure landscape orientation for the dialog
var settings = new PrintSettings
{
PaperOrientation = PaperOrientation.Landscape,
PaperSize = PaperSize.Letter
};
// Open the dialog with pre-selected orientation
Printer.ShowPrintDialog("wide-report.pdf", settings);Imports IronPrint
' Pre-configure landscape orientation for the dialog
Dim settings As New PrintSettings With {
.PaperOrientation = PaperOrientation.Landscape,
.PaperSize = PaperSize.Letter
}
' Open the dialog with pre-selected orientation
Printer.ShowPrintDialog("wide-report.pdf", settings)Imports IronPrint
' Pre-configure landscape orientation for the dialog
Dim settings As New PrintSettings With {
.PaperOrientation = PaperOrientation.Landscape,
.PaperSize = PaperSize.Letter
}
' Open the dialog with pre-selected orientation
Printer.ShowPrintDialog("wide-report.pdf", settings)비차단 UI 시나리오의 경우, 비동기 변형 Printer.ShowPrintDialogAsync()은 동일한 매개변수를 수용하며 대화 상자가 열려 있는 동안 애플리케이션을 반응형으로 유지합니다. 이는 특히 방향 설정에 유용한데, 사용자가 인쇄 작업에 착수하기 전에 세로 방향과 가로 방향에서 문서가 어떻게 보이는지 미리 보기 원하기 때문입니다. Print 문서 튜토리얼은 비활성 및 대화형 작업 흐름을 시작부터 끝까지 다룹니다.
다음 단계
용지 방향은 PrintSettings 객체에서 하나의 속성입니다 - PaperOrientation, Portrait, Landscape 또는 Automatic로 설정하고 이를 IronPrint 인쇄 메소드에 전달하십시오. 완전한 레이아웃 제어를 위해 PaperSize, Dpi, 및 PaperMargins과 결합하십시오.
모든 사용 가능한 속성에 대한 인쇄 설정 사용 방법, 전체 메소드 표면에 대한 프린터 클래스 API 참조, 또는 실행 가능한 코드 조각용 코드 예제 페이지를 탐색하십시오. IronPrint 튜토리얼은 전체 인쇄 수명을 안내하고, 변경 로그는 성능 향상을 포함한 최근 업데이트를 추적합니다.
라이브 프로젝트에서 방향 설정을 테스트하려면 무료 30일 체험을 시작하십시오. 준비가 되면, $999에서 시작되는 라이선스 옵션 보기를 확인하십시오.
자주 묻는 질문
C#에서 인쇄를 위해 용지 방향을 설정하는 방법은 무엇입니까?
IronPrint를 사용하여 C#에서 용지 방향을 설정하려면, PrintSettings 클래스의 PaperOrientation 속성을 사용하십시오. 수직 레이아웃의 경우 Portrait, 수평 레이아웃의 경우 Landscape로 설정할 수 있습니다. 이러한 설정을 Printer.Print()에 전달하여 문서가 지정된 방향으로 인쇄되도록 할 수 있습니다.
IronPrint에서 사용할 수 있는 용지 방향 옵션은 무엇입니까?
IronPrint는 세 가지 PaperOrientation 옵션을 제공합니다: Portrait, Landscape 및 Automatic. Portrait는 편지와 같은 수직 문서에 적합하고, Landscape는 스프레드시트와 같은 수평 콘텐츠에 이상적입니다. Automatic은 프린터의 기본 방향 설정에 따릅니다.
용지 방향과 함께 다른 인쇄 설정도 수정할 수 있습니까?
네, IronPrint는 용지 크기, DPI, 여백과 같은 다른 설정과 방향을 조합하여 동일한 PrintSettings 객체 내에서 구성할 수 있습니다. 이는 인쇄 레이아웃에 대해 완전한 제어를 보장합니다.
사용자가 인쇄 대화 상자를 통해 원하는 방향을 선택할 수 있습니까?
네, 미리 구성된 PrintSettings 객체와 함께 Printer.ShowPrintDialog()를 사용하면 사용자가 세로 및 가로 방향을 선택할 수 있는 대화 상자가 제공됩니다.
용지 방향을 관리하기 위해 내 프로젝트에 IronPrint를 설치하려면 어떻게 해야 합니까?
IronPrint를 설치하려면 Install-Package IronPrint 명령어를 사용하여 NuGet을 통해 설치하십시오. 이를 통해 필요한 라이브러리가 프로젝트에 추가되어 용지 방향 및 다른 인쇄 설정을 제어할 수 있습니다.
.NET의 기본 System.Drawing.Printing과 IronPrint의 용지 방향 설정 접근 방식의 차이점은 무엇입니까?
IronPrint는 PrintPage 이벤트 처리 및 페이지 레이아웃 관리와 같은 복잡한 기본 메서드를 PrintSettings 객체의 PaperOrientation 속성으로 대체하여 프로세스를 단순화하고 더 쉽고 효율적인 방향 설정 방법을 제공합니다.
IronPrint에서 방향 설정을 테스트하기 위해 체험판을 시작하려면 어떻게 해야 합니까?
IronPrint 웹사이트를 방문하면 무료 30일 체험판을 시작할 수 있습니다. 이를 통해 구매 전 실시간 프로젝트 내에서 다양한 방향 설정과 다른 기능을 탐구하고 테스트할 수 있습니다.
IronPrint는 인쇄 대화 상자에서 사용자 상호 작용을 위한 비동기 작업을 지원합니까?
네, IronPrint는 비동기 작업을 Printer.ShowPrintDialogAsync()를 통해 지원하여 인쇄 대화 상자가 열려 있는 동안 애플리케이션이 응답성을 유지하도록 합니다. 이는 사용자가 문서 방향 옵션을 미리 볼 필요가 있는 시나리오에 유용합니다.
커티스 차우는 칼턴 대학교에서 컴퓨터 과학 학사 학위를 취득했으며, Node.js, TypeScript, JavaScript, React를 전문으로 하는 프론트엔드 개발자입니다. 직관적이고 미적으로 뛰어난 사용자 인터페이스를 만드는 데 열정을 가진 그는 최신 프레임워크를 활용하고, 잘 구성되고 시각적으로 매력적인 매뉴얼을 제작하는 것을 즐깁니다.