C#에서 문서를 무음으로 인쇄하는 방법

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

무음 인쇄는 코드를 통해 문서를 직접 프린터로 전송합니다 — 대화 상자, 사용자 상호 작용, 중단 없음. 배치 송장 처리, 키오스크 응용 프로그램, Windows 서비스 백그라운드 작업과 같은 자동화된 워크플로에서는 인쇄 대화 상자의 제거가 필수적입니다. 기본 제공되는 System.Drawing.Printing 네임스페이스는 자동 인쇄 기능을 제공하지만, 팀과 프로젝트 전반에 걸쳐 확장성이 떨어지는 이벤트 기반 상용구 코드를 필요로 합니다.

IronPrint는 무음 인쇄를 단일 메서드 호출로 축소합니다. NuGet 패키지 하나를 설치하고 Printer.Print()를 호출하면, 이 라이브러리가 백그라운드에서 프린터 통신, 문서 렌더링 및 인쇄 스풀러 상호 작용을 처리합니다.

빠른 시작: 무음 인쇄

  1. NuGet을 통해 IronPrint 설치: Install-Package IronPrint
  2. 파일에 using IronPrint;을 추가하십시오
  3. Printer.Print("filepath")을 호출하여 문서를 기본 프린터로 전송합니다.
  4. PrintSettings 객체를 전달하여 프린터 이름, DPI, 부수 및 용지 구성을 제어합니다.
  5. PRINT 작업이 호출 스레드를 차단해서는 안 되는 경우 Printer.PrintAsync()을 사용하십시오
  1. NuGet 패키지 관리자를 사용하여 https://www.nuget.org/packages/IronPrint 설치하기

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

    using IronPrint;
    
    // Silent print — no dialog, no user interaction
    Printer.Print("invoice.pdf");
  3. 실제 운영 환경에서 테스트할 수 있도록 배포하세요.

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

    arrow pointer

.NET에서 무음 인쇄는 어떻게 작동합니까?

.NET System.Drawing.Printing 네임스페이스에는 인쇄 작업 중 상태 대화 상자를 표시하지 않도록 하는 StandardPrintController 클래스가 포함되어 있습니다. 기본적으로 .NET은 PrintControllerWithStatusDialog를 사용하며, 이는 "Y페이지 중 X페이지 PRINT 중" 팝업을 표시합니다. StandardPrintController로 전환하면 해당 대화 상자가 사라지지만, 설정 비용은 여전히 상당합니다.

네이티브 방식을 사용하여 백그라운드에서 PRINT하려면, PrintDocument를 생성하고, 인쇄 그래픽 표면에 콘텐츠를 그리는 PrintPage 이벤트 핸들러를 연결하며, StandardPrintController를 할당하고, PrinterSettings를 구성한 다음, Print()을 호출합니다. 이를 위해서는 단일 문서당 약 15~25줄의 설정 코드가 필요하며, 새로운 문서 유형이나 형식이 추가될 때마다 PrintPage 이벤트 내에서 해당 문서 전용 렌더링 로직을 구현해야 합니다. 특히 PDF 렌더링 기능은 System.Drawing.Printing에 내장되어 있지 않습니다. 페이지를 추출하여 Graphics 표면에 그리려면 별도의 PDF 파싱 라이브러리가 필요합니다.

IronPrint는 이 전체 파이프라인을 정적 Printer 클래스에 포함시킵니다. Print() 메서드는 파일 경로 또는 바이트 배열을 받아 파일 형식을 감지하고, 적절한 엔진을 통해 렌더링한 후 기본 프린터로 전송합니다. 이 모든 과정이 대화 상자를 표시하지 않고 수행됩니다.

:path=/static-assets/print/content-code-examples/how-to/silent-printing/silent-printing-print-pdf-and-byte-array.cs
using IronPrint;

// Print a PDF silently
Printer.Print("quarterly-report.pdf");

// Print from a byte array
byte[] pdfData = File.ReadAllBytes("shipping-label.pdf");
Printer.Print(pdfData);
Imports IronPrint

' Print a PDF silently
Printer.Print("quarterly-report.pdf")

' Print from a byte array
Dim pdfData As Byte() = File.ReadAllBytes("shipping-label.pdf")
Printer.Print(pdfData)
$vbLabelText   $csharpLabel

Print() 메서드는 PDF, PNG, TIFF, JPEG, GIF, HTML 및 BMP 파일 형식을 지원합니다. 파일 경로를 문자열로 전달하거나 원본 파일 데이터를 byte[] 형식으로 전달하면, IronPrint가 렌더링 전략을 자동으로 결정합니다.

무음 출력에 대한 인쇄 설정을 어떻게 구성합니까?

PrintSettings 클래스는 우리에게 인쇄 작업에 대한 완전한 제어를 제공합니다. 대상 프린터, 용지 크기, 방향, 여백, DPI, 색상 모드, 인쇄 매수 및 양면 인쇄 설정을 구성한 다음, 설정 객체를 Printer.Print()에 전달합니다. DPI Grayscale PaperMargins

:path=/static-assets/print/content-code-examples/how-to/silent-printing/silent-printing-print-with-settings.cs
using IronPrint;

// Configure print settings
var settings = new PrintSettings
{
    PrinterName = "HP LaserJet Pro",
    PaperSize = PaperSize.A4,
    PaperOrientation = PaperOrientation.Portrait,
    Dpi = 300,
    NumberOfCopies = 2,
    Grayscale = false,
    PaperMargins = new Margins(10, 10, 10, 10)
};

// Print with custom settings
Printer.Print("report.pdf", settings);
Imports IronPrint

' Configure print settings
Dim settings As New PrintSettings With {
    .PrinterName = "HP LaserJet Pro",
    .PaperSize = PaperSize.A4,
    .PaperOrientation = PaperOrientation.Portrait,
    .Dpi = 300,
    .NumberOfCopies = 2,
    .Grayscale = False,
    .PaperMargins = New Margins(10, 10, 10, 10)
}

' Print with custom settings
Printer.Print("report.pdf", settings)
$vbLabelText   $csharpLabel

각 속성은 표준 인쇄 스풀러 설정에 매핑됩니다. Resolution는 출력 해상도를 제어합니다. 300은 비즈니스 문서에 일반적으로 사용되는 값이며, 150은 초안 작성에 적합합니다. ColorMode는 색상이 필요하지 않을 때 토너 사용량을 줄여줍니다. Margins 값은 밀리미터 단위로 지정됩니다.

특정 프린터를 어떻게 선택하나요?

Printer.GetPrinterNames()를 사용하여 시스템에 설치된 모든 프린터를 열거한 다음, 대상 프린터 이름을 PrintSettings.PrinterName에 할당합니다.

:path=/static-assets/print/content-code-examples/how-to/silent-printing/silent-printing-select-specific-printer.cs
using IronPrint;

// List all available printers
List<string> printers = Printer.GetPrinterNames();
foreach (string name in printers)
{
    Console.WriteLine(name);
}

// Target a specific network printer
var settings = new PrintSettings
{
    PrinterName = printers.First(p => p.Contains("LaserJet"))
};

// Print the document
Printer.Print("document.pdf", settings);
Imports IronPrint

' List all available printers
Dim printers As List(Of String) = Printer.GetPrinterNames()
For Each name As String In printers
    Console.WriteLine(name)
Next

' Target a specific network printer
Dim settings As New PrintSettings With {
    .PrinterName = printers.First(Function(p) p.Contains("LaserJet"))
}

' Print the document
Printer.Print("document.pdf", settings)
$vbLabelText   $csharpLabel

PrinterName가 지정되지 않은 경우, IronPrint는 작업을 운영 체제의 기본 프린터로 전송합니다. 여러 프린터가 있는 환경 — 공유 사무실, 창고, 인쇄실 — 에서는 프로그래밍 방식으로 적절한 프린터를 열거하고 선택하여 잘못된 경로의 작업을 방지합니다.

여러 문서를 배치로 인쇄하려면 어떻게 합니까?

배치 인쇄는 간단한 루프 패턴을 따릅니다. 파일 경로 컬렉션을 순회하며 각 문서에 대해 Printer.Print()를 호출합니다. 모든 호출이 조용히 처리되므로, 전체 배치는 단 하나의 대화형 프롬프트 없이 완료됩니다.

:path=/static-assets/print/content-code-examples/how-to/silent-printing/silent-printing-batch-print.cs
using IronPrint;

// Collect all PDFs in the batch folder
string[] invoices = Directory.GetFiles(@"C:\Invoices\Pending", "*.pdf");

// Configure print settings for the batch
var settings = new PrintSettings
{
    PrinterName = "Accounting Printer",
    NumberOfCopies = 1,
    Grayscale = true
};

// Print each invoice and track successes
int successCount = 0;
foreach (string invoice in invoices)
{
    try
    {
        Printer.Print(invoice, settings);
        successCount++;
        Console.WriteLine($"Printed: {Path.GetFileName(invoice)}");
    }
    catch (Exception ex)
    {
        Console.WriteLine($"Failed: {Path.GetFileName(invoice)}: {ex.Message}");
    }
}

// Report batch results
Console.WriteLine($"Batch complete: {successCount}/{invoices.Length} documents printed.");
Imports IronPrint
Imports System.IO

' Collect all PDFs in the batch folder
Dim invoices As String() = Directory.GetFiles("C:\Invoices\Pending", "*.pdf")

' Configure print settings for the batch
Dim settings As New PrintSettings With {
    .PrinterName = "Accounting Printer",
    .NumberOfCopies = 1,
    .Grayscale = True
}

' Print each invoice and track successes
Dim successCount As Integer = 0
For Each invoice As String In invoices
    Try
        Printer.Print(invoice, settings)
        successCount += 1
        Console.WriteLine($"Printed: {Path.GetFileName(invoice)}")
    Catch ex As Exception
        Console.WriteLine($"Failed: {Path.GetFileName(invoice)}: {ex.Message}")
    End Try
Next

' Report batch results
Console.WriteLine($"Batch complete: {successCount}/{invoices.Length} documents printed.")
$vbLabelText   $csharpLabel

Print() 호출을 try-catch 블록으로 감싸면, 손상된 파일 하나나 프린터 시간 초과로 인해 전체 배치 처리가 중단되는 것을 방지할 수 있습니다. 백그라운드 서비스에서 실행되는 대용량 배치의 경우, 각 결과를 데이터베이스나 모니터링 시스템에 기록하면 운영 팀이 검토할 수 있는 감사 추적을 제공합니다.

스레드를 차단하지 않고 비동기적으로 인쇄하는 방법은 무엇입니까?

Printer.PrintAsync() 메서드는 Task를 반환하므로, await 패턴과 호환됩니다. 이는 차단되는 인쇄 호출이 인터페이스를 멈추게 하는 UI 응용 프로그램과 동시 작업을 처리하는 서비스에 필수적입니다.

:path=/static-assets/print/content-code-examples/how-to/silent-printing/silent-printing-async-print.cs
using IronPrint;

// Print asynchronously without blocking the thread
await Printer.PrintAsync("report.pdf");

// Print a batch of reports asynchronously
string[] files = Directory.GetFiles(@"C:\Reports", "*.pdf");
foreach (string file in files)
{
    await Printer.PrintAsync(file);
}
Imports IronPrint

' Print asynchronously without blocking the thread
Await Printer.PrintAsync("report.pdf")

' Print a batch of reports asynchronously
Dim files As String() = Directory.GetFiles("C:\Reports", "*.pdf")
For Each file As String In files
    Await Printer.PrintAsync(file)
Next
$vbLabelText   $csharpLabel

PrintAsync()Print()과 동일한 매개변수(파일 경로 또는 바이트 배열, 그리고 선택적인 PrintSettings 객체)를 받아들입니다. 비동기 오버로드는 수십 개의 문서가 동시에 인쇄 대기열에 놓이는 고처리량 시나리오에서 스레드 풀 고갈을 방지합니다. 이는 현대 .NET 개발 전반에 걸쳐 권장되는 작업 기반 비동기 패턴과 동일한 흐름을 따릅니다.

플랫폼 고려 사항은 무엇입니까?

IronPrint는 데스크탑과 모바일 플랫폼에서 조용한 인쇄를 지원하지만, 동작은 운영 체제에 따라 다릅니다.

플랫폼 무음 인쇄 노트
Windows (7+) 전체 지원 대화 상자 없음, 완전한 PrintSettings 제어
macOS (10+) 지원됨 macOS 기본 인쇄 하위 시스템을 사용
iOS (11+) 대화 상자 표시 Print() 여전히 시스템 인쇄 대화 상자가 표시됨
Android (API 21+) 대화 상자 표시 Print() 여전히 시스템 인쇄 대화 상자가 표시됨

모바일 플랫폼에서는 운영 체제의 제한으로 인해 완전히 무음으로 인쇄하는 것이 불가능하며, Printer.Print()을 사용하더라도 기본 PRINT 대화 상자가 표시됩니다. Android의 경우, PRINT 작업을 수행하기 전에 Printer.Initialize(Android.Content.Context) 호출이 필요합니다. 데스크탑 플랫폼(Windows 및 macOS)은 완전히 비중단의 조용한 인쇄를 모든 제약 없이 지원합니다.

네이티브 .NET 인쇄와 어떻게 비교됩니까?

라이브러리를 도입할지, 아니면 네이티브 System.Drawing.Printing 네임스페이스를 기반으로 개발할지 평가하는 엔지니어링 팀의 경우, 장단점은 다음과 같이 정리됩니다:

PDF/UA-1 PDF/UA-2
게시됨 2012 2024
기본 사양 PDF 1.7 (ISO 32000-1) PDF 2.0 (ISO 32000-2)
규제 범위 미국 장애인법(ADA) 제2장 제508조, EU 접근성법 기존 규정과 호환됩니다.
검증 도구 veraPDF, Adobe Acrobat Pro, PAC 2024 veraPDF (점점 더 많은 지원)
폼 필드 의미론 기준 향상된 기능 (더욱 풍부한 접근성 메타데이터)
~에 가장 적합함 오늘날 대부분의 프로젝트 PDF 2.0 기능을 필요로 하는 새로운 시스템

네이티브 접근 방식은 이미 문서 렌더링 인프라가 있는 팀이 간단한 시나리오에서 작동합니다. PDF, 이미지 또는 HTML을 렌더링 코드 없이 인쇄하는 팀의 경우 IronPrint는 수주일의 개발과 지속적인 유지를 제거합니다. 2025년 5월 릴리스에서 제공된 30% 인쇄 속도 향상은 자체적으로 구축할 경우 엔지니어링 사이클을 소비할 최적화의 한 예입니다.

다음 단계

IronPrint를 사용한 무음 인쇄는 세 가지 핵심 메서드로 요약됩니다: Printer.Print()는 동기식 무음 출력, Printer.PrintAsync()는 비차단 실행, PrintSettings는 인쇄 작업에 대한 완전한 제어를 위한 것입니다. 이들은 데스크탑 플랫폼 전반에 걸쳐 단일 문서, 배치, 동시 인쇄 시나리오를 포괄합니다.

깊이 있는 튜토리얼을 살펴보려면 IronPrint 튜토리얼을 탐색하거나, 완전한 메서드 표면을 위해 프린터 클래스 API 레퍼런스를 검토하세요. 인쇄 설정 사용 방법은 트레이 선택 및 평면화와 같은 추가 구성 옵션을 다룹니다.

무료 30일 체험판을 시작하세요 실제 환경에서 조용한 인쇄를 테스트하십시오 — 신용카드가 필요 없습니다. 배포 준비가 되면 $999부터 시작하는 라이선스 옵션을 확인하십시오.

Iron Software 엔지니어와 채팅하여 특정 배포 시나리오에 대한 도움을 받으세요.

자주 묻는 질문

C#에서 무음 인쇄란 무엇인가요?

C#에서 무음 인쇄는 인쇄 대화 상자나 사용자 상호작용 없이 직접 프린터로 문서를 인쇄할 수 있는 기능을 의미합니다. IronPrint는 개발자가 프로그램을 통해 인쇄 설정을 구성할 수 있도록 이 기능을 제공합니다.

IronPrint로 무음 인쇄를 어떻게 수행할 수 있나요?

IronPrint를 사용하여 DPI, 복사본 수, 비동기 배치 인쇄 활성화와 같은 프린터 구성을 직접 C# 코드에서 설정하여 인쇄 대화 상자를 우회하는 방식으로 무음 인쇄를 수행할 수 있습니다.

IronPrint가 PDF 파일을 무음 인쇄로 처리할 수 있나요?

네, IronPrint는 PDF 파일을 무음 인쇄로 처리하기 위해 특별히 디자인되어, 대화방해 없이 PDF 문서를 원활하게 인쇄할 수 있습니다.

IronPrint를 사용하여 프린터 설정을 구성할 수 있나요?

물론입니다. IronPrint를 사용하면 코드 내부에서 사용자 개입 없이 프린터 선택, DPI 설정, 복사본 수 지정 등 여러 프린터 설정을 구성할 수 있습니다.

IronPrint가 비동기 배치 인쇄를 지원하나요?

네, IronPrint는 비동기 배치 인쇄를 지원하여 여러 인쇄 작업을 백그라운드에서 실행할 수 있게 하며 C# 애플리케이션에서 효율성과 성능을 높입니다.

IronPrint가 호환되는 프로그래밍 언어는 무엇인가요?

IronPrint는 C#과 호환되므로 .NET Framework 내에서 강력한 무음 인쇄 기능이 필요한 개발자에게 훌륭한 선택입니다.

IronPrint가 어떤 인쇄 다이얼로그 없이 인쇄할 수 있나요?

네, IronPrint는 무음 인쇄를 위해 특별히 설계되어 인쇄 대화 상자를 열지 않고 문서를 직접 프린터로 보낼 수 있습니다.

IronPrint 사용하여 어떤 종류의 문서를 인쇄할 수 있습니까?

IronPrint는 주로 PDF 문서를 인쇄하여 C# 애플리케이션에서 원활하고 대화 없는 인쇄 경험을 제공합니다.

IronPrint의 무음 인쇄는 배치 처리에 적합한가요?

네, IronPrint의 무음 인쇄는 배치 처리에 이상적이며, 여러 인쇄 작업을 비동기적으로 관리하고 실행하여 생산성을 향상시키고 워크플로를 간소화할 수 있습니다.

IronPrint는 C# 애플리케이션에서 인쇄 프로세스를 어떻게 개선하나요?

IronPrint는 무대화 인쇄 솔루션을 제공하여 개발자가 프로그램으로 인쇄 구성을 제어할 수 있도록 하고, 효율적인 배치 처리를 위한 비동기 작업을 지원하여 C# 애플리케이션에서 인쇄 프로세스를 개선합니다.

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 다운로드 41,154 | 버전: 2026.5 just released
Still Scrolling Icon

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

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