푸터 콘텐츠로 바로가기
IRONPRINT 사용하여

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#?

  1. Visual Studio 프로젝트 생성
  2. IronWord, IronPDF, 및 IronPrint 라이브러리 설치
  3. IronWord WordDocument 클래스를 사용하여 Word 문서 생성
  4. SaveAs 메서드를 사용하여 Word 문서 저장
  5. IronPDF의 DocxToPdfRenderer 메서드를 사용하여 PDF 문서 생성
  6. IronPrint를 사용하여 PrinterSettings 조정
  7. 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);
$vbLabelText   $csharpLabel

프린터 클래스는 어떻게 작동하나요?

Printer 클래스는 IronPrint의 핵심입니다. 이미지 및 PDF를 포함한 다양한 파일 유형을 인쇄하는 메소드를 제공합니다. 어떤 인쇄 시나리오에도 통합할 수 있으며 실시간 응용 프로그램을 위한 인쇄 대화 상자도 지원합니다. ShowPrintDialog 메소드는 사용자가 필요할 때 익숙한 인쇄 구성 옵션을 제공합니다.

어떤 플랫폼을 IronPrint가 지원하나요?

IronPrint는 Windows, macOS, Android 및 iOS 전반에서 작동하여 어디에서 배포하든 일관된 인쇄 기능을 보장합니다. 이 크로스 플랫폼 지원은 WPF, Windows Forms 및 ASP.NET 응용 프로그램으로 확장됩니다.

필요한 전제 조건은 무엇인가요?

시작하기 전에 다음을 확인하세요:

  1. Visual Studio: 공식 웹사이트에서 다운로드하고 설치합니다.
  2. IronWord 라이브러리: Word 파일 생성 및 조작을 위해. NuGet을 통해 설치하거나 IronWord에서 설치하세요.
  3. IronPDF 라이브러리: Word를 PDF로 변환하기 위해. IronPDF에서 가져오세요.
  4. IronPrint 라이브러리: 인쇄 기능을 위해. IronPrint에서 사용 가능.

Word 문서를 생성, 변환 및 인쇄하는 방법은?

IronWord, IronPDF 및 IronPrint 라이브러리를 사용하여 Word 문서를 생성하고 PDF로 변환한 후 인쇄하는 C# 콘솔 응용 프로그램을 만들어 보겠습니다.

단계 1: Visual Studio에서 C# 콘솔 응용 프로그램 생성

  1. Visual Studio를 열고 새 C# 콘솔 애플리케이션을 만듭니다.
  2. 프로젝트를 구성하고 '다음'을 클릭합니다.
  3. 추가 정보를 선택하여 사용할 .NET Framework를 선택하고 '생성'을 클릭합니다.

2단계: NuGet 패키지 관리자를 통해 필요한 라이브러리 설치

  1. 도구 메뉴에서 NuGet 패키지 관리자 콘솔을 엽니다.
  2. 탐색 탭에서 각 라이브러리를 검색하고 설치를 클릭합니다.
  3. 이 명령을 사용하여 IronPrint를 설치합니다:

    Install-Package IronPrint
  4. IronWord 및 IronPDF도 같은 방식으로 설치합니다. 콘솔의 경우 다음을 사용하십시오:

    Install-Package IronWord
    Install-Package IronPdf
    Install-Package IronWord
    Install-Package IronPdf
    SHELL

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");
$vbLabelText   $csharpLabel

여기서 일어나는 일:

  • 텍스트를 포함한 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");
$vbLabelText   $csharpLabel

Word 문서 출력

IronWord로 생성된 출력 Word 문서는 서식이 지정된 텍스트 콘텐츠를 표시함 - 샘플 텍스트 문단이 포함된 document.docx 파일이 Microsoft 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");
$vbLabelText   $csharpLabel

프로세스는 간단합니다:

  • 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);
$vbLabelText   $csharpLabel

이 코드는:

  • Printer.GetPrinterNames()을 통해 사용 가능한 프린터 가져오기
  • 특정 프린터 선택
  • 용지 크기 및 여백 구성
  • PDF 인쇄

 변환된 PDF 문서의 인쇄 미리보기 준비됨 - IronPrint 출력이 올바른 서식과 여백으로 word.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!");
}
$vbLabelText   $csharpLabel

인쇄 옵션이 기능성을 어떻게 향상시킵니까?

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 IronPDFInstall-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 사용할 것을 권장합니다. 이 조합을 통해 고품질 출력과 편리한 사용성을 보장할 수 있습니다.

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

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

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

Iron Support Team

We're online 24 hours, 5 days a week.
Chat
Email
Call Me