From 5b87bf62d315c3e86f5cf1e09ca81df167ddf963 Mon Sep 17 00:00:00 2001 From: sameerkhan001 Date: Thu, 18 Sep 2025 17:17:12 +0530 Subject: [PATCH] 261104: Created UG documentation for decrypting encrypted PDF files. --- .../Decrypting-encrypted-PDF-document.sln | 25 +++++++++++++++++ .../Data/Input.pdf | Bin 0 -> 2006 bytes .../Decrypting-encrypted-PDF-document.csproj | 15 ++++++++++ .../Output/gitkeep.txt | 0 .../Program.cs | 26 ++++++++++++++++++ 5 files changed, 66 insertions(+) create mode 100644 Security/Decrypting-encrypted-PDF-document/.NET/Decrypting-encrypted-PDF-document.sln create mode 100644 Security/Decrypting-encrypted-PDF-document/.NET/Decrypting-encrypted-PDF-document/Data/Input.pdf create mode 100644 Security/Decrypting-encrypted-PDF-document/.NET/Decrypting-encrypted-PDF-document/Decrypting-encrypted-PDF-document.csproj create mode 100644 Security/Decrypting-encrypted-PDF-document/.NET/Decrypting-encrypted-PDF-document/Output/gitkeep.txt create mode 100644 Security/Decrypting-encrypted-PDF-document/.NET/Decrypting-encrypted-PDF-document/Program.cs diff --git a/Security/Decrypting-encrypted-PDF-document/.NET/Decrypting-encrypted-PDF-document.sln b/Security/Decrypting-encrypted-PDF-document/.NET/Decrypting-encrypted-PDF-document.sln new file mode 100644 index 00000000..7725f2f8 --- /dev/null +++ b/Security/Decrypting-encrypted-PDF-document/.NET/Decrypting-encrypted-PDF-document.sln @@ -0,0 +1,25 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.14.36408.4 d17.14 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Decrypting-encrypted-PDF-document", "Decrypting-encrypted-PDF-document\Decrypting-encrypted-PDF-document.csproj", "{93EFCE7C-2111-4150-AB8D-5E675DADB782}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {93EFCE7C-2111-4150-AB8D-5E675DADB782}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {93EFCE7C-2111-4150-AB8D-5E675DADB782}.Debug|Any CPU.Build.0 = Debug|Any CPU + {93EFCE7C-2111-4150-AB8D-5E675DADB782}.Release|Any CPU.ActiveCfg = Release|Any CPU + {93EFCE7C-2111-4150-AB8D-5E675DADB782}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {ACAC9DFE-C228-4D63-BEB8-B3F16EDEA60F} + EndGlobalSection +EndGlobal diff --git a/Security/Decrypting-encrypted-PDF-document/.NET/Decrypting-encrypted-PDF-document/Data/Input.pdf b/Security/Decrypting-encrypted-PDF-document/.NET/Decrypting-encrypted-PDF-document/Data/Input.pdf new file mode 100644 index 0000000000000000000000000000000000000000..51caf9b1f781468135fa9a0ea9811f0cfc895877 GIT binary patch literal 2006 zcmb_ddr(wW8215|yKH18kq&wtL^Q;`@5ivA_ug}lIho+DXr`dc?nOb^#pSBt3-N`i zDA)jsn&#S=nL0km!IXyqAw4jsniL#C87-6W1sXo;EVz@FS${Nh=iKw1^PS&!&hLEZ z`-MaU7*33247!lz8#^8vbOeTD&iEvQ&SWy^j1x0bRm><`HEXhSCbFZgGu1SVL_TI@ zi8hxLI$bFk)in?qY0#+-d*^cc2^^T1tf?-{Xwj?=yVYg)Kw%utqkjx$VsRWwEXPnX zjguVDNsL5Oia_xKfPh6)5GP2EWN1;60Z9N>!X-#^BrQOWphTXMIf+#SLKY|)0)c06 zUZemG6q=Sqg5c1$j8T|LfC@tcoMr`9hLBMxl2assL=G}3k_bzHgu((q@ub9YEQc#H z3m^i(MMV%G;ANSX6u?84r#Qe;Ji`M*W^q#CNd^~4PndD4W2QC>BN-MMW(@IaoY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j5N6I8Rr|2)+S6~$BQt+Wk>aqq zGEz0nBP<^A84IwfCYB@^fhKs8R8SF80Ex>CBeFasd6J`fB@&6tzq!OBFtgLCVV(@> zM0VKKbZjb)5tL`nlDI%cUDWH!k+;oi0x~9JQwgMmgvaHX*}^=k(B9{p9@np?qIWmU zuj=&uPgggdy3tTM!6#JH?aLm6mG=vB=MAYo5K + + + Exe + net8.0 + Decrypting_encrypted_PDF_document + enable + enable + + + + + + + diff --git a/Security/Decrypting-encrypted-PDF-document/.NET/Decrypting-encrypted-PDF-document/Output/gitkeep.txt b/Security/Decrypting-encrypted-PDF-document/.NET/Decrypting-encrypted-PDF-document/Output/gitkeep.txt new file mode 100644 index 00000000..e69de29b diff --git a/Security/Decrypting-encrypted-PDF-document/.NET/Decrypting-encrypted-PDF-document/Program.cs b/Security/Decrypting-encrypted-PDF-document/.NET/Decrypting-encrypted-PDF-document/Program.cs new file mode 100644 index 00000000..8d969eb5 --- /dev/null +++ b/Security/Decrypting-encrypted-PDF-document/.NET/Decrypting-encrypted-PDF-document/Program.cs @@ -0,0 +1,26 @@ +using Syncfusion.Drawing; +using Syncfusion.Pdf; +using Syncfusion.Pdf.Graphics; +using Syncfusion.Pdf.Parsing; +using Syncfusion.Pdf.Security; + +using (FileStream inputStream = new FileStream(Path.GetFullPath(@"Data/Input.pdf"), FileMode.Open, FileAccess.Read)) +{ + // Load the encrypted PDF document from the input stream + PdfLoadedDocument loadedDocument = new PdfLoadedDocument(inputStream, "syncfusion"); + + // Set the document permissions to default (removes any restrictions) + loadedDocument.Security.Permissions = PdfPermissionsFlags.Default; + + // Clear the owner and user passwords to decrypt the document + loadedDocument.Security.OwnerPassword = string.Empty; + loadedDocument.Security.UserPassword = string.Empty; + + using (FileStream outputStream = new FileStream(Path.GetFullPath(@"Output/Output.pdf"), FileMode.Create, FileAccess.Write)) + { + // Save the decrypted PDF document to the output stream + loadedDocument.Save(outputStream); + } + // Close the loaded PDF document and release resources + loadedDocument.Close(true); +}