C#에서 인쇄 전에 PDF를 평면화하는 방법

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

IronPrint의 PrintSettings 클래스에는 인쇄 시 모든 대화형 양식 필드, 주석 및 이미지 레이어를 정적 콘텐츠로 병합하는 Flatten 속성이 포함되어 있습니다. Flatten = true 객체에 PrintSettings를 설정하면 IronPrint가 나머지를 처리하므로, 별도의 PDF 조작 라이브러리나 중간 파일 저장이 필요하지 않습니다.

이 가이드는 언제, 어떻게 PDF를 인쇄 전에 평면화하는지 다루며, 동기, 결합 설정, 비동기 워크플로를 위한 작동 C# 코드를 포함합니다.

빠른 시작: 인쇄 전에 PDF 평면화

  1. NuGet을 통해 IronPrint 설치: Install-Package IronPrint
  2. 파일에 using IronPrint;을 추가하십시오
  3. PrintSettings 객체 생성
  4. Flattentrue로 설정하십시오.
  5. 설정을 Printer.Print() 또는 Printer.PrintAsync()로 전달
  1. NuGet 패키지 관리자를 사용하여 https://www.nuget.org/packages/IronPrint 설치하기

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

    using IronPrint;
    
    // Flatten and print a PDF with form fields
    Printer.Print("form-document.pdf", new PrintSettings
    {
        Flatten = true
    });
  3. 실제 운영 환경에서 테스트할 수 있도록 배포하세요.

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

    arrow pointer

C#에서 인쇄 전에 PDF를 어떻게 평면화합니까?

우리는 PrintSettings 객체에서 Flatten 속성을 true로 설정하여 인쇄 시점에 PDF를 평면화합니다. 그런 다음 해당 객체를 IronPrint의 인쇄 메서드 중 하나에 전달합니다.

:path=/static-assets/print/content-code-examples/how-to/flatten-pdfs/flatten-pdfs-flatten-basic.cs
using IronPrint;

// Configure print settings with flattening enabled
PrintSettings settings = new PrintSettings();
settings.Flatten = true;

// Print the flattened document
Printer.Print("application-form.pdf", settings);
Imports IronPrint

' Configure print settings with flattening enabled
Dim settings As New PrintSettings()
settings.Flatten = True

' Print the flattened document
Printer.Print("application-form.pdf", settings)
$vbLabelText   $csharpLabel

먼저 PrintSettings를 인스턴스화하면, Flatten = false를 포함한 기본값으로 초기화됩니다. 그런 다음 Flattentrue, Printer.Print, Flatten로 설정하면, IronPrint가 인쇄 작업을 전송하기 전에 모든 상호작용 요소를 페이지 콘텐츠에 병합하도록 지시합니다. [Print()]을 호출하면 프린터는 문서의 완전히 정적 버전을 수신합니다.

평면화는 인쇄 파이프라인 동안 메모리에서 발생합니다. 원본 PDF 파일은 디스크에서 대화형으로 남아 있으므로 최종 사용자가 여전히 양식을 작성하고 다시 제출할 수 있습니다. 이것은 중요한 구별점입니다: 우리는 프린터를 위해 평면화하고 있으며, 원본 파일을 영구히 변경하지 않습니다.

Flatten 속성은 IronPrint v2024.7.2에서 도입되었으며, 이후 모든 버전에서 사용할 수 있습니다.

언제 PDF를 인쇄 전에 평면화해야 하나요?

PDF에 올바르게 렌더링되지 않을 수 있는 대화형 요소가 포함되어 있을 때 평면화가 가장 가치가 있습니다. 가장 일반적인 사례는 다음과 같습니다:

양식 필드를 채울 수 있는 PDFs. 텍스트 입력, 체크박스, 라디오 버튼, 드롭다운 메뉴는 PDF 뷰어에서 렌더링되며 페이지 콘텐츠에 임베드되지 않습니다. 일부 프린터 드라이버는 이러한 레이어를 완전히 건너뛰어 인쇄된 페이지에 빈 필드를 남깁니다. 평면화는 필드 값을 정적 페이지 레이어로 강제합니다.

주석 또는 오버레이가 있는 PDFs. 주석, 스티커 노트, 스탬프, 마크업 주석은 별도의 레이어에 존재합니다. 평면화는 그들을 보이는 콘텐츠로 병합하여 인쇄된 출력에 나타나도록 합니다.

다양한 레이어에 내장된 이미지가 있는 PDFs. 여러 소스로 구성된 문서는 서로 다른 z-레이어에 이미지를 가질 수 있습니다. 평면화는 누락되거나 잘못 정렬된 이미지를 방지하기 위해 모든 것을 하나의 레이어로 통합합니다.

PDF에 단지 정적 텍스트와 이미지가 포함되어 있을 때 — 예를 들어 HTML에서 생성된 보고서나 스캔 문서 — 평면화는 영향을 미치지 않습니다. 이러한 경우, 불필요한 처리 오버헤드를 방지하기 위해 Flatten를 기본값인 false Flatten = true PaperSize.A4 PaperOrientation.Portrait Dpi PaperMargins로 두어 불필요한 처리 부하를 피할 수 있습니다.

평면화를 다른 인쇄 설정과 결합하는 방법은?

PrintSettings 클래스는 Flatten와 함께 여러 속성을 제공합니다. 우리는 평면화와 함께 용지 크기, 방향, DPI, 여백 및 복사 수를 하나의 인쇄 작업에 설정할 수 있습니다.

:path=/static-assets/print/content-code-examples/how-to/flatten-pdfs/flatten-pdfs-combined-settings.cs
using IronPrint;

// Configure flatten with full print settings
PrintSettings settings = new PrintSettings
{
    Flatten = true,
    PaperSize = PaperSize.A4,
    PaperOrientation = PaperOrientation.Portrait,
    Dpi = 300,
    NumberOfCopies = 2,
    PaperMargins = new Margins(10, 10, 10, 10),
    Grayscale = false
};

// Print the insurance claim form
Printer.Print("insurance-claim.pdf", settings);
Imports IronPrint

' Configure flatten with full print settings
Dim settings As New PrintSettings With {
    .Flatten = True,
    .PaperSize = PaperSize.A4,
    .PaperOrientation = PaperOrientation.Portrait,
    .Dpi = 300,
    .NumberOfCopies = 2,
    .PaperMargins = New Margins(10, 10, 10, 10),
    .Grayscale = False
}

' Print the insurance claim form
Printer.Print("insurance-claim.pdf", settings)
$vbLabelText   $csharpLabel

명확성을 위해 객체 초기화 구문을 사용합니다. EnsureFlatten은 모든 양식 데이터가 인쇄된 페이지에 표시되도록 보장합니다. PaperSizeOrientation는 비즈니스 양식의 표준 형식을 따릅니다. DPI을 300으로 설정하면, 원래 화면 해상도로 렌더링되었던 채워진 영역의 텍스트가 선명하게 표시됩니다. MarginsMargins 생성자를 통해 밀리미터 단위의 네 가지 값을 받아들입니다.

이 속성들은 서로 충돌하지 않습니다. IronPrint는 평면화 작업을 먼저 적용하고, 결과적으로 생성된 정적 문서를 나머지 설정에 따라 포맷한 후 프린터에 작업을 보냅니다. 프린트 설정 옵션에는 프린터 선택트레이 구성이 포함되어 있으며, 전체 구성 가이드를 참조하세요.

평면화 및 비동기 인쇄 방법은?

메인 스레드를 차단하는 것이 허용되지 않는 애플리케이션에서는 — 예를 들어 WPF 또는 WinForms 앱 — Printer.PrintAsync를 사용합니다. 이 메서드는 동일한 PrintSettings 객체를 받아 Task를 반환합니다.

:path=/static-assets/print/content-code-examples/how-to/flatten-pdfs/flatten-pdfs-async-flatten.cs
using IronPrint;
using System.Threading.Tasks;

public class FormPrinter
{
    public async Task PrintFlattenedFormAsync(string pdfPath)
    {
        // Configure flatten with Letter paper at 300 DPI
        PrintSettings settings = new PrintSettings
        {
            Flatten = true,
            PaperSize = PaperSize.Letter,
            Dpi = 300
        };

        // Print asynchronously
        await Printer.PrintAsync(pdfPath, settings);
    }
}
Imports IronPrint
Imports System.Threading.Tasks

Public Class FormPrinter
    Public Async Function PrintFlattenedFormAsync(pdfPath As String) As Task
        ' Configure flatten with Letter paper at 300 DPI
        Dim settings As New PrintSettings With {
            .Flatten = True,
            .PaperSize = PaperSize.Letter,
            .Dpi = 300
        }

        ' Print asynchronously
        Await Printer.PrintAsync(pdfPath, settings)
    End Function
End Class
$vbLabelText   $csharpLabel

이 클래스 기반 패턴은 서비스 계층에서 프린트 로직이 존재할 때 유용합니다. 미국식 양식의 경우 Flatten = truePaperSize.Letter을 함께 구성합니다. await 키워드는 IronPrint가 평면화 작업을 처리하고 인쇄 작업을 전송하는 동안 호출 스레드를 해제합니다.

IronPrint의 비동기 메서드(PrintAsyncShowPrintDialogAsync 포함)는 모두 Flatten 설정을 동기식 메서드 await PrintSettings.Flatten Flatten = true와 동일하게 준수합니다. 조용히 인쇄하거나 인쇄 대화상자를 통해 인쇄하든, 평면화 동작은 일관성을 유지합니다.

내 다음 단계는 무엇인가요?

IronPrint의 PrintSettings 속성을 사용하여 C#에서 인쇄 전에 PDF를 평면화하는 방법을 다루었습니다. 핵심 요점: Flatten을 설정하면 소스 파일을 수정하지 않고도 PRINT 시 대화형 양식 필드, 주석 및 이미지 레이어를 정적 콘텐츠로 병합할 수 있습니다.

이 작업을 계속 진행하려면:

무료 30일 체험판을 시작하여 자신의 프린트 워크플로에서 PDF 평면화를 테스트하거나, 생산 사용을 위한 라이선스 옵션 보기.

자주 묻는 질문

T15: PDF를 인쇄하기 전에 평면화하는 목적은 무엇입니까?

T16: PDF를 평면화하면 모든 양식 필드, 주석 및 이미지가 단일 레이어로 통합되어 정확한 렌더링 및 인쇄를 보장합니다.

T17: C#을 사용하여 PDF를 어떻게 평면화할 수 있습니까?

T18: C#에서 IronPrint 라이브러리를 활용하여 PDF를 평면화할 수 있습니다. 이는 PrintSettings에서 불리언을 설정하여 모든 요소가 인쇄 과정에서 적절히 평면화되도록 보장하는 것을 포함합니다.

T19: 양식 필드와 주석은 왜 평면화해야 합니까?

T20: 양식 필드와 주석은 편집 가능하거나 잘못 정렬되는 것을 방지하기 위해 평면화해야 하며, 이를 통해 일관된 출력물을 보장합니다.

T21: PDF가 평면화되지 않으면 어떤 일이 발생합니까?

T22: PDF가 평면화되지 않으면 양식 필드와 주석과 같은 대화형 요소가 올바르게 인쇄되지 않을 수 있으며, 이로 인해 인쇄된 문서에 오류나 누락된 정보가 생길 수 있습니다.

T23: IronPrint는 양식 필드 외에 다른 PDF 요소의 평면화를 지원합니까?

T24: 예, IronPrint는 주석, 이미지 및 기타 레이어 콘텐츠를 포함한 다양한 PDF 요소의 평면화를 지원하여 모든 내용을 의도한 대로 인쇄할 수 있도록 합니다.

T25: C#에서 평면화 프로세스를 자동화할 수 있습니까?

T26: 당연히 가능합니다. IronPrint를 사용하면 C# 코드에서 PrintSettings를 구성하여 PDF 배치 처리 워크플로를 간소화할 수 있습니다.

T27: PDF 평면화가 인쇄 품질에 영향을 줄 수 있습니까?

T28: PDF 평면화는 일반적으로 모든 요소가 정확하게 렌더링되고 정렬되도록 함으로써 인쇄 품질을 개선하고 인쇄 과정에서 오류 발생 가능성을 줄입니다.

T29: PDF 평면화에서 PrintSettings 불리언의 역할은 무엇입니까?

T30: IronPrint의 PrintSettings 불리언은 PDF의 평면화를 가능하게 하는 주요 매개변수로, 모든 레이어가 단일 인쇄 가능 형식으로 합쳐지도록 합니다.

T31: IronPrint는 PDF를 평면화하는 데 추가 소프트웨어가 필요합니까?

T32: 추가 소프트웨어는 필요하지 않습니다. IronPrint는 독립 실행형 라이브러리로, C# 응용 프로그램 내에서 PDF를 즉시 평면화하는 데 필요한 모든 기능을 제공합니다.

T33: IronPrint는 서로 다른 PDF 버전과의 호환성을 어떻게 보장합니까?

T34: IronPrint는 다양한 PDF 버전과의 호환을 위해 설계되었으며, 평면화 과정에서 원본 문서의 무결성과 서식을 유지합니다.

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
샘플을 실행하세요 문서가 프린터로 전송되는 것을 지켜보세요.