PdfDocument Constructor(PdfFormat,EncryptionSystem)
Initializes a new instance of the
PdfDocument class.
This constructor creates new PDF document of specified format and encryption settings.
Here is an example that shows how to create an empty encrypted PDF document version 1.4 in the memory and save it to a file:
Public Shared Sub CreateEncryptedDocument(pdfFilename As String, images As Vintasoft.Imaging.ImageCollection, password As String)
' create encryption system 40-bit RC4, password protection
Dim encryption As New Vintasoft.Imaging.Pdf.Security.EncryptionSystem(Vintasoft.Imaging.Pdf.Security.EncryptionAlgorithm.RC4, 40, password, password, Vintasoft.Imaging.Pdf.Security.UserAccessPermissions.AllowAll)
' create encrypted document
Using document As New Vintasoft.Imaging.Pdf.PdfDocument(Vintasoft.Imaging.Pdf.PdfFormat.Pdf_14, encryption)
' add pages
For Each image As Vintasoft.Imaging.VintasoftImage In images
document.Pages.Add(image)
Next
' save document
document.SaveChanges(pdfFilename)
End Using
End Sub
public static void CreateEncryptedDocument(
string pdfFilename,
Vintasoft.Imaging.ImageCollection images,
string password)
{
// create encryption system 40-bit RC4, password protection
Vintasoft.Imaging.Pdf.Security.EncryptionSystem encryption =
new Vintasoft.Imaging.Pdf.Security.EncryptionSystem(
Vintasoft.Imaging.Pdf.Security.EncryptionAlgorithm.RC4, 40,
password, password,
Vintasoft.Imaging.Pdf.Security.UserAccessPermissions.AllowAll);
// create encrypted document
using (Vintasoft.Imaging.Pdf.PdfDocument document = new Vintasoft.Imaging.Pdf.PdfDocument(
Vintasoft.Imaging.Pdf.PdfFormat.Pdf_14, encryption))
{
// add pages
foreach (Vintasoft.Imaging.VintasoftImage image in images)
document.Pages.Add(image);
// save document
document.SaveChanges(pdfFilename);
}
}
Target Platforms: .NET9; .NET 8; .NET 7; .NET 6; .NET Framework 4.8, 4.7, 4.6, 4.5, 4.0, 3.5