using System;
using SautinSoft.Pdf;
using System.IO;
class Program
{
static void Main()
{
using (var document = PdfDocument.Load(Path.GetFullPath(@"..\..\..\simple text.pdf")))
{
document.SaveOptions.SetPasswordEncryption().DocumentOpenPassword = "user1234";
document.Save("SautinSoft.pdf");
}
System.Diagnostics.Process.Start(new System.Diagnostics.ProcessStartInfo("SautinSoft.pdf") { UseShellExecute = true });
}
}
The PDF .Net product includes a code example for setting a password on a PDF document. This example demonstrates how to use the library to programmatically add password protection to a PDF file.
The product supports various platforms, including Windows, Linux, macOS, and Docker, and is compatible with .NET 8, 7, 6, 5, Standard 2, Core 2x & 3x, and Framework 4.6.2+.