Skip to content

Commit 7fa3464

Browse files
author
mitchel
committed
Implement missing PdfDocument.Flatten() method
1 parent ddf452b commit 7fa3464

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

PdfSharpCore/Pdf/PdfDocument.cs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
using System;
3131
using System.Diagnostics;
3232
using System.IO;
33+
using System.Linq;
3334
using PdfSharpCore.Pdf.Advanced;
3435
using PdfSharpCore.Pdf.Internal;
3536
using PdfSharpCore.Pdf.IO;
@@ -797,6 +798,17 @@ public PdfPage InsertPage(int index, PdfPage page, AnnotationCopyingType annotat
797798
return Catalog.Pages.Insert(index, page, annotationCopying);
798799
}
799800

801+
/// <summary>
802+
/// Flattens a document (make the fields non-editable).
803+
/// </summary>
804+
public void Flatten()
805+
{
806+
for (var i = 0; i < AcroForm?.Fields.Count(); i++)
807+
{
808+
AcroForm.Fields[i].ReadOnly = true;
809+
}
810+
}
811+
800812
/// <summary>
801813
/// Gets the security handler.
802814
/// </summary>

0 commit comments

Comments
 (0)