This sample shows how to protect your PDF document with a password.
There are two passwords types: a "user" and an "owner" password.
PDFSecurity.OwnerPassword property is for an "owner" password
and PDFSecurity.UserPassword property is for a "user" password.
C# :
using PDFMosaic;
using System;
namespace SetPassword
{
class SetPassword
{
static void Main()
{
PDFDocument document = new PDFDocument();
document.Pages.Add(new PDFPage(PDFPaperFormat.A4));
document.Security.EncryptionAlgorithm = PDFEncryptionAlgorithm.el40bitRC4;
document.Security.UserPassword = "test";
document.Save("SetPassword.pdf", true);
}
}
}
VB.NET :
Imports PDFMosaic
Imports System
Module SetPassword
Sub Main()
Dim document As New PDFDocument()
document.Pages.Add(New PDFPage(PDFPaperFormat.A4))
document.Security.EncryptionAlgorithm = PDFEncryptionAlgorithm.el40bitRC4
document.Security.UserPassword = "test"
document.Save("SetPassword.pdf", True)
End Sub
End Module
