Skip to content

Commit 3b27a93

Browse files
committed
1005727-ug: Added proper content for identify the document permission
1 parent 6f375c0 commit 3b27a93

1 file changed

Lines changed: 77 additions & 0 deletions

File tree

Document-Processing/PDF/PDF-Library/NET/Working-with-Security.md

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1603,6 +1603,83 @@ loadedDocument.Close(True)
16031603

16041604
You can download a complete working sample from [GitHub](https://github.com/SyncfusionExamples/PDF-Examples/tree/master/Security/Change-the-permission-of-the-PDF-document/).
16051605

1606+
## View document permission flags
1607+
1608+
Read a PDF document permission flags via the [Security.Permissions](https://help.syncfusion.com/cr/document-processing/Syncfusion.Pdf.Security.PdfSecurity.html#Syncfusion_Pdf_Security_PdfSecurity_Permissions) property, which returns a bitwise combination of values from the [PdfPermissionsFlags](https://help.syncfusion.com/cr/document-processing/Syncfusion.Pdf.Security.PdfPermissionsFlags.html) enumeration.
1609+
1610+
{% tabs %}
1611+
{% highlight c# tabtitle="C# [Cross-platform]" %}
1612+
1613+
// Load an existing PDF
1614+
using (PdfLoadedDocument loadedDocument = new PdfLoadedDocument("Input.pdf"))
1615+
{
1616+
// Access the document security settings
1617+
PdfSecurity security = loadedDocument.Security;
1618+
// Get the permission flags (bitwise enum)
1619+
PdfPermissionsFlags permissions = security.Permissions;
1620+
Console.WriteLine("Permissions in the document:");
1621+
// Enumerate all flags and print the enabled ones
1622+
foreach (PdfPermissionsFlags flag in Enum.GetValues(typeof(PdfPermissionsFlags)))
1623+
{
1624+
if (flag == 0) continue; // Skip None (0)
1625+
// Check whether the specific flag is set
1626+
if (permissions.HasFlag(flag))
1627+
{
1628+
Console.WriteLine($"- {flag}");
1629+
}
1630+
}
1631+
}
1632+
1633+
{% endhighlight %}
1634+
{% highlight c# tabtitle="C# [Windows-specific]" %}
1635+
1636+
// Load an existing PDF
1637+
using (PdfLoadedDocument loadedDocument = new PdfLoadedDocument("Input.pdf"))
1638+
{
1639+
// Access the document security settings
1640+
PdfSecurity security = loadedDocument.Security;
1641+
// Get the permission flags (bitwise enum)
1642+
PdfPermissionsFlags permissions = security.Permissions;
1643+
Console.WriteLine("Permissions in the document:");
1644+
// Enumerate all flags and print the enabled ones
1645+
foreach (PdfPermissionsFlags flag in Enum.GetValues(typeof(PdfPermissionsFlags)))
1646+
{
1647+
if (flag == 0) continue; // Skip None (0)
1648+
// Check whether the specific flag is set
1649+
if (permissions.HasFlag(flag))
1650+
{
1651+
Console.WriteLine($"- {flag}");
1652+
}
1653+
}
1654+
}
1655+
1656+
{% endhighlight %}
1657+
{% highlight vb.net tabtitle="VB.NET [Windows-specific]" %}
1658+
1659+
' Load an existing PDF
1660+
Using loadedDocument As New PdfLoadedDocument("Input.pdf")
1661+
' Access the document security settings
1662+
Dim security As PdfSecurity = loadedDocument.Security
1663+
' Get the permission flags (bitwise enum)
1664+
Dim permissions As PdfPermissionsFlags = security.Permissions
1665+
Console.WriteLine("Permissions in the document:")
1666+
' Enumerate all flags and print the enabled ones
1667+
For Each flag As PdfPermissionsFlags In [Enum].GetValues(GetType(PdfPermissionsFlags))
1668+
If flag = 0 Then
1669+
Continue For ' Skip None (0)
1670+
End If
1671+
' Check whether the specific flag is set
1672+
If permissions.HasFlag(flag) Then
1673+
Console.WriteLine($"- {flag}")
1674+
End If
1675+
Next
1676+
End Using
1677+
1678+
{% endhighlight %}
1679+
{% endtabs %}
1680+
1681+
You can download a complete working sample from GitHub.
1682+
16061683
## Remove password from the user password PDF document
16071684

16081685
You can remove the [UserPassword](https://help.syncfusion.com/cr/document-processing/Syncfusion.Pdf.Security.PdfSecurity.html#Syncfusion_Pdf_Security_PdfSecurity_UserPassword) from the encrypted PDF document by using the following code snippet.

0 commit comments

Comments
 (0)