VintaSoft Imaging .NET SDK v8.7
Vintasoft.Imaging.Pdf Namespace / PdfDocument Class / PdfDocument Constructor / PdfDocument Constructor(PdfFormat,EncryptionSystem)
Format of new PDF document.
Encryption system of new PDF document.
Example



In This Topic
    PdfDocument Constructor(PdfFormat,EncryptionSystem)
    In This Topic
    Initializes a new instance of the PdfDocument class.
    Syntax
    'Declaration
     
    Public Function New( _
       ByVal format As PdfFormat, _
       ByVal encryptionSystem As EncryptionSystem _
    )
    public PdfDocument( 
       PdfFormat format,
       EncryptionSystem encryptionSystem
    )
    public: PdfDocument( 
       PdfFormat* format,
       EncryptionSystem* encryptionSystem
    )
    public:
    PdfDocument( 
       PdfFormat^ format,
       EncryptionSystem^ encryptionSystem
    )

    Parameters

    format
    Format of new PDF document.
    encryptionSystem
    Encryption system of new PDF document.
    Remarks
    This constructor creates new PDF document of specified format and encryption settings.
    Example
    This example 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: Windows 10, Windows 8, Windows 7, Windows Vista, Windows XP, Windows Server 2012, Windows Server 2008, Windows Server 2003

    See Also