Last time, I had introduced methods about PDF security, including how to encrypt PDF and add digital certificate. In this post, I want to show another method about how to decrypt PDF document with C#/VB.NET.
In my example, I have an encrypted PDF document, which saves an image about employee information. What I will do is to decrypt this document with password and extract image from it.
Also, I use s component Spire.PDF in my method. Therefore, I add its dll file as reference when starting with the following steps.
Steps:

Original Document
Main Coding:
C#
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");
}
}
}
VB.NET
Imports System.Drawing
Imports Spire.Pdf
Module Decrypt
Sub Main()
'Create Document
Dim encryptedPdf As String = "D:\work\My Documents\Encryption.pdf"
Dim doc As New PdfDocument(encryptedPdf, "123456")
'Extract Image
Dim image As 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")
End Sub
End Module
Result Shown by Following:

______________________________________________________________________________________________
Click Here to Learn more about Spire.PDF
Click Here to Download Spire.PDF
Related Posts:
Create PDF Digital Certificate