public static void Merger()
        {
            MergeDocument document = new MergeDocument(Util.GetPath("Resources/PDFs/DocumentA.pdf"));

            Aes256Security security = new Aes256Security("OwnerPassword", "UserPassword");

            document.Security = security;

            document.Draw("PasswordProtectPDFMerger.pdf");
            document.Draw(Util.GetPath("Output/PasswordProtectExistingPDF.pdf"));
        }
Beispiel #2
0
        public static void Merger()
        {
            MergeDocument document = new MergeDocument(Util.GetPath("Resources/PDFs/DocumentA.pdf"));

            Aes256Security security = new Aes256Security("OwnerPassword", "UserPassword");

            security.AllowCopy  = false;
            security.AllowPrint = false;
            document.Security   = security;

            document.Draw(Util.GetPath("Output/EncryptExistingPDF.pdf"));
        }
Beispiel #3
0
        // Add password protection for an existing PDF.
        // This code uses DynamicPDF Merger for .NET product.
        // Use the ceTe.DynamicPDF.Merger namespace for the MergeDocument class.
        private static void AddPasswordToExistingPDF()
        {
            //Create PdfDocument object with the existing PDF file and create MergeDocument using PdfDocument
            PdfDocument   pdf      = new PdfDocument(GetResourcePath("doc-a.pdf"));
            MergeDocument document = new MergeDocument(pdf);

            //Create Security object with passwords and set it to the Document
            Aes256Security security = new Aes256Security("owner", "user");

            document.Security = security;

            //Save the Document
            document.Draw("output-existing-pdf.pdf");
        }
Beispiel #4
0
        public static void Generator()
        {
            Document document = new Document();

            Page page = new Page();

            document.Pages.Add(page);

            Aes256Security security = new Aes256Security("OwnerPassword", "UserPassword");

            security.AllowAccessibility = true;
            security.AllowFormFilling   = false;
            document.Security           = security;
            document.Draw(Util.GetPath("Output/EncryptNewPDF.pdf"));
        }
        public static void Generator()
        {
            Document document = new Document();

            Page page = new Page();

            page.Elements.Add(new Label("Protected", 0, 0, 100, 15));
            document.Pages.Add(page);

            Aes256Security security = new Aes256Security("OwnerPassword", "UserPassword");

            document.Security = security;

            document.Draw("PasswordProtectPDFGenerator.pdf");
            document.Draw(Util.GetPath("Output/PasswordProtectNewPDF.pdf"));
        }
Beispiel #6
0
        // Encrypts an existing PDF document
        // This code uses the DynamicPDF Merger for .NET product.
        // Use the ceTe.DynamicPDF.Merger namespace for the MergeDocument class.
        private static void EncryptExistingPDF()
        {
            //Create a MergeDocument object with the existing PDF
            MergeDocument document = new MergeDocument(GetResourcePath("doc-a.pdf"));

            //Create Security object with passwords and other settings
            Aes256Security security = new Aes256Security("owner", "user");

            security.AllowAccessibility = true;
            security.AllowFormFilling   = false;

            //Set security to the Document
            document.Security = security;

            //Save document
            document.Draw("output-existing-pdf.pdf");
        }
Beispiel #7
0
        // Create a password protected PDF from scratch.
        // This code uses DynamicPDF Generator for .NET product.
        // Use the ceTe.DynamicPDF namespace for the Document and Page classes.
        // Use the ceTe.DynamicPDF.Cryptography namespace for the Aes256Security class.
        private static void PasswordProtectNewPDF()
        {
            //Create a Document object
            Document document = new Document();

            //Create a Page object and add it to the Document
            Page page = new Page();

            document.Pages.Add(page);

            //Create a Security class object with passwords and set it to the Document
            Aes256Security security = new Aes256Security("owner", "user");

            document.Security = security;

            document.Draw("output-new-pdf.pdf");
        }
        public static void Run(string outputPdfPath)
        {
            // Create a PDF Document
            Document document = new Document
            {
                Creator = "Aes256BitEncryption",
                Author  = "ceTe Software",
                Title   = "AES 256 Bit Encrypted Document"
            };

            // Create a page to add to the document
            Page page = new Page(PageSize.Letter, PageOrientation.Portrait, 54.0f);

            // Create a Label to add to the page
            string text  = "Hello ASPX C# World...\nFrom DynamicPDF Generator for .NET\nDynamicPDF.com";
            Label  label = new Label(text, 0, 0, 504, 100, Font.Helvetica, 18, TextAlign.Center);

            // Add label to page
            page.Elements.Add(label);

            // Add page to document
            document.Pages.Add(page);

            // Create an instance of EmbeddedFile
            EmbeddedFile embeddedFile = new EmbeddedFile(Util.GetResourcePath("PDFs/DocumentA.pdf"));

            // Add the embeddedFile to the EmbeddedFileList of the document public class
            document.EmbeddedFiles.Add(embeddedFile);

            // Set the PageMode to the ShowAttachments
            document.InitialPageMode = PageMode.ShowAttachments;

            // Create AES 256 bit security object
            Aes256Security security = new Aes256Security("password")
            {
                // Set DocumentComponents property to OnlyFileAttachments
                DocumentComponents = EncryptDocumentComponents.OnlyFileAttachments
            };

            // Add the security object to the document
            document.Security = security;

            // Outputs the document to the current web page
            document.Draw(outputPdfPath);
        }
Beispiel #9
0
        // Encrypts a new PDF created from scratch
        // This code uses the DynamicPDF Generator for .NET product.
        // Use the ceTe.DynamicPDF namespace for the Document and Page classes.
        // Use the ceTe.DynamicPDF.Cryptography namespace for the Aes256Security class.
        private static void EncryptNewPDF()
        {
            //Create a Document object
            Document document = new Document();

            //Create a Page and add to Document
            Page page = new Page();

            document.Pages.Add(page);

            //Create a Aes256Security object with passwords and required options
            Aes256Security security = new Aes256Security("owner", "user");

            security.AllowAccessibility = true;
            security.AllowFormFilling   = false;

            //Set security to the document
            document.Security = security;

            //Save Document
            document.Draw("output-new-pdf.pdf");
        }