Skip to content

958192 Added proper GitHub sample for Read-only PDF document #163

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

Merged
merged 1 commit into from
May 15, 2025
Merged
Show file tree
Hide file tree
Changes from all 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
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2" />
</startup>
</configuration>
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{8AEEB7E7-DDA5-400F-AC31-84E2DA573007}</ProjectGuid>
<OutputType>Exe</OutputType>
<RootNamespace>Make_a_PDF_read_only</RootNamespace>
<AssemblyName>Make-a-PDF-read-only</AssemblyName>
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<Deterministic>true</Deterministic>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="Syncfusion.Compression.Base, Version=29.2462.4.0, Culture=neutral, PublicKeyToken=3d67ed1f87d44c89, processorArchitecture=MSIL">
<HintPath>..\packages\Syncfusion.Compression.Base.29.2.4\lib\net462\Syncfusion.Compression.Base.dll</HintPath>
</Reference>
<Reference Include="Syncfusion.Licensing, Version=29.2462.4.0, Culture=neutral, PublicKeyToken=632609b4d040f6b4, processorArchitecture=MSIL">
<HintPath>..\packages\Syncfusion.Licensing.29.2.4\lib\net462\Syncfusion.Licensing.dll</HintPath>
</Reference>
<Reference Include="Syncfusion.Pdf.Base, Version=29.2462.4.0, Culture=neutral, PublicKeyToken=3d67ed1f87d44c89, processorArchitecture=MSIL">
<HintPath>..\packages\Syncfusion.Pdf.WinForms.29.2.4\lib\net462\Syncfusion.Pdf.Base.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
<None Include="packages.config" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>
Original file line number Diff line number Diff line change
@@ -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);
}
}
}
Original file line number Diff line number Diff line change
@@ -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")]
Loading