How to Flatten PDFs Before Printing in C#
IronPrint's PrintSettings class includes a Flatten property that merges all interactive form fields, annotations, and image layers into static content at print time. We set Flatten = true on our PrintSettings object, and IronPrint handles the rest — no separate PDF manipulation library or intermediate file save required.
This guide covers when and how to flatten PDFs before printing, with working C# code for synchronous, combined-settings, and async workflows.
Quickstart: Flatten PDFs Before Printing
- Install IronPrint via NuGet:
Install-Package IronPrint - Add
using IronPrint;to the file - Create a
PrintSettingsobject - Set
Flattentotrue - Pass settings to
Printer.Print()orPrinter.PrintAsync()
-
Install IronPrint with NuGet Package Manager
PM > Install-Package IronPrint -
Copy and run this code snippet.
using IronPrint; // Flatten and print a PDF with form fields Printer.Print("form-document.pdf", new PrintSettings { Flatten = true }); -
Deploy to test on your live environment
Start using IronPrint in your project today with a free trial
Minimal Workflow (5 steps)
- Install the IronPrint C# printing library
- Create a
PrintSettingsobject - Set
Flattentotrue - Pass settings to
Printer.Print() - Verify the printed output contains flattened form fields
How Do I Flatten a PDF Before Printing in C#?
We flatten a PDF at print time by setting the Flatten property to true on a PrintSettings object. We then pass that object to any of IronPrint's print methods.
: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)
We first instantiate PrintSettings, which initializes with default values — including Flatten = false. We then set Flatten to true, Printer.Print Flatten which tells IronPrint to merge all interactive elements into the page content before sending the print job. When we call [Print()], the printer receives a fully static version of the document.
Flattening happens in memory during the print pipeline. The original PDF file remains interactive on disk, so end users can still fill out and resubmit the form. This is an essential distinction: we are flattening for the printer, not permanently altering the source file.
The Flatten property was introduced in IronPrint v2024.7.2 and is available in all subsequent versions.
When Should I Flatten a PDF Before Printing?
Flattening is most valuable when the PDF contains interactive elements that might not render correctly on paper. The most common scenarios include:
PDFs with fillable form fields. Text inputs, checkboxes, radio buttons, and dropdown menus are rendered by the PDF viewer — not embedded in the page content. Some printer drivers skip these layers entirely, resulting in blank fields on the printed page. Flattening forces the field values into the static page layer.
PDFs with annotations or overlays. Comments, sticky notes, stamps, and markup annotations exist on a separate layer. Flattening merges them into the visible content so they appear on the printed output.
PDFs with embedded images at different layers. Documents assembled from multiple sources can have images on different z-layers. Flattening composites everything into a single layer, preventing missing or misaligned images.
When the PDF contains only static text and images — such as a report generated from HTML or a scanned document — flattening has no effect. In those cases, we can leave Flatten at its default value of false Flatten = true PaperSize.A4 PaperOrientation.Portrait Dpi PaperMargins to avoid unnecessary processing overhead.
How Do I Combine Flatten with Other Print Settings?
The PrintSettings class exposes several properties alongside Flatten. We can configure paper size, orientation, DPI, margins, and copy count alongside flattening — all in a single print job.
: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)
We use object initializer syntax for clarity. EnsureFlatten ensures all form data appears on the printed page. PaperSize and Orientation match the standard format for business forms. DPI at 300 produces sharp text on filled fields that were originally rendered at screen resolution. Margins accepts four values in millimeters through the Margins constructor.
These properties do not conflict with each other. IronPrint applies the flatten operation first, then formats the resulting static document according to the remaining settings before sending the job to the printer. For more print settings options including printer selection and tray configuration, see the full configuration guide.
How Do I Flatten and Print Asynchronously?
For applications where blocking the main thread is not acceptable — such as WPF or WinForms apps — we use Printer.PrintAsync. The method accepts the same PrintSettings object and returns a 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
This class-based pattern is useful when print logic lives in a service layer. We configure Flatten = true alongside PaperSize.Letter for US-format forms. The await keyword releases the calling thread while IronPrint processes the flatten operation and sends the print job.
IronPrint's async methods — including PrintAsync and ShowPrintDialogAsync — all honor the Flatten setting identically to their synchronous counterparts await PrintSettings.Flatten Flatten = true. Whether we print silently or through a print dialog, the flattening behavior remains consistent.
What Are My Next Steps?
We covered how to flatten PDFs before printing in C# using IronPrint's PrintSettings property. The key takeaway: set Flatten to merge interactive form fields, annotations, and image layers into static content at print time — without modifying the source file.
To continue building on this:
- Explore the full print settings configuration guide for all available properties
- See the print settings code examples for common patterns
- Review the PrintSettings API reference for property details and default values
- Check the IronPrint changelog for the latest features and improvements
Start a free 30-day trial to test PDF flattening in your own print workflows, or view licensing options for production use.
Frequently Asked Questions
What is the purpose of flattening PDFs before printing?
Flattening PDFs ensures that all form fields, annotations, and images are consolidated into a single layer, which guarantees accurate rendering and printing.
How can I flatten a PDF using C#?
You can flatten a PDF in C# by utilizing the IronPrint library. This involves setting a boolean on the PrintSettings to ensure all elements are properly flattened during the print process.
Why do form fields and annotations need to be flattened?
Form fields and annotations need to be flattened to prevent any interactive elements from being editable or misaligned when printed, ensuring a consistent output.
What happens if a PDF is not flattened before printing?
If a PDF is not flattened, interactive elements like form fields and annotations might not print correctly, leading to errors or missing information in the printed document.
Does IronPrint support flattening other PDF elements aside from form fields?
Yes, IronPrint supports flattening various PDF elements, including annotations, images, and other layered content, ensuring everything is printed as intended.
Is it possible to automate the flattening process in C#?
Absolutely, using IronPrint, you can automate the flattening process by configuring the PrintSettings in your C# code, streamlining the workflow for batch processing PDFs.
Can flattening PDFs impact print quality?
Flattening PDFs generally improves print quality by ensuring all elements are accurately rendered and aligned, reducing the chances of errors during the print process.
What is the role of the PrintSettings boolean in PDF flattening?
The PrintSettings boolean in IronPrint is a key parameter that enables the flattening of PDFs, ensuring all layers are merged into a single, print-ready format.
Does IronPrint require any additional software to flatten PDFs?
No additional software is needed. IronPrint is a standalone library that provides all necessary functionalities to flatten PDFs directly within your C# applications.
How does IronPrint ensure compatibility with different PDF versions?
IronPrint is designed to be compatible with various PDF versions, ensuring that the flattening process maintains the integrity and formatting of the original document.

