Example #1
0
        static void UnlockPDF(Book book, string saveFolder)
        {
            Console.WriteLine("[-] Unlocking document: {0}", book.Title);

            try
            {
                var pass = GeneratePDFPassword(book.ID, book.Aggr);
                SaveAndRemovePDFProtection(book, saveFolder, pass);

                Console.WriteLine("[|]    Document unlocked.");
            }
            catch (Exception ex)
            {
                Console.WriteLine("[!]    Error unlocking document: {0}", ex.Message);
            }
        }
Example #2
0
        static void SaveAndRemovePDFProtection(Book book, string saveFolder, string password)
        {
            PdfDocument pdf = CompatiblePdfReader.Open(book.FilePath, password);

            pdf.SecuritySettings.OwnerPassword = string.Empty;
            pdf.SecuritySettings.UserPassword = string.Empty;
            pdf.SecuritySettings.DocumentSecurityLevel = PdfDocumentSecurityLevel.None;

            var savePath = Path.Combine(saveFolder, book.Title + ".pdf");

            var saveStream = new FileStream(savePath, FileMode.OpenOrCreate);
            pdf.Save(saveStream, true);
        }