무음 인쇄는 코드를 통해 문서를 직접 프린터로 전송합니다 — 대화 상자, 사용자 상호 작용, 중단 없음. 배치 송장 처리, 키오스크 응용 프로그램, Windows 서비스 백그라운드 작업과 같은 자동화된 워크플로에서는 인쇄 대화 상자의 제거가 필수적입니다. 기본 제공되는 System.Drawing.Printing 네임스페이스는 자동 인쇄 기능을 제공하지만, 팀과 프로젝트 전반에 걸쳐 확장성이 떨어지는 이벤트 기반 상용구 코드를 필요로 합니다.
IronPrint는 무음 인쇄를 단일 메서드 호출로 축소합니다. NuGet 패키지 하나를 설치하고 Printer.Print()를 호출하면, 이 라이브러리가 백그라운드에서 프린터 통신, 문서 렌더링 및 인쇄 스풀러 상호 작용을 처리합니다.
빠른 시작: 무음 인쇄
NuGet을 통해 IronPrint 설치: Install-Package IronPrint
파일에 using IronPrint;을 추가하십시오
Printer.Print("filepath")을 호출하여 문서를 기본 프린터로 전송합니다.
PrintSettings 객체를 전달하여 프린터 이름, DPI, 부수 및 용지 구성을 제어합니다.
PRINT 작업이 호출 스레드를 차단해서는 안 되는 경우 Printer.PrintAsync()을 사용하십시오
NuGet 패키지 관리자를 사용하여 https://www.nuget.org/packages/IronPrint 설치하기
PM > Install-Package IronPrint
다음 코드 조각을 복사하여 실행하세요.
using IronPrint;
// Silent print — no dialog, no user interaction
Printer.Print("invoice.pdf");
.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() 메서드는 파일 경로 또는 바이트 배열을 받아 파일 형식을 감지하고, 적절한 엔진을 통해 렌더링한 후 기본 프린터로 전송합니다. 이 모든 과정이 대화 상자를 표시하지 않고 수행됩니다.
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()에 전달합니다. DPIGrayscalePaperMargins
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에 할당합니다.
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()를 호출합니다. 모든 호출이 조용히 처리되므로, 전체 배치는 단 하나의 대화형 프롬프트 없이 완료됩니다.
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 응용 프로그램과 동시 작업을 처리하는 서비스에 필수적입니다.
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는 인쇄 작업에 대한 완전한 제어를 위한 것입니다. 이들은 데스크탑 플랫폼 전반에 걸쳐 단일 문서, 배치, 동시 인쇄 시나리오를 포괄합니다.