diff --git a/Security/Make-a-PDF-read-only/.NET Framework/Make-a-PDF-read-only.sln b/Security/Make-a-PDF-read-only/.NET Framework/Make-a-PDF-read-only.sln new file mode 100644 index 00000000..de4db379 --- /dev/null +++ b/Security/Make-a-PDF-read-only/.NET Framework/Make-a-PDF-read-only.sln @@ -0,0 +1,22 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.12.35707.178 d17.12 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Make-a-PDF-read-only", "Make-a-PDF-read-only\Make-a-PDF-read-only.csproj", "{8AEEB7E7-DDA5-400F-AC31-84E2DA573007}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {8AEEB7E7-DDA5-400F-AC31-84E2DA573007}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {8AEEB7E7-DDA5-400F-AC31-84E2DA573007}.Debug|Any CPU.Build.0 = Debug|Any CPU + {8AEEB7E7-DDA5-400F-AC31-84E2DA573007}.Release|Any CPU.ActiveCfg = Release|Any CPU + {8AEEB7E7-DDA5-400F-AC31-84E2DA573007}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Security/Make-a-PDF-read-only/.NET Framework/Make-a-PDF-read-only/App.config b/Security/Make-a-PDF-read-only/.NET Framework/Make-a-PDF-read-only/App.config new file mode 100644 index 00000000..56efbc7b --- /dev/null +++ b/Security/Make-a-PDF-read-only/.NET Framework/Make-a-PDF-read-only/App.config @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/Security/Make-a-PDF-read-only/.NET Framework/Make-a-PDF-read-only/Data/Input.pdf b/Security/Make-a-PDF-read-only/.NET Framework/Make-a-PDF-read-only/Data/Input.pdf new file mode 100644 index 00000000..da082542 Binary files /dev/null and b/Security/Make-a-PDF-read-only/.NET Framework/Make-a-PDF-read-only/Data/Input.pdf differ diff --git a/Security/Make-a-PDF-read-only/.NET Framework/Make-a-PDF-read-only/Make-a-PDF-read-only.csproj b/Security/Make-a-PDF-read-only/.NET Framework/Make-a-PDF-read-only/Make-a-PDF-read-only.csproj new file mode 100644 index 00000000..8244b192 --- /dev/null +++ b/Security/Make-a-PDF-read-only/.NET Framework/Make-a-PDF-read-only/Make-a-PDF-read-only.csproj @@ -0,0 +1,63 @@ + + + + + Debug + AnyCPU + {8AEEB7E7-DDA5-400F-AC31-84E2DA573007} + Exe + Make_a_PDF_read_only + Make-a-PDF-read-only + v4.7.2 + 512 + true + true + + + AnyCPU + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + AnyCPU + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + ..\packages\Syncfusion.Compression.Base.29.2.4\lib\net462\Syncfusion.Compression.Base.dll + + + ..\packages\Syncfusion.Licensing.29.2.4\lib\net462\Syncfusion.Licensing.dll + + + ..\packages\Syncfusion.Pdf.WinForms.29.2.4\lib\net462\Syncfusion.Pdf.Base.dll + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Security/Make-a-PDF-read-only/.NET Framework/Make-a-PDF-read-only/Output/gitkeep.txt b/Security/Make-a-PDF-read-only/.NET Framework/Make-a-PDF-read-only/Output/gitkeep.txt new file mode 100644 index 00000000..e69de29b diff --git a/Security/Make-a-PDF-read-only/.NET Framework/Make-a-PDF-read-only/Program.cs b/Security/Make-a-PDF-read-only/.NET Framework/Make-a-PDF-read-only/Program.cs new file mode 100644 index 00000000..7a688890 --- /dev/null +++ b/Security/Make-a-PDF-read-only/.NET Framework/Make-a-PDF-read-only/Program.cs @@ -0,0 +1,39 @@ +using Syncfusion.Pdf.Parsing; +using Syncfusion.Pdf.Security; +using System.IO; + +namespace Make_a_PDF_read_only +{ + internal class Program + { + static void Main(string[] args) + { + // Load an existing PDF document from disk + PdfLoadedDocument loadedDocument = new PdfLoadedDocument("../../Data/Input.pdf"); + + // Access the security settings of the PDF document + PdfSecurity security = loadedDocument.Security; + + // Set the encryption algorithm to AES (Advanced Encryption Standard) + security.Algorithm = PdfEncryptionAlgorithm.AES; + + // Set the encryption key size to 128-bit for a balance of security and performance + security.KeySize = PdfEncryptionKeySize.Key128Bit; + + // Set the owner password (required to enforce permissions) + security.OwnerPassword = "Syncfusion"; + + //It allows printing and accessibility copy content. + security.Permissions = PdfPermissionsFlags.Print | PdfPermissionsFlags.AccessibilityCopyContent; + + // Set an optional user password (required to open the PDF) + security.UserPassword = "password"; + + // Save the updated and secured PDF document to a new file + loadedDocument.Save("../../Output/Output.pdf"); + + // Close and dispose of the loaded PDF document to release resources + loadedDocument.Close(true); + } + } +} diff --git a/Security/Make-a-PDF-read-only/.NET Framework/Make-a-PDF-read-only/Properties/AssemblyInfo.cs b/Security/Make-a-PDF-read-only/.NET Framework/Make-a-PDF-read-only/Properties/AssemblyInfo.cs new file mode 100644 index 00000000..ecdcab69 --- /dev/null +++ b/Security/Make-a-PDF-read-only/.NET Framework/Make-a-PDF-read-only/Properties/AssemblyInfo.cs @@ -0,0 +1,33 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("Make-a-PDF-read-only")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("Make-a-PDF-read-only")] +[assembly: AssemblyCopyright("Copyright © 2025")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("8aeeb7e7-dda5-400f-ac31-84e2da573007")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")]