Skip to content

Commit 5b87bf6

Browse files
committed
261104: Created UG documentation for decrypting encrypted PDF files.
1 parent 2db63d8 commit 5b87bf6

File tree

5 files changed

+66
-0
lines changed

5 files changed

+66
-0
lines changed
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio Version 17
4+
VisualStudioVersion = 17.14.36408.4 d17.14
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Decrypting-encrypted-PDF-document", "Decrypting-encrypted-PDF-document\Decrypting-encrypted-PDF-document.csproj", "{93EFCE7C-2111-4150-AB8D-5E675DADB782}"
7+
EndProject
8+
Global
9+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
10+
Debug|Any CPU = Debug|Any CPU
11+
Release|Any CPU = Release|Any CPU
12+
EndGlobalSection
13+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
14+
{93EFCE7C-2111-4150-AB8D-5E675DADB782}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15+
{93EFCE7C-2111-4150-AB8D-5E675DADB782}.Debug|Any CPU.Build.0 = Debug|Any CPU
16+
{93EFCE7C-2111-4150-AB8D-5E675DADB782}.Release|Any CPU.ActiveCfg = Release|Any CPU
17+
{93EFCE7C-2111-4150-AB8D-5E675DADB782}.Release|Any CPU.Build.0 = Release|Any CPU
18+
EndGlobalSection
19+
GlobalSection(SolutionProperties) = preSolution
20+
HideSolutionNode = FALSE
21+
EndGlobalSection
22+
GlobalSection(ExtensibilityGlobals) = postSolution
23+
SolutionGuid = {ACAC9DFE-C228-4D63-BEB8-B3F16EDEA60F}
24+
EndGlobalSection
25+
EndGlobal
1.96 KB
Binary file not shown.
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<OutputType>Exe</OutputType>
5+
<TargetFramework>net8.0</TargetFramework>
6+
<RootNamespace>Decrypting_encrypted_PDF_document</RootNamespace>
7+
<ImplicitUsings>enable</ImplicitUsings>
8+
<Nullable>enable</Nullable>
9+
</PropertyGroup>
10+
11+
<ItemGroup>
12+
<PackageReference Include="Syncfusion.Pdf.Net.Core" Version="*" />
13+
</ItemGroup>
14+
15+
</Project>

Security/Decrypting-encrypted-PDF-document/.NET/Decrypting-encrypted-PDF-document/Output/gitkeep.txt

Whitespace-only changes.
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
using Syncfusion.Drawing;
2+
using Syncfusion.Pdf;
3+
using Syncfusion.Pdf.Graphics;
4+
using Syncfusion.Pdf.Parsing;
5+
using Syncfusion.Pdf.Security;
6+
7+
using (FileStream inputStream = new FileStream(Path.GetFullPath(@"Data/Input.pdf"), FileMode.Open, FileAccess.Read))
8+
{
9+
// Load the encrypted PDF document from the input stream
10+
PdfLoadedDocument loadedDocument = new PdfLoadedDocument(inputStream, "syncfusion");
11+
12+
// Set the document permissions to default (removes any restrictions)
13+
loadedDocument.Security.Permissions = PdfPermissionsFlags.Default;
14+
15+
// Clear the owner and user passwords to decrypt the document
16+
loadedDocument.Security.OwnerPassword = string.Empty;
17+
loadedDocument.Security.UserPassword = string.Empty;
18+
19+
using (FileStream outputStream = new FileStream(Path.GetFullPath(@"Output/Output.pdf"), FileMode.Create, FileAccess.Write))
20+
{
21+
// Save the decrypted PDF document to the output stream
22+
loadedDocument.Save(outputStream);
23+
}
24+
// Close the loaded PDF document and release resources
25+
loadedDocument.Close(true);
26+
}

0 commit comments

Comments
 (0)