VintaSoft Imaging .NET SDK 15.1: Documentation for .NET developer
Vintasoft.Imaging.Pdf Namespace / PdfDocument Class / PdfDocument Constructors / PdfDocument Constructor(PdfFormat,EncryptionSystem)
Syntax Exceptions Remarks Example Requirements SeeAlso
In This Topic
PdfDocument Constructor(PdfFormat,EncryptionSystem)
In This Topic
Initializes a new instance of the PdfDocument class.
Syntax

Parameters

format
Format of new PDF document.
encryptionSystem
Encryption system of new PDF document.
Exceptions
ExceptionDescription
Thrown if format is Pdf_A. Use ConvertDocument(PdfDocumentConformance) method to convert document to PDF/A.
Remarks

This constructor creates new PDF document of specified format and encryption settings.

Example

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);
    }
}

Requirements

Target Platforms: .NET 10; .NET 9; .NET 8; .NET 7; .NET 6; .NET Framework 4.8, 4.7, 4.6, 4.5, 4.0, 3.5

See Also