Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

868485 sample #65

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions Security/troubleshooting/.NET/ConsoleApp1.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.8.34330.188
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ConsoleApp1", "ConsoleApp1\ConsoleApp1.csproj", "{F791E0B1-C642-4323-80E3-6194633CEFFE}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{F791E0B1-C642-4323-80E3-6194633CEFFE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{F791E0B1-C642-4323-80E3-6194633CEFFE}.Debug|Any CPU.Build.0 = Debug|Any CPU
{F791E0B1-C642-4323-80E3-6194633CEFFE}.Release|Any CPU.ActiveCfg = Release|Any CPU
{F791E0B1-C642-4323-80E3-6194633CEFFE}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {F9DF932F-EB48-4DE6-A052-C05C40E70DAF}
EndGlobalSection
EndGlobal
14 changes: 14 additions & 0 deletions Security/troubleshooting/.NET/ConsoleApp1/ConsoleApp1.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Syncfusion.Pdf.Net.Core" Version="24.1.47" />
</ItemGroup>

</Project>
Binary file not shown.
28 changes: 28 additions & 0 deletions Security/troubleshooting/.NET/ConsoleApp1/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
using Syncfusion.Pdf.Parsing;
using Syncfusion.Pdf.Security;
using System.Security.Cryptography;

// Open a FileStream for reading the PDF file.
FileStream fileStream = new FileStream("OwnerPasswordOnly.pdf", FileMode.Open, FileAccess.Read);
// Load the PDF document from the FileStream with the specified owner password.
PdfLoadedDocument loadedDocument = new PdfLoadedDocument(fileStream, "12345");
// Access the security settings of the loaded PDF document.
PdfSecurity security = loadedDocument.Security;
// Disable incremental update for the file structure.
loadedDocument.FileStructure.IncrementalUpdate = false;
// Set specific permissions for a PDF document.
loadedDocument.Security.Permissions = PdfPermissionsFlags.EditAnnotations | PdfPermissionsFlags.AssembleDocument;
Sri-hari-haran-g marked this conversation as resolved.
Show resolved Hide resolved
// Set the encryption algorithm to AES for the document security.
security.Algorithm = PdfEncryptionAlgorithm.AES;
// Set the owner password for a PDF document.
security.OwnerPassword = "";
// Set the user password for a PDF document.
security.UserPassword = "";
// Create a MemoryStream to store the modified PDF document.
MemoryStream stream = new MemoryStream();
// Save the modified PDF document to the MemoryStream.
loadedDocument.Save(stream);
// Write the contents of the MemoryStream.
File.WriteAllBytes("output.pdf", stream.ToArray());
Sri-hari-haran-g marked this conversation as resolved.
Show resolved Hide resolved
// Close the loaded PDF document.
loadedDocument.Close(true);
Loading