C#에서 워드 문서를 인쇄하는 방법
C#에서 Word 문서를 인쇄하려면 IronWord를 사용하여 문서를 생성하고 IronPDF로 PDF 형식으로 변환한 다음 IronPrint를 사용하여 여러 플랫폼에서 사용자 정의 가능한 설정으로 인쇄 프로세스를 처리하세요.
C# 응용 프로그램을 빌드할 때, 자주 Word 문서를 프로그래밍 방식으로 생성하고 인쇄해야 합니다. 보고서를 생성하든, 문서를 처리하든, 전문적인 결과물을 생성하든 신뢰할 수 있는 도구를 갖추는 것이 모든 차이를 만듭니다. 여기서 Iron Software의 IronWord, IronPDF, 및 IronPrint가 있습니다. 이 라이브러리는 C# 응용 프로그램에서 문서 생성, 변환 및 인쇄를 단순화하기 위해 협력합니다.
이 글은 IronPrint를 사용한 인쇄, IronWord로 Word 문서 생성, IronPDF로 PDF 변환에 대해 안내합니다. Enterprise 보고 시스템을 구축하든 문서 워크플로를 자동화하든, 이러한 도구는 문서 처리에 필요한 모든 것을 제공합니다.
How to Print a Word Document in C#?
- Visual Studio 프로젝트 생성
- IronWord, IronPDF, 및 IronPrint 라이브러리 설치
- IronWord
WordDocument클래스를 사용하여 Word 문서 생성 SaveAs메서드를 사용하여 Word 문서 저장- IronPDF의
DocxToPdfRenderer메서드를 사용하여 PDF 문서 생성 - IronPrint를 사용하여
PrinterSettings조정 - IronPrint
Printer.Print메서드를 사용하여 인쇄
IronPrint는 무엇인가요?
IronPrint는 .NET용 효과적인 인쇄 라이브러리로, C#에서 인쇄를 완벽하게 제어할 수 있도록 해줍니다. Iron Software에서 제작되었으며, 인쇄 작업을 위해 특별히 설계된 전용 클래스와 메소드를 제공하여 인쇄 프로세스의 모든 측면을 세부 조정할 수 있도록 합니다. 이 라이브러리는 .NET Framework 및 .NET Core와 원활하게 작동하여 모든 유형의 응용 프로그램에 사용할 수 있습니다.
IronPrint의 주요 기능은 무엇인가요?
IronPrint는 인쇄 설정을 어떻게 처리하나요?
IronPrint는 인쇄 작업의 모든 측면을 사용자 정의할 수 있도록 합니다:
- 용지 크기 (Letter, Legal, A4, A3, 사용자 정의)
- 방향 (세로 방향 또는 환경)
- 품질 관리를 위한 DPI
- 정렬된 복사본 수
- 프린터 선택 및 검증
- 정밀한 측정치를 가진 여백
- 비용 절감을 위한 회색조 인쇄
// Example: Advanced print settings configuration
using IronPrint;
// Create complete print settings
PrintSettings advancedSettings = new PrintSettings()
{
PrinterName = "HP LaserJet Pro",
PaperSize = PaperSize.A4,
PrintOrientation = PrintOrientation.Portrait,
Dpi = 600, // High quality print
NumberOfCopies = 3,
Grayscale = true,
PaperMargins = new Margins(50, 50, 40, 40) // Left, Right, Top, Bottom
};
// Apply settings to print job
Printer.Print("document.pdf", advancedSettings);
// Example: Advanced print settings configuration
using IronPrint;
// Create complete print settings
PrintSettings advancedSettings = new PrintSettings()
{
PrinterName = "HP LaserJet Pro",
PaperSize = PaperSize.A4,
PrintOrientation = PrintOrientation.Portrait,
Dpi = 600, // High quality print
NumberOfCopies = 3,
Grayscale = true,
PaperMargins = new Margins(50, 50, 40, 40) // Left, Right, Top, Bottom
};
// Apply settings to print job
Printer.Print("document.pdf", advancedSettings);
Imports IronPrint
' Example: Advanced print settings configuration
' Create complete print settings
Dim advancedSettings As New PrintSettings() With {
.PrinterName = "HP LaserJet Pro",
.PaperSize = PaperSize.A4,
.PrintOrientation = PrintOrientation.Portrait,
.Dpi = 600, ' High quality print
.NumberOfCopies = 3,
.Grayscale = True,
.PaperMargins = New Margins(50, 50, 40, 40) ' Left, Right, Top, Bottom
}
' Apply settings to print job
Printer.Print("document.pdf", advancedSettings)
프린터 클래스는 어떻게 작동하나요?
Printer 클래스는 IronPrint의 핵심입니다. 이미지 및 PDF를 포함한 다양한 파일 유형을 인쇄하는 메소드를 제공합니다. 어떤 인쇄 시나리오에도 통합할 수 있으며 실시간 응용 프로그램을 위한 인쇄 대화 상자도 지원합니다. ShowPrintDialog 메소드는 사용자가 필요할 때 익숙한 인쇄 구성 옵션을 제공합니다.
어떤 플랫폼을 IronPrint가 지원하나요?
IronPrint는 Windows, macOS, Android 및 iOS 전반에서 작동하여 어디에서 배포하든 일관된 인쇄 기능을 보장합니다. 이 크로스 플랫폼 지원은 WPF, Windows Forms 및 ASP.NET 응용 프로그램으로 확장됩니다.
필요한 전제 조건은 무엇인가요?
시작하기 전에 다음을 확인하세요:
Word 문서를 생성, 변환 및 인쇄하는 방법은?
IronWord, IronPDF 및 IronPrint 라이브러리를 사용하여 Word 문서를 생성하고 PDF로 변환한 후 인쇄하는 C# 콘솔 응용 프로그램을 만들어 보겠습니다.
단계 1: Visual Studio에서 C# 콘솔 응용 프로그램 생성
- Visual Studio를 열고 새 C# 콘솔 애플리케이션을 만듭니다.
- 프로젝트를 구성하고 '다음'을 클릭합니다.
- 추가 정보를 선택하여 사용할 .NET Framework를 선택하고 '생성'을 클릭합니다.
2단계: NuGet 패키지 관리자를 통해 필요한 라이브러리 설치
- 도구 메뉴에서 NuGet 패키지 관리자 콘솔을 엽니다.
- 탐색 탭에서 각 라이브러리를 검색하고 설치를 클릭합니다.
-
이 명령을 사용하여 IronPrint를 설치합니다:
Install-Package IronPrint
-
IronWord 및 IronPDF도 같은 방식으로 설치합니다. 콘솔의 경우 다음을 사용하십시오:
Install-Package IronWord Install-Package IronPdfInstall-Package IronWord Install-Package IronPdfSHELL
3단계: IronWord를 사용하여 Word 문서 만들기
다음 링크를 통해 간단한 Word 문서를 생성: IronWord을 사용하여 만듭니다:
using IronWord;
using IronWord.Models;
// Code to Create Word File
// Create a TextRun object with sample text
TextRun textRun = new TextRun("Sample text");
// Create a paragraph and add the TextRun to it
Paragraph paragraph = new Paragraph();
paragraph.AddTextRun(textRun);
// Create a Word document object with the paragraph and save it as a .docx file
WordDocument doc = new WordDocument(paragraph);
doc.SaveAs("assets/document.docx");
using IronWord;
using IronWord.Models;
// Code to Create Word File
// Create a TextRun object with sample text
TextRun textRun = new TextRun("Sample text");
// Create a paragraph and add the TextRun to it
Paragraph paragraph = new Paragraph();
paragraph.AddTextRun(textRun);
// Create a Word document object with the paragraph and save it as a .docx file
WordDocument doc = new WordDocument(paragraph);
doc.SaveAs("assets/document.docx");
Imports IronWord
Imports IronWord.Models
' Code to Create Word File
' Create a TextRun object with sample text
Private textRun As New TextRun("Sample text")
' Create a paragraph and add the TextRun to it
Private paragraph As New Paragraph()
paragraph.AddTextRun(textRun)
' Create a Word document object with the paragraph and save it as a .docx file
Dim doc As New WordDocument(paragraph)
doc.SaveAs("assets/document.docx")
여기서 일어나는 일:
- 텍스트를 포함한
TextRun생성 - 그것을
Paragraph에 추가 WordDocument을 생성하고 저장
더 복잡한 문서를 위해서는 서식, 여러 단락, 표를 추가하십시오:
using IronWord;
using IronWord.Models;
// Create a more complex Word document
WordDocument complexDoc = new WordDocument();
// Add a title paragraph with formatting
TextRun titleRun = new TextRun("Quarterly Sales Report")
{
FontSize = 24,
Bold = true,
FontFamily = "Arial"
};
Paragraph titleParagraph = new Paragraph();
titleParagraph.AddTextRun(titleRun);
// Add body content
TextRun bodyRun = new TextRun("This report contains sales data for Q4 2023.");
Paragraph bodyParagraph = new Paragraph();
bodyParagraph.AddTextRun(bodyRun);
// Add paragraphs to document
complexDoc.AddParagraph(titleParagraph);
complexDoc.AddParagraph(bodyParagraph);
// Save the document
complexDoc.SaveAs("assets/sales_report.docx");
using IronWord;
using IronWord.Models;
// Create a more complex Word document
WordDocument complexDoc = new WordDocument();
// Add a title paragraph with formatting
TextRun titleRun = new TextRun("Quarterly Sales Report")
{
FontSize = 24,
Bold = true,
FontFamily = "Arial"
};
Paragraph titleParagraph = new Paragraph();
titleParagraph.AddTextRun(titleRun);
// Add body content
TextRun bodyRun = new TextRun("This report contains sales data for Q4 2023.");
Paragraph bodyParagraph = new Paragraph();
bodyParagraph.AddTextRun(bodyRun);
// Add paragraphs to document
complexDoc.AddParagraph(titleParagraph);
complexDoc.AddParagraph(bodyParagraph);
// Save the document
complexDoc.SaveAs("assets/sales_report.docx");
Imports IronWord
Imports IronWord.Models
' Create a more complex Word document
Dim complexDoc As New WordDocument()
' Add a title paragraph with formatting
Dim titleRun As New TextRun("Quarterly Sales Report") With {
.FontSize = 24,
.Bold = True,
.FontFamily = "Arial"
}
Dim titleParagraph As New Paragraph()
titleParagraph.AddTextRun(titleRun)
' Add body content
Dim bodyRun As New TextRun("This report contains sales data for Q4 2023.")
Dim bodyParagraph As New Paragraph()
bodyParagraph.AddTextRun(bodyRun)
' Add paragraphs to document
complexDoc.AddParagraph(titleParagraph)
complexDoc.AddParagraph(bodyParagraph)
' Save the document
complexDoc.SaveAs("assets/sales_report.docx")
Word 문서 출력

4단계: IronPDF를 사용하여 Word 문서를 PDF로 변환
이제 우리의 Word 문서를 PDF로 변환합니다 IronPDF를 사용하여:
using IronPdf;
// Code to convert DOCX file to PDF using IronPDF
// Create a DocxToPdfRenderer instance
var renderer = new DocxToPdfRenderer();
// Render the DOCX document as a PDF
var pdf = renderer.RenderDocxAsPdf("assets/document.docx");
// Save the resulting PDF
pdf.SaveAs("assets/word.pdf");
using IronPdf;
// Code to convert DOCX file to PDF using IronPDF
// Create a DocxToPdfRenderer instance
var renderer = new DocxToPdfRenderer();
// Render the DOCX document as a PDF
var pdf = renderer.RenderDocxAsPdf("assets/document.docx");
// Save the resulting PDF
pdf.SaveAs("assets/word.pdf");
Imports IronPdf
' Code to convert DOCX file to PDF using IronPDF
' Create a DocxToPdfRenderer instance
Private renderer = New DocxToPdfRenderer()
' Render the DOCX document as a PDF
Private pdf = renderer.RenderDocxAsPdf("assets/document.docx")
' Save the resulting PDF
pdf.SaveAs("assets/word.pdf")
프로세스는 간단합니다:
DocxToPdfRenderer생성- Word 문서를 PDF로 렌더링
- 결과 저장
5단계: IronPrint를 사용하여 PDF 인쇄
마지막으로 우리의 PDF를 인쇄합니다 IronPrint를 사용하여:
using IronPrint;
using System.Collections.Generic;
// Code for Printing using IronPrint
// Fetch printer names available in the system
List<string> printerNames = Printer.GetPrinterNames();
// Configure print settings
PrintSettings printerSettings = new PrintSettings();
foreach(string printerName in printerNames)
{
if(printerName.Equals("Microsoft Print to PDF"))
{
printerSettings.PrinterName = printerName;
}
}
// Set paper size to A4 and configure margins
printerSettings.PaperSize = PaperSize.A4;
Margins margins = new Margins(30, 10);
printerSettings.PaperMargins = margins;
// Print the PDF with the specified settings
Printer.Print("assets/word.pdf", printerSettings);
using IronPrint;
using System.Collections.Generic;
// Code for Printing using IronPrint
// Fetch printer names available in the system
List<string> printerNames = Printer.GetPrinterNames();
// Configure print settings
PrintSettings printerSettings = new PrintSettings();
foreach(string printerName in printerNames)
{
if(printerName.Equals("Microsoft Print to PDF"))
{
printerSettings.PrinterName = printerName;
}
}
// Set paper size to A4 and configure margins
printerSettings.PaperSize = PaperSize.A4;
Margins margins = new Margins(30, 10);
printerSettings.PaperMargins = margins;
// Print the PDF with the specified settings
Printer.Print("assets/word.pdf", printerSettings);
Imports IronPrint
Imports System.Collections.Generic
' Code for Printing using IronPrint
' Fetch printer names available in the system
Private printerNames As List(Of String) = Printer.GetPrinterNames()
' Configure print settings
Private printerSettings As New PrintSettings()
For Each printerName As String In printerNames
If printerName.Equals("Microsoft Print to PDF") Then
printerSettings.PrinterName = printerName
End If
Next printerName
' Set paper size to A4 and configure margins
printerSettings.PaperSize = PaperSize.A4
Dim margins As New Margins(30, 10)
printerSettings.PaperMargins = margins
' Print the PDF with the specified settings
Printer.Print("assets/word.pdf", printerSettings)
이 코드는:
Printer.GetPrinterNames()을 통해 사용 가능한 프린터 가져오기- 특정 프린터 선택
- 용지 크기 및 여백 구성
- PDF 인쇄

복사본 수, 다중 페이지, 회색조 및 DPI에 대한 더 많은 제어를 위해 이 코드 예제를 참조하십시오. 사용자 상호작용을 위해 프린터 대화상자를 활성화할 수도 있습니다.
IronPrint를 사용하여 인쇄하는 것의 장점은 무엇입니까?
여기서 IronPrint가 C# 인쇄 작업에 탁월한 이유:
비동기 인쇄가 중요한 이유는 무엇입니까?
IronPrint는 인쇄 작업이 애플리케이션을 차단하지 않도록 하는 비동기 함수를 제공합니다. 긴 인쇄 작업 동안 UI가 응답성을 유지합니다:
// Asynchronous printing example
using IronPrint;
using System.Threading.Tasks;
public async Task PrintDocumentAsync(string filePath)
{
PrintSettings settings = new PrintSettings
{
PrinterName = "Default Printer",
NumberOfCopies = 2
};
// Non-blocking print operation
await Printer.PrintAsync(filePath, settings);
Console.WriteLine("Print job completed!");
}
// Asynchronous printing example
using IronPrint;
using System.Threading.Tasks;
public async Task PrintDocumentAsync(string filePath)
{
PrintSettings settings = new PrintSettings
{
PrinterName = "Default Printer",
NumberOfCopies = 2
};
// Non-blocking print operation
await Printer.PrintAsync(filePath, settings);
Console.WriteLine("Print job completed!");
}
Imports IronPrint
Imports System.Threading.Tasks
Public Async Function PrintDocumentAsync(filePath As String) As Task
Dim settings As New PrintSettings With {
.PrinterName = "Default Printer",
.NumberOfCopies = 2
}
' Non-blocking print operation
Await Printer.PrintAsync(filePath, settings)
Console.WriteLine("Print job completed!")
End Function
인쇄 옵션이 기능성을 어떻게 향상시킵니까?
Printer 클래스는 PDF, PNG, JPG, TIFF 및 BMP를 포함한 다양한 파일 형식을 처리합니다. 이러한 다양성 덕분에 접근 방식을 변경하지 않고 다양한 콘텐츠 유형을 인쇄할 수 있습니다.
어떤 플랫폼에 배포할 수 있습니까?
IronPrint는 Windows, Android, iOS, macOS에서 실행됩니다. 모든 플랫폼에서 인쇄 코드가 일관되게 작동하여 배포가 간단합니다.
어떤 인쇄 설정을 사용자 정의할 수 있습니까?
PrintSettings 클래스를 통해 다음을 제어할 수 있습니다:
- 용지 크기 및 방향
- DPI 및 인쇄 품질
- 복사본 및 정렬
- 여백 및 레이아웃
- 양면 인쇄
- 사용자 지정 페이지 범위
IronPrint는 다른 라이브러리와 어떻게 통합됩니까?
IronPrint는 다른 Iron Software 제품인 IronBarcode 및 IronPDF와 원활하게 작동합니다. 일관된 API 디자인으로 한 워크플로우에서 문서를 만들고 변환하며 인쇄하는 것이 용이합니다.
API가 사용자 친화적인 이유는 무엇인가요?
IronPrint의 직관적인 메서드 이름과 완벽한 IntelliSense 지원으로 모든 개발자가 쉽게 접근할 수 있습니다. 가파른 학습 곡선 없이 빠르게 인쇄 기능을 추가할 수 있습니다.
어떤 지원 리소스가 제공되나요?
Iron Software는 완전한 문서, 예제, API 참조 및 모범 사례를 제공합니다. 지원 팀이 인쇄 기능을 효과적으로 구현할 수 있도록 도와줍니다.
IronPrint가 인쇄에 대한 제어를 어떻게 향상시키나요?
IronPrint는 인쇄의 모든 측면에 대해 정확한 제어를 제공합니다. 정확한 용지 크기, 여백 및 매개변수를 설정하여 출력물이 특정 요구 사항을 충족하도록 합니다. 프린터 상태를 모니터링하고 오류를 처리하여 신뢰할 수 있는 인쇄 작업 관리를 수행합니다.
다음 단계는 무엇인가요?
이제 Word 문서를 만들고 PDF로 변환하며 C# 애플리케이션에서 인쇄하는 데 필요한 모든 것이 준비되었습니다. IronWord, IronPDF, 및 IronPrint는 함께 완전한 문서 처리 솔루션을 제공합니다. 웹, 모바일, 데스크톱 또는 콘솔 애플리케이션을 구축하고 있든, 이러한 도구는 문서 워크플로우를 간소화합니다.
자세한 인쇄 기술을 보려면 문서 페이지를 방문하세요. 배치 인쇄 및 사용자 정의 인쇄 프로세서와 같은 기능을 탐색하여 애플리케이션의 기능을 향상하세요.
IronPrint 라이선스는 $799부터 시작합니다. 라이브러리를 다운로드하고 오늘 C# 애플리케이션에 전문 인쇄를 추가하세요.
자주 묻는 질문
C#에서 서식을 유지하면서 Word 문서를 인쇄하려면 어떻게 해야 할까요?
C#에서 Word 문서를 서식 그대로 유지한 채 인쇄하려면 IronWord 사용하여 문서를 생성하고, IronPDF 사용하여 PDF로 변환한 다음, IronPrint 로 인쇄하십시오. 이렇게 하면 문서의 서식이 전체 과정에서 보존됩니다.
C#에서 IronPrint 사용하여 문서를 인쇄할 때의 장점은 무엇인가요?
IronPrint 비동기 인쇄, 용지 크기 및 방향과 같은 사용자 지정 설정, 크로스 플랫폼 호환성, Iron Software의 다른 라이브러리와의 원활한 통합을 제공하여 C# 환경에서 인쇄 작업을 위한 강력한 솔루션을 제공합니다.
IronWord, IronPDF, IronPrint C# 프로젝트에 통합하는 방법은 무엇인가요?
이러한 라이브러리를 C# 프로젝트에 통합하려면 Visual Studio의 NuGet 패키지 관리자 콘솔을 통해 설치하세요. Word 문서 생성, PDF 변환 및 인쇄에 필요한 기능을 추가하려면 Install-Package IronWord , Install-Package IronPDF 및 Install-Package IronPrint 사용하십시오.
IronPrint 사용할 때 인쇄 설정을 사용자 지정할 수 있나요?
네, IronPrint 사용하면 용지 크기, 방향, DPI, 인쇄 매수, 프린터 이름, 여백, 흑백 인쇄 등 다양한 인쇄 설정을 사용자 지정할 수 있어 인쇄 과정을 완벽하게 제어할 수 있습니다.
IronPrint 다양한 플랫폼의 인쇄 작업에 적합한가요?
IronPrint 는 크로스 플랫폼 지원을 위해 설계되어 Windows, macOS, Android 및 iOS에 배포할 수 있으므로 다양한 개발 환경에서 활용할 수 있습니다.
C#에서 Word 문서를 생성하고 인쇄하는 데에는 어떤 단계가 포함되나요?
먼저 IronWord 사용하여 Word 문서를 생성합니다. 다음으로 IronPDF의 DocxToPdfRenderer 사용하여 PDF로 변환합니다. 마지막으로 IronPrint 사용하여 PDF를 인쇄하고 문서의 서식이 유지되도록 합니다.
IronPrint C# 애플리케이션에서 문서 처리를 어떻게 향상시키나요?
IronPrint 포괄적인 인쇄 설정, 비동기 인쇄 및 다른 Iron Software 라이브러리와의 원활한 통합을 제공하여 문서 처리를 향상시키고 C# 애플리케이션에서 효율적인 문서 처리 및 인쇄를 지원합니다.
C#에서 문서를 생성하고 인쇄하는 데 권장되는 도구는 무엇입니까?
Iron Software 문서 작성에는 IronWord , PDF 변환에는 IronPDF , 최종 인쇄에는 IronPrint 사용할 것을 권장합니다. 이 조합을 통해 고품질 출력과 편리한 사용성을 보장할 수 있습니다.



