How to Flatten PDF Images in C# with IronPDF

Flatten PDFs in C#

PDF documents often include forms featuring interactive fillable widgets, such as radio buttons, checkboxes, text boxes, lists, etc. In order to make it non-editable for different application purposes, we need to flatten the PDF file. IronPDF provides the function to flatten your PDF in C# with just one line of code.

PDF before flattening
Flattening process
PDF after flattening

Quickstart: Flatten Your PDF in One Line

Easily flatten PDF documents using IronPDF to remove interactivity and ensure content remains uneditable. This simple one-liner in C# loads an existing PDF, flattens it to remove fillable widgets, and saves the newly secured document. Whether for security or simplification, this method provides a quick and effective solution for .NET developers.

Nuget IconGet started making PDFs with NuGet now:

  1. Install IronPDF with NuGet Package Manager

    PM > Install-Package IronPdf

  2. Copy and run this code snippet.

    IronPdf.PdfDocument.FromFile("input.pdf").Flatten().SaveAs("flattened.pdf");
  3. Deploy to test on your live environment

    Start using IronPDF in your project today with a free trial
    arrow pointer

Flatten C# PDF Document

Once the IronPDF package is installed, you can flatten your PDF file with just one line of code.

In the code example below, we have selected our PDF using the PdfDocument class. If your project requires it, you can also create a PDF using the ChromePdfRenderer class.

To flatten a PDF file, use the Flatten method. This will make the PDF uneditable, removing interactive widgets like radio buttons and checkboxes. Let's see it in action in the flatten PDF C# code example below.

:path=/static-assets/pdf/content-code-examples/how-to/pdf-image-flatten-csharp-flatten-pdf.cs
using IronPdf;

// Select the desired PDF File
PdfDocument pdf = PdfDocument.FromFile("before.pdf");

// Flatten the pdf
pdf.Flatten();

// Save as a new file
pdf.SaveAs("after_flatten.pdf");
Imports IronPdf

' Select the desired PDF File
Private pdf As PdfDocument = PdfDocument.FromFile("before.pdf")

' Flatten the pdf
pdf.Flatten()

' Save as a new file
pdf.SaveAs("after_flatten.pdf")
$vbLabelText   $csharpLabel

Check the Flattened Document

In the below output, the first PDF is editable, our original file. Using IronPDF and the code above, we have made it flat or non-editable. You can use this code for any of your .NET PDF project needs.

Please noteForms will not be detectable after using the Flatten method.


Library Quick Access

Documentation

Read More Documentation

Read the Documentation for more on how to flatten PDFs, edit and manipulate them, and more.

Visit IronPDF Documentation

Ready to see what else you can do? Check out our tutorial page here: Addtional Features

Frequently Asked Questions

How can I flatten a PDF in C#?

You can flatten a PDF in C# by using the IronPDF library. Simply load the PDF with the PdfDocument class, apply the Flatten method, and save the output to create a non-editable document.

What steps are involved in making a PDF uneditable using C#?

To make a PDF uneditable in C#, first install IronPDF from the NuGet Package Manager. Then load or create a PDF document, apply the Flatten method to remove interactivity, and save the flattened document.

Is it possible to flatten interactive elements in any PDF using C#?

Yes, using IronPDF, you can flatten any PDF's interactive elements such as forms, checkboxes, and radio buttons, making the document uneditable.

How does flattening a PDF help in securing the document?

Flattening a PDF secures the document by removing interactive elements, thus preventing any changes or edits to the content, which is ideal for archiving and compliance purposes.

Do I need to write a lot of code to flatten a PDF in C#?

No, with IronPDF, you can flatten a PDF with just one line of code by applying the Flatten method to your PDF document.

Can flattening a PDF be done on newly created PDFs from HTML in C#?

Yes, IronPDF allows you to create PDFs from HTML and then flatten them using the Flatten method, ensuring the document is non-editable.

What resources are available for learning more about PDF manipulation in C#?

You can visit the IronPDF documentation page, which provides extensive guides and API references for manipulating PDFs, including flattening techniques.

.NET 10: Is IronPDF fully compatible and how do I flatten PDFs in a .NET 10 project?

Yes — IronPDF supports .NET 10 (as well as earlier versions like .NET 6–9, .NET Core, and .NET Framework) out of the box. To flatten a PDF in a .NET 10 project, add the IronPdf NuGet package, then use the same example code: PdfDocument pdf = PdfDocument.FromFile("input.pdf"); pdf.Flatten(); pdf.SaveAs("output.pdf"); There’s no special configuration needed for .NET 10.

Curtis Chau
Technical Writer

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.

...

Read More
Ready to Get Started?
Nuget Downloads 16,086,749 | Version: 2025.11 just released