C#에서 인쇄를 위한 종이 방향 설정 방법

This article was translated from English: Does it need improvement?
Translated
View the article in English

종이 방향은 문서를 세로(길이방향) 또는 가로(넓이방향) 모드로 인쇄할지를 제어합니다. 세로는 대부분의 편지, 청구서, 보고서에 적합합니다. 가로는 넓은 테이블, 스프레드시트, 대시보드, 프레젠테이션 슬라이드에 더 좋습니다. 프로그램적으로 방향을 설정하여 사용자의 기본 프린터 구성에 관계없이 일관된 출력을 보장합니다.

IronPrintPrintSettings 클래스의 PaperOrientation 속성을 제공합니다. 우리는 그것을 Portrait 또는 Landscape로 설정하고, 설정을 Printer.Print()에 전달하면 문서는 지정된 레이아웃으로 인쇄됩니다.

빠른 시작: 종이 방향 설정

  1. NuGet을 통해 IronPrint 설치: Install-Package IronPrint
  2. 파일에 using IronPrint; 추가
  3. PrintSettings 객체 생성
  4. PaperOrientationPortrait 또는 Landscape로 설정
  5. 설정을 Printer.Print() 또는 Printer.ShowPrintDialog()에 전달
  1. NuGet 패키지 관리자를 사용하여 https://www.nuget.org/packages/IronPrint 설치하기

    PM > Install-Package IronPrint
  2. 다음 코드 조각을 복사하여 실행하세요.

    using IronPrint;
    
    // Print a document in landscape orientation
    Printer.Print("report.pdf", new PrintSettings
    {
        PaperOrientation = PaperOrientation.Landscape
    });
  3. 실제 운영 환경에서 테스트할 수 있도록 배포하세요.

    무료 체험판으로 오늘 프로젝트에서 IronPrint 사용 시작하기

    arrow pointer

인쇄를 위해 종이 방향을 어떻게 설정합니까?

PrintSettingsPaperOrientation 속성은 세 가지 값을 수용합니다:

  • PaperOrientation.Portrait — 세로 레이아웃(대부분의 프린터에서 기본값). 편지, 계약서, 청구서 같은 단일 열 문서에 가장 적합합니다.
  • PaperOrientation.Landscape — 가로 레이아웃. 데이터 테이블, 간트 차트, 스프레드시트, 슬라이드 데크 같은 넓은 내용에 가장 적합합니다.
  • PaperOrientation.Automatic — 프린터의 기본 설정을 따름.

우리는 PrintSettings 객체를 생성하고 원하는 방향을 할당한 후, 무음 인쇄Printer.Print() 또는 대화 상자 기반 인쇄Printer.ShowPrintDialog()에 전달합니다.

:path=/static-assets/print/content-code-examples/how-to/set-paper-orientation/portrait-and-landscape-orientation.cs
// 이 코드 조각은 사용할 수 없습니다!
$vbLabelText   $csharpLabel

네이티브 .NET System.Drawing.Printing 접근 방식에서는 방향이 DefaultPageSettings.Landscape = true boolean으로, 또한 PrintDocument 내에 숨겨져 있으며 PrintPage 이벤트 처리, 그래픽 렌더링, 수동 페이지 관리가 요구됩니다. IronPrint는 설정 객체의 단일 속성으로 전체 파이프라인을 대체합니다.

다른 인쇄 설정과 방향을 어떻게 결합합니까?

방향은 전체 인쇄 레이아웃을 정의하기 위해 종이 크기, DPI 및 여백과 결합될 때 가장 유용합니다. PrintSettings 클래스는 이러한 모든 것을 하나의 객체로 구성할 수 있도록 합니다.

:path=/static-assets/print/content-code-examples/how-to/set-paper-orientation/combine-orientation-with-settings.cs
// 이 코드 조각은 사용할 수 없습니다!
$vbLabelText   $csharpLabel

PaperSizePaperOrientation는 함께 작동합니다 — A4 가로 방향을 설정하면 297 × 210 mm의 인쇄 영역을 제공하고, A4 세로 방향을 설정하면 210 × 297 mm를 제공합니다. Dpi 속성은 출력 해상도를 제어하며(비즈니스 문서에는 300이 표준), PaperMargins 값은 밀리미터 단위입니다.

인쇄 대화 상자에서 사용자에게 방향 선택을 허용하는 방법은 무엇인가요?

우리가 PrintSettingsPrinter.ShowPrintDialog()에 전달할 때, 대화 상자가 우리가 미리 설정한 방향으로 열립니다. 사용자는 이를 수락하거나 인쇄 전에 세로 방향과 가로 방향을 전환할 수 있습니다.

:path=/static-assets/print/content-code-examples/how-to/set-paper-orientation/dialog-with-orientation-preset.cs
// 이 코드 조각은 사용할 수 없습니다!
$vbLabelText   $csharpLabel

비블로킹 UI 시나리오의 경우, 비동기 변형 Printer.ShowPrintDialogAsync()는 동일한 매개변수를 수락하며 대화 상자가 열려 있는 동안 응용 프로그램을 응답 상태로 유지합니다. 이는 특히 방향 설정에 유용한데, 사용자가 인쇄 작업에 착수하기 전에 세로 방향과 가로 방향에서 문서가 어떻게 보이는지 미리 보기 원하기 때문입니다. 인쇄 문서 튜토리얼은 무음과 대화형 워크플로우를 처음부터 끝까지 다룹니다.

다음 단계

용지 방향은 PrintSettings 객체의 한 속성입니다 — PaperOrientationPortrait, Landscape, Automatic 중 하나로 설정하고 IronPrint 인쇄 메서드에 전달합니다. PaperSize, DpiPaperMargins와 결합하여 전체 레이아웃 제어를 합니다.

사용 가능한 모든 속성을 탐색하려면 인쇄 설정 하우투를, 모든 메서드 표면을 포함하는 Printer 클래스 API 참조를, 또는 실행 가능한 코드 조각 페이지를 보려면 코드 예제 페이지를 참조하십시오. IronPrint 튜토리얼은 전체 인쇄 라이프사이클을 설명하며, 변경 로그는 성능 향상을 포함한 최근 업데이트를 추적합니다.

무료 30일 체험판을 시작하여 실제 프로젝트에서 방향 설정을 테스트하십시오. 준비가 되면 라이선스 옵션 보기를 클릭하여 $749부터 시작하세요.

A PHP Error was encountered

Severity: Warning

Message: Illegal string offset 'name'

Filename: sections/author_component.php

Line Number: 18

Backtrace:

File: /var/www/ironpdf.com/application/views/main/sections/author_component.php
Line: 18
Function: _error_handler

File: /var/www/ironpdf.com/application/libraries/Render.php
Line: 63
Function: view

File: /var/www/ironpdf.com/application/views/products/sections/three_column_docs_page_structure.php
Line: 64
Function: main_view

File: /var/www/ironpdf.com/application/libraries/Render.php
Line: 88
Function: view

File: /var/www/ironpdf.com/application/views/products/how-to/index.php
Line: 2
Function: view

File: /var/www/ironpdf.com/application/libraries/Render.php
Line: 88
Function: view

File: /var/www/ironpdf.com/application/libraries/Render.php
Line: 552
Function: view

File: /var/www/ironpdf.com/application/controllers/Products/Howto.php
Line: 31
Function: render_products_view

File: /var/www/ironpdf.com/index.php
Line: 292
Function: require_once

A PHP Error was encountered

Severity: Warning

Message: Illegal string offset 'title'

Filename: sections/author_component.php

Line Number: 38

Backtrace:

File: /var/www/ironpdf.com/application/views/main/sections/author_component.php
Line: 38
Function: _error_handler

File: /var/www/ironpdf.com/application/libraries/Render.php
Line: 63
Function: view

File: /var/www/ironpdf.com/application/views/products/sections/three_column_docs_page_structure.php
Line: 64
Function: main_view

File: /var/www/ironpdf.com/application/libraries/Render.php
Line: 88
Function: view

File: /var/www/ironpdf.com/application/views/products/how-to/index.php
Line: 2
Function: view

File: /var/www/ironpdf.com/application/libraries/Render.php
Line: 88
Function: view

File: /var/www/ironpdf.com/application/libraries/Render.php
Line: 552
Function: view

File: /var/www/ironpdf.com/application/controllers/Products/Howto.php
Line: 31
Function: render_products_view

File: /var/www/ironpdf.com/index.php
Line: 292
Function: require_once

A PHP Error was encountered

Severity: Warning

Message: Illegal string offset 'comment'

Filename: sections/author_component.php

Line Number: 48

Backtrace:

File: /var/www/ironpdf.com/application/views/main/sections/author_component.php
Line: 48
Function: _error_handler

File: /var/www/ironpdf.com/application/libraries/Render.php
Line: 63
Function: view

File: /var/www/ironpdf.com/application/views/products/sections/three_column_docs_page_structure.php
Line: 64
Function: main_view

File: /var/www/ironpdf.com/application/libraries/Render.php
Line: 88
Function: view

File: /var/www/ironpdf.com/application/views/products/how-to/index.php
Line: 2
Function: view

File: /var/www/ironpdf.com/application/libraries/Render.php
Line: 88
Function: view

File: /var/www/ironpdf.com/application/libraries/Render.php
Line: 552
Function: view

File: /var/www/ironpdf.com/application/controllers/Products/Howto.php
Line: 31
Function: render_products_view

File: /var/www/ironpdf.com/index.php
Line: 292
Function: require_once

시작할 준비 되셨나요?
Nuget 다운로드 38,093 | 버전: 2026.3 방금 출시되었습니다
Still Scrolling Icon

아직도 스크롤하고 계신가요?

빠른 증거를 원하시나요? PM > Install-Package IronPrint
샘플을 실행하세요 문서가 프린터로 전송되는 것을 지켜보세요.