Add password to PDF with permissions

You can easy protect PDF document with permissions, using the “GroupDocs.Merger for .NET” product.

The following example demonstrates how to secure PDF document with permissions in C# code:

string filePath = @"c:\sample.pdf";
string filePathOut = @"c:\output\result.pdf";

PdfSecurityOptions pdfSecurityOptions = new PdfSecurityOptions("SAMPLE_PASSWORD");
pdfSecurityOptions.Permissions = PdfSecurityPermissions.DenyModification;

using (Merger merger = new Merger(filePath))
{
    merger.AddPassword(pdfSecurityOptions);
    merger.Save(filePathOut);
}