File tree Expand file tree Collapse file tree 4 files changed +40
-0
lines changed
Security/PDF-permission-viewer/.NET Expand file tree Collapse file tree 4 files changed +40
-0
lines changed Original file line number Diff line number Diff line change 1+ <Solution >
2+ <Project Path =" PDF-permission-viewer/PDF-permission-viewer.csproj" />
3+ </Solution >
Original file line number Diff line number Diff line change 1+ <Project Sdk =" Microsoft.NET.Sdk" >
2+
3+ <PropertyGroup >
4+ <OutputType >Exe</OutputType >
5+ <TargetFramework >net8.0</TargetFramework >
6+ <RootNamespace >PDF_permission_viewer</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 >
Original file line number Diff line number Diff line change 1+ using Syncfusion . Pdf . Parsing ;
2+ using Syncfusion . Pdf . Security ;
3+
4+ // Load an existing PDF
5+ using ( PdfLoadedDocument loadedDocument = new PdfLoadedDocument ( Path . GetFullPath ( @"Data/Input.pdf" ) ) )
6+ {
7+ // Access the document security settings
8+ PdfSecurity security = loadedDocument . Security ;
9+ // Get the permission flags (bitwise enum)
10+ PdfPermissionsFlags permissions = security . Permissions ;
11+ Console . WriteLine ( "Permissions in the document:" ) ;
12+ // Enumerate all flags and print the enabled ones
13+ foreach ( PdfPermissionsFlags flag in Enum . GetValues ( typeof ( PdfPermissionsFlags ) ) )
14+ {
15+ if ( flag == 0 ) continue ; // Skip None (0)
16+ // Check whether the specific flag is set
17+ if ( permissions . HasFlag ( flag ) )
18+ {
19+ Console . WriteLine ( $ "- { flag } ") ;
20+ }
21+ }
22+ }
You can’t perform that action at this time.
0 commit comments