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()
-
1Install IronPrint with NuGet Package Manager
-
2Copy and run this code snippet.
using IronPrint; // Flatten and print a PDF with form fields Printer.Print("form-document.pdf", new PrintSettings { Flatten = true });C# -
3Deploy 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.
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, 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.8 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 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.
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.
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 ClassThis 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. 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 PDF flattening in IronPrint?
PDF flattening in IronPrint refers to the process of merging all interactive form fields, annotations, and image layers into a static content layer using the 'Flatten' property in the PrintSettings class. This ensures correct print output without altering the source file.
How do I enable PDF flattening in C# using IronPrint?
To enable PDF flattening in C#, create a PrintSettings object, set the 'Flatten' property to true, and pass this configuration to the Printer.Print() or Printer.PrintAsync() methods.
Why should I flatten PDFs before printing?
Flattening PDFs is beneficial for ensuring that form fields, annotations, and overlays are correctly rendered on paper, especially since some printer drivers may omit these when printing from interactive PDFs.
Can I combine 'Flatten' with other print settings in IronPrint?
Yes, you can combine 'Flatten' with other print settings such as paper size, orientation, DPI, margins, and copy count within the PrintSettings class to control full printing configuration.
Is PDF flattening permanent in IronPrint?
No, PDF flattening in IronPrint is not permanent. It occurs in memory at print time, leaving the original PDF file unchanged so it remains interactive for future use.
How does asynchronous PDF printing work in IronPrint?
IronPrint supports asynchronous printing via Printer.PrintAsync, which accepts a PrintSettings object with 'Flatten' enabled and performs the operation without blocking the main thread, making it suitable for applications like WPF.
What are common uses for flattening PDFs in C# applications?
Common uses for flattening PDFs include printing documents with interactive form fields, annotations, and overlays that might otherwise not render correctly on paper.
Which IronPrint versions support PDF flattening?
PDF flattening is supported in IronPrint versions starting from v2024.7.8 and available in all subsequent versions.
Can I test PDF flattening before purchasing IronPrint?
Yes, you can start a free 30-day trial of IronPrint to test PDF flattening and evaluate how it integrates with your print workflows.
Does IronPrint affect the original PDF file during flattening?
No, IronPrint does not alter the original PDF file during flattening. The process is done in-memory for printing purposes only, preserving the original file's interactivity on disk.

Curtis Chau holds a Bachelor’s degree in Computer Science (Carleton University) and specializes in front-end development with expertise in Node.js, TypeScript, JavaScript, and React. Passionate about crafting intuitive and aesthetically pleasing user interfaces, Curtis enjoys working with modern frameworks and creating well-structured, visually appealing manuals.