how can a password-protected PDF file be opened programmatically?

前端 未结 2 710
轻奢々
轻奢々 2021-01-15 02:58

The Adobe IFilter doesn\'t provide a mechanism to supply a password to open a password-protected PDF file, so it cannot be used to open password-protected files.

I w

2条回答
  •  伪装坚强ぢ
    2021-01-15 03:22

    If you use SpirePDF then you can get images of the pages out of an ecrypted PDF like this:

    using System;
    using System.Drawing;
    using Spire.Pdf;
    namespace PDFDecrypt
    {
        class Decrypt
        {
            static void Main(string[] args)
            {
                //Create Document
                String encryptedPdf = @"D:\work\My Documents\Encryption.pdf";
                PdfDocument doc = new PdfDocument(encryptedPdf, "123456");
    
                //Extract Image
                Image image = doc.Pages[0].ImagesInfo[0].Image;
    
                doc.Close();
    
                //Save
                image.Save("EmployeeInfo.png", System.Drawing.Imaging.ImageFormat.Png);
    
                //Launch
                System.Diagnostics.Process.Start("EmployeeInfo.png");
            }
        }
    }
    

提交回复
热议问题