Examples

Marking Form Fields as Read Only in PDF (.NET Core/Framework)

Marking Form Fields as Read Only in PDF using DynamicPDF Merger is simple and easy.

How to mark Form Fields as Read Only in PDF

Below are the steps and sample code to to mark form fields as read only so that they cannot be modified once they are set using the DynamicPDF Merger product.

Steps for Marking Form Fields as Read Only in PDF

  1. Create a MergeDocument object with the desired pdf.
  2. Set the field values.
  3. Make the form read only.
  4. Save the MergeDocument.

Sample Code - C#

MergeDocument document = new MergeDocument(pdfFilePath);
document.Form.Fields["TextBox1"].Value = "My Text"; // TextBox field
document.Form.IsReadOnly = true;
document.Draw(@"C:\Output.pdf");  

How to mark Form Fields as Read Only with Encryption in PDF

Below are the steps and sample code to to mark form fields as read only with encryption. Marking form fields as read only does not prevent the PDF from being modified (through a PDF viewer) so that the read only property is turned off and then the form field content can be modified again. Adding encryption to the PDF document after the form fields have been set to read only will prevent users of the PDF from being able to modify the form fields.

Steps for Marking Form Fields as Read Only with Encryption in PDF

  1. Create a MergeDocument object with the desired pdf.
  2. Set the IsReadOnly property on the Form to true.
  3. Create a RC4128Security with owner and user password.
  4. Set the AllowFormFilling and AllowUpdateAnnotsAndFields property to false.
  5. set the documents security to RC4128Security.
  6. Save the MergeDocument.

Sample Code - C#

MergeDocument document = new MergeDocument(pdfFilePath);
document.Form.IsReadOnly = true;
RC4128Security security = new RC4128Security("owner", "user" );
security.AllowFormFilling = false;
security.AllowUpdateAnnotsAndFields = false;
security.AllowEdit = false;
document.Security = security;
document.Draw(@"C:\Output.pdf");  

Getting Started

NuGet Package

DynamicPDF Merger is available on NuGet and is part of the ceTe.DynamicPDF.CoreSuite.NET package. The Core Suite package includes Generator, Merger and ReportWriter.

NuGet Package ID: ceTe.DynamicPDF.CoreSuite.NET

DynamicPDF Merger Information

More information can be found here:

Available in Other Platforms

DynamicPDF Merger PDF Library is available for Java and COM/AxtiveX platforms. Refer to the respective product pages for more details.

Why Choose DynamicPDF?

  • Transparent Pricing
  • Lots of Features
  • Easy to Use
  • Great Support
  • Efficient Performance
  • Product Maturity (Over 18 Years)
  • Free Evaluation
  • .NET Core Support (Most Products)
  • Flexible Licensing

We’re Not The Only Ones That Think We’re Great!