C#을 사용하여 PDF에서 인쇄 설정을 구성하는 방법 | IronPrint

IronPrint 사용하여 C#에서 인쇄 설정을 구성하는 방법

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

C#에서 IronPrint의 PrintSettings 클래스를 사용하여 용지 크기, 방향, DPI, 여백 등을 제어하는 인쇄 설정을 구성합니다. PrintSettings를 단순히 인스턴스화하고 선호 설정을 설정한 다음 Print 메서드에 전달하세요.

빠른 시작: 인쇄 설정 구성하기

  1. NuGet을 통해 IronPrint를 설치합니다: Install-Package IronPrint
  2. using IronPrint;를 파일에 추가합니다
  3. PrintSettings 객체를 생성합니다
  4. PaperSize, Dpi, PaperOrientation, NumberOfCopiesGrayscale와 같은 속성을 설정합니다
  5. 설정을 Printer.Print() 또는 Printer.ShowPrintDialog()에 전달합니다
  1. NuGet 패키지 관리자를 사용하여 https://www.nuget.org/packages/IronPrint 설치하기

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

    using IronPrint;
    
    // Print with custom settings
    Printer.Print("document.pdf", new PrintSettings
    {
        PaperSize = PaperSize.A4,
        PaperOrientation = PaperOrientation.Landscape,
        Dpi = 300,
        NumberOfCopies = 2,
        Grayscale = true
    });
  3. 실제 운영 환경에서 테스트할 수 있도록 배포하세요.

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

    arrow pointer

인쇄 설정은 어떻게 하나요?

인쇄 설정을 구성하려면 PrintSettings 클래스를 인스턴스화하고 원하는 대로 구성하십시오. Print 또는 ShowPrintDialog 메서드에서 PrintSettings 객체를 두 번째 매개변수로 전달합니다. 아래 코드 예제는 이러한 사용법을 보여줍니다. 더 자세한 예시는 인쇄 설정 코드 예시 페이지를 참조하세요.

// Import the necessary namespace for IronPrint
using IronPrint;

// Initialize a new instance of the PrintSettings class
PrintSettings settings = new PrintSettings();

// Configure various print settings
settings.PaperSize = PaperSize.A4;                // Set paper size to A4
settings.PaperOrientation = PaperOrientation.Landscape; // Set paper orientation to Landscape
settings.Dpi = 300;                               // Set print resolution to 300 DPI
settings.NumberOfCopies = 2;                      // Set the number of copies to 2
settings.PrinterName = "MyPrinter";               // Set the name of the printer
settings.PaperMargins = new Margins(10, 10, 10, 10); // Set margins to 10mm on each side
settings.Grayscale = true;                        // Print in grayscale

// Use the PrintSettings in the Print method
IronPrint.Printer.Print(document, settings);
// Import the necessary namespace for IronPrint
using IronPrint;

// Initialize a new instance of the PrintSettings class
PrintSettings settings = new PrintSettings();

// Configure various print settings
settings.PaperSize = PaperSize.A4;                // Set paper size to A4
settings.PaperOrientation = PaperOrientation.Landscape; // Set paper orientation to Landscape
settings.Dpi = 300;                               // Set print resolution to 300 DPI
settings.NumberOfCopies = 2;                      // Set the number of copies to 2
settings.PrinterName = "MyPrinter";               // Set the name of the printer
settings.PaperMargins = new Margins(10, 10, 10, 10); // Set margins to 10mm on each side
settings.Grayscale = true;                        // Print in grayscale

// Use the PrintSettings in the Print method
IronPrint.Printer.Print(document, settings);
$vbLabelText   $csharpLabel

인쇄 설정을 구성해야 하는 이유는 무엇입니까?

인쇄 설정은 문서나 콘텐츠가 인쇄되는 방식을 결정하는 구성 또는 매개변수 집합을 의미합니다. 이러한 설정에는 용지 크기, 방향(세로 또는 가로), 인쇄 해상도(인치당 도트 수 - DPI), 복사 매수, 프린터 선택, 여백 및 흑백 인쇄와 같은 옵션 등의 세부 정보가 포함됩니다. 특정 인쇄 환경 설정 및 요구 사항에 맞게 이러한 설정을 사용자 지정하십시오.

IronPrint의 포괄적인 인쇄 설정 기능은 개발자에게 인쇄 프로세스의 모든 측면을 세밀하게 제어할 수 있는 기능을 제공합니다. 데스크톱 애플리케이션을 개발하든 ASP.NET 웹 애플리케이션을 개발하든, 적절한 구성은 다양한 환경에서 일관된 결과를 보장합니다.

사용자 지정 인쇄 설정은 언제 사용해야 할까요?

특정 여백으로 보고서를 인쇄하거나, 문서를 여러 부 복사하거나, 업무상 필요에 따라 문서 방향을 정확하게 인쇄하는 등 인쇄 출력물을 정밀하게 제어해야 할 때는 사용자 지정 인쇄 설정이 필수적입니다.

다음은 특정 요구 사항에 맞춰 송장을 인쇄하는 실용적인 예입니다.

// Example: Printing invoices with business requirements
using IronPrint;

// Invoice printing with specific business settings
var invoiceSettings = new PrintSettings
{
    PaperSize = PaperSize.Letter,        // US Letter size for business documents
    PaperOrientation = PaperOrientation.Portrait,
    Dpi = 600,                           // High quality for professional output
    NumberOfCopies = 3,                  // Original + customer copy + file copy
    PaperMargins = new Margins(15, 15, 15, 25), // Extra bottom margin for footer
    Grayscale = false,                   // Keep company logo in color
    PrinterName = "Office Color Printer" // Specific high-quality printer
};

// Print the invoice
Printer.Print("invoice_2024_001.pdf", invoiceSettings);
// Example: Printing invoices with business requirements
using IronPrint;

// Invoice printing with specific business settings
var invoiceSettings = new PrintSettings
{
    PaperSize = PaperSize.Letter,        // US Letter size for business documents
    PaperOrientation = PaperOrientation.Portrait,
    Dpi = 600,                           // High quality for professional output
    NumberOfCopies = 3,                  // Original + customer copy + file copy
    PaperMargins = new Margins(15, 15, 15, 25), // Extra bottom margin for footer
    Grayscale = false,                   // Keep company logo in color
    PrinterName = "Office Color Printer" // Specific high-quality printer
};

// Print the invoice
Printer.Print("invoice_2024_001.pdf", invoiceSettings);
$vbLabelText   $csharpLabel

인쇄 설정을 지정하지 않으면 어떻게 되나요?

인쇄 설정을 지정하지 않으면 IronPrint 시스템의 기본 프린터 설정을 사용하며, 이는 사용자가 의도한 출력 형식이나 품질 요구 사항과 일치하지 않을 수 있습니다. 시스템에서 사용 가능한 프린터를 확인하려면 GetPrinterNames 메서드를 사용하여 연결된 모든 프린터를 프로그래밍 방식으로 검색하십시오.

사용 가능한 인쇄 설정은 무엇입니까?

아래에서 사용 가능한 모든 인쇄 설정 옵션을 살펴보세요. 전체 API 참조 문서 에는 각 속성 및 메서드에 대한 자세한 설명이 포함되어 있습니다.

환경 설명 기본값 비고
기본 설정 IronPrint 클래스의 새 인스턴스를 기본값으로 초기화합니다. 해당 없음 해당 없음
용지 크기 프린터에서 사용할 용지 크기를 설정합니다. IronPrint.PaperSize.PrinterDefault 해당 없음
종이 방향 용지 방향(예: 세로 또는 가로)을 지정합니다. IronPrint.PaperOrientation.Portrait 해당 없음
DPI 인치당 도트 수로 나타낸 의도된 인쇄 해상도입니다. 300 실제 인쇄에 사용되는 DPI는 프린터의 성능에 따라 제한될 수 있습니다.
사본 수 문서를 인쇄할 때 생성될 동일한 사본의 수를 나타냅니다. 1 일부 플랫폼에서는 여러 복사본을 정확하게 복제하는 데 제약이 있을 수 있습니다. 이러한 경우, IronPrint.PrintSettings.NumberOfCopies의 지정된 값이 무시되어 한 장의 복사본만 인쇄될 수 있습니다
프린터 이름 인쇄에 사용할 프린터의 이름을 지정합니다. null (운영체제 기본 프린터 사용) 인쇄 대화 상자에서 프린터를 선택하면 이 설정은 무시됩니다. 사용 가능한 프린터 이름을 얻으려면 IronPrint.Printer.GetPrinterNames 또는 IronPrint.Printer.GetPrinterNamesAsync를 사용하여 프린터 이름 목록을 가져올 수 있습니다
용지 여백 인쇄에 사용할 여백을 밀리미터 단위로 설정합니다. null (프린터 기본 여백 사용) 해당 없음
회색조 흑백으로 인쇄할지 여부를 나타냅니다. 거짓 (컬러 인쇄 시도) 해당 없음
단조롭게 하다 인쇄하기 전에 PDF를 병합하면 양식 필드 값과 이미지를 표시하는 데 유용합니다. 거짓 해당 없음
쟁반 인쇄 작업에 사용되는 프린터 트레이. 이 기능을 통해 사용자는 프린터에 용지를 공급할 특정 용지함을 지정할 수 있습니다. null (프린터 기본 용지함을 사용합니다) 인쇄 대화 상자에서 용지함을 선택하면 이 설정은 무시됩니다. 사용 가능한 트레이를 얻으려면 IronPrint.Printer.GetPrinterTrays(System.String) 또는 IronPrint.Printer.GetPrinterTraysAsync(System.String)를 사용할 수 있습니다. 이 트레이 선택 속성은 Windows에서만 사용할 수 있습니다.

어떤 인쇄 설정을 항상 구성해야 할까요?

대부분의 비즈니스 응용 프로그램의 경우 항상 PaperSize, PaperOrientationDpi를 설정하여 다른 프린터 및 시스템에서 일관된 출력을 보장하세요. 이 세 가지 설정은 문서의 모양과 가독성에 가장 큰 영향을 미칩니다.

대화 상자 기반 인쇄를 사용할 때는 ShowPrintDialog 메서드를 이용하여 사용자 지정 설정과 사용자 상호 작용을 결합하십시오.

// Pre-configure settings but allow user to modify
var presetSettings = new PrintSettings
{
    PaperSize = PaperSize.A4,
    PaperOrientation = PaperOrientation.Portrait,
    Dpi = 300
};

// Show dialog with preset values
Printer.ShowPrintDialog("report.pdf", presetSettings);
// Pre-configure settings but allow user to modify
var presetSettings = new PrintSettings
{
    PaperSize = PaperSize.A4,
    PaperOrientation = PaperOrientation.Portrait,
    Dpi = 300
};

// Show dialog with preset values
Printer.ShowPrintDialog("report.pdf", presetSettings);
$vbLabelText   $csharpLabel

플랫폼별 설정은 어떻게 관리하나요?

트레이 선택과 같은 일부 설정은 Windows에서만 사용할 수 있습니다. 플랫폼별 기능을 사용할 때는 항상 플랫폼 호환성을 확인하고, 크로스 플랫폼 애플리케이션의 경우 대체 동작을 제공해야 합니다. 플랫폼별 문제 해결을 위해서는 엔지니어링 지원 가이드를 참조하십시오.

일반적인 인쇄 설정 조합에는 어떤 것들이 있습니까?

일반적인 조합으로는 표준 문서용 A4/세로/300 DPI, 상세 보고서용 A3/가로/600 DPI, 잉크 절약을 위한 초안 인쇄용 Letter/세로/300 DPI/흑백 조합이 있습니다.

다음은 다양한 시나리오를 보여주는 예시입니다.

// Standard office document
var standardDocument = new PrintSettings
{
    PaperSize = PaperSize.A4,
    PaperOrientation = PaperOrientation.Portrait,
    Dpi = 300
};

// Detailed engineering drawing
var technicalDrawing = new PrintSettings
{
    PaperSize = PaperSize.A3,
    PaperOrientation = PaperOrientation.Landscape,
    Dpi = 600,
    Grayscale = false
};

// Draft mode for review
var draftMode = new PrintSettings
{
    PaperSize = PaperSize.Letter,
    PaperOrientation = PaperOrientation.Portrait,
    Dpi = 150,
    Grayscale = true,
    NumberOfCopies = 5
};

// High-volume batch printing
var batchPrint = new PrintSettings
{
    PaperSize = PaperSize.A4,
    PaperOrientation = PaperOrientation.Portrait,
    Dpi = 300,
    NumberOfCopies = 100,
    Tray = "Tray 2" // Large capacity tray on Windows
};
// Standard office document
var standardDocument = new PrintSettings
{
    PaperSize = PaperSize.A4,
    PaperOrientation = PaperOrientation.Portrait,
    Dpi = 300
};

// Detailed engineering drawing
var technicalDrawing = new PrintSettings
{
    PaperSize = PaperSize.A3,
    PaperOrientation = PaperOrientation.Landscape,
    Dpi = 600,
    Grayscale = false
};

// Draft mode for review
var draftMode = new PrintSettings
{
    PaperSize = PaperSize.Letter,
    PaperOrientation = PaperOrientation.Portrait,
    Dpi = 150,
    Grayscale = true,
    NumberOfCopies = 5
};

// High-volume batch printing
var batchPrint = new PrintSettings
{
    PaperSize = PaperSize.A4,
    PaperOrientation = PaperOrientation.Portrait,
    Dpi = 300,
    NumberOfCopies = 100,
    Tray = "Tray 2" // Large capacity tray on Windows
};
$vbLabelText   $csharpLabel

보다 자세한 예시와 고급 인쇄 시나리오를 보려면 인쇄 워크플로의 처음부터 끝까지 전체 과정을 다루는 인쇄 문서 튜토리얼을 참조하십시오.

특히 Web.config를 사용하는 웹 애플리케이션과 같은 실제 운영 환경에서 인쇄 설정을 구현할 때는 Web.config에서 라이선스 키를 설정하는 방법에 대한 가이드를 검토하여 올바르게 구성되었는지 확인하십시오.

자주 묻는 질문

C#에서 인쇄 설정을 어떻게 구성하나요?

C#에서 인쇄 설정을 구성하려면 IronPrint의 PrintSettings 클래스를 인스턴스화하고 PaperSize, PaperOrientation, DPI, NumberOfCopies 및 Grayscale과 같은 속성을 설정합니다. 그런 다음 이 PrintSettings 객체를 Print 또는 ShowPrintDialog 메서드의 두 번째 매개변수로 전달합니다.

어떤 인쇄 설정을 사용자 지정할 수 있나요?

IronPrint의 PrintSettings 클래스를 사용하면 용지 크기(A4, Letter 등), 방향(세로/가로), DPI 해상도, 복사본 수, 프린터 선택, 용지 여백 및 회색조 인쇄 옵션을 사용자 지정할 수 있습니다.

용지 크기와 방향은 어떻게 설정하나요?

Print 메서드를 호출하기 전에 IronPrint PrintSettings 객체에서 PaperSize 속성(예: PaperSize.A4)을 사용하여 용지 크기를 설정하고 PaperOrientation 속성(예: PaperOrientation.Landscape)을 사용하여 용지 방향을 설정하십시오.

문서를 여러 부 복사해서 인쇄할 수 있나요?

네, PrintSettings 클래스의 NumberOfCopies 속성을 설정하여 여러 부를 인쇄할 수 있습니다. 예를 들어 settings.NumberOfCopies = 2로 설정하면 IronPrint를 사용하여 문서가 두 부 인쇄됩니다.

인쇄 시 사용자 지정 여백을 설정하는 방법은 무엇인가요?

PrintSettings의 PaperMargins 속성을 Margins 클래스와 함께 사용하여 사용자 지정 여백을 설정할 수 있습니다. 예를 들어, settings.PaperMargins = new Margins(10, 10, 10, 10)은 IronPrint로 인쇄할 때 모든 면에 10mm 여백을 설정합니다.

컬러 대신 흑백으로 인쇄할 수 있나요?

예, PrintSettings 객체의 Grayscale 속성을 true로 설정하여 흑백 인쇄를 활성화할 수 있습니다. 이렇게 하면 IronPrint를 통해 인쇄할 때 컬러 문서가 흑백으로 변환됩니다.

커티스 차우
기술 문서 작성자

커티스 차우는 칼턴 대학교에서 컴퓨터 과학 학사 학위를 취득했으며, Node.js, TypeScript, JavaScript, React를 전문으로 하는 프론트엔드 개발자입니다. 직관적이고 미적으로 뛰어난 사용자 인터페이스를 만드는 데 열정을 가진 그는 최신 프레임워크를 활용하고, 잘 구성되고 시각적으로 매력적인 매뉴얼을 제작하는 것을 즐깁니다.

커티스는 개발 분야 외에도 사물 인터넷(IoT)에 깊은 관심을 가지고 있으며, 하드웨어와 소프트웨어를 통합하는 혁신적인 방법을 연구합니다. 여가 시간에는 게임을 즐기거나 디스코드 봇을 만들면서 기술에 대한 애정과 창의성을 결합합니다.

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

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

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