- Demo
- C# source
- VB.Net source
The sample demonstrates how to decrypt an encrypted PDF document and extract the embedded picture.

using System;
using System.Drawing;
using Spire.Pdf;
namespace Decryption
{
class Program
{
static void Main(string[] args)
{
//Create a pdf document.
String encryptedPdf = @"Encrypted.pdf";
PdfDocument doc = new PdfDocument(encryptedPdf, "test");
//extract image
Image image = doc.Pages[0].ImagesInfo[0].Image;
doc.Close();
//Save image file.
image.Save("Wikipedia_Science.png", System.Drawing.Imaging.ImageFormat.Png);
//Launching the image file.
System.Diagnostics.Process.Start("Wikipedia_Science.png");
}
}
}
Imports System.Drawing
Imports Spire.Pdf
Namespace Decryption
Friend Class Program
Shared Sub Main(ByVal args() As String)
'Create a pdf document.
Dim encryptedPdf As String = "Encrypted.pdf"
Dim doc As New PdfDocument(encryptedPdf, "test")
'extract image
Dim image As Image = doc.Pages(0).ImagesInfo(0).Image
doc.Close()
'Save image file.
image.Save("Wikipedia_Science.png", System.Drawing.Imaging.ImageFormat.Png)
'Launching the image file.
Process.Start("Wikipedia_Science.png")
End Sub
End Class
End Namespace
