1. Tag Results
password (9)
1 - 9 of 9
Utilizing .NET MAUI OTP Input For Password Entry?
This article explains how to enable password-style input masking in the .NET MAUI OTP Input control. For security purposes, masking input is essential when entering sensitive values. You can achieve this by setting the Type property to Password. XAML: <syncfusion:SfOtpInput Type="Password" Value="e3c7"/> C#: var otpInput = new SfOtpInput { Type = OtpInputType.Password, Value = "e3c7" }; Output: You can download the complete sample from GitHub. Conclusion We hope you found this guide helpful in learning how to use the .NET MAUI OTP Input for password entry. For more features, visit our .NET MAUI OTP Input feature tour page. You can also explore our .NET MAUI OTP Input documentation to understand better how to present and manipulate data. Please let us know in the comments section below if you have any queries or need clarification. Alternatively, you can contact us by creating a support ticket. We are always happy to assist!
How to perform hash calculation in WinForms DataGrid?
WinForms DataGrid (SfDataGrid) does not provide direct support to perform the Hash calculation. You can perform the Hash calculation by customizing the CurrentCellValidated event with the SHA256 hash helper method. //Event subscription sfDataGrid1.CurrentCellValidated += OnCurrentCellValidated; //Event customization private void OnCurrentCellValidated(object sender, CurrentCellValidatedEventArgs e) { // Customize based on your requirement if (e.Column.MappingName == "Password") { //Get the current row var column = e.RowData as System.Data.DataRowView; //Set the Password column value as SHA256 hash column["Password"] = GetSHA256Hash((string)e.NewValue); } } //Helper method to get SHA256 hash public static string GetSHA256Hash(string input) { using (SHA256 sha256 = SHA256.Create()) { // ComputeHash returns a byte array byte[] bytes = sha256.ComputeHash(Encoding.UTF8.GetBytes(input)); // Convert the byte array to a hexadecimal string StringBuilder builder = new StringBuilder(); for (int i = 0; i < bytes.Length; i++) { builder.Append(bytes[i].ToString("x2")); // "x2" formats as a two-digit hexadecimal number } return builder.ToString(); } } The screenshot below illustrates the hash calculation performed in the Password column, Take a moment to peruse the WinForms DataGrid - Cell Validation documentation, where you can find about cell validation with code examples. View Sample in GitHub Conclusion I hope you enjoyed learning about how to perform hash calculation in WinForms DataGrid. You can refer to our WinForms DataGrid feature tour page to know about its other groundbreaking feature representations. You can also explore our WinForms DataGrid documentation to understand how to create and manipulate data. For current customers, you can check out our components from the License and Downloads page. If you are new to Syncfusion, you can try our 30-day free trial to check out our other controls. If you have any queries or require clarifications, please let us know in the comments section below. You can also contact us through our support forums, Direct-Trac, or feedback portal. We are always happy to assist you!
How to show the password column in WinForms GridGroupingControl?
The password column character for the WinForms Grid Grouping control can be set by using the PasswordChar property. The password column character can also be set by using the QueryCellStyleInfo event handler also.   By using the GridColumnDescriptor: In the following code example, the password character of the Password column is set by using the  PasswordChar property. C# //Sets the password column character by using the PasswordChar property of the TableDescriptor. this.gridGroupingControl1.TableDescriptor.Columns["Password"].Appearance.AnyRecordFieldCell.PasswordChar = '*'; VB 'Sets the password column character by using the PasswordChar property of the TableDescriptor. Me.gridGroupingControl1.TableDescriptor.Columns("Password").Appearance.AnyRecordFieldCell.PasswordChar = "*"c By using the QueryCellStyleInfo Event: In the following event handler, the password character of the Grid Grouping control is set for the Password column. C# //Event subscription this.gridGroupingControl1.QueryCellStyleInfo += GridGroupingControl1_QueryCellStyleInfo;   //Eventcustomization private void GridGroupingControl1_QueryCellStyleInfo(object sender, GridTableCellStyleInfoEventArgs e) {     if (e.TableCellIdentity.Column != null && e.TableCellIdentity.Column.Name == "Password")     {         e.Style.PasswordChar = '*';     } } VB 'Event subscription AddHandler Me.gridGroupingControl1.QueryCellStyleInfo, AddressOf GridGroupingControl1_QueryCellStyleInfo   'Eventcustomization Private Sub GridGroupingControl1_QueryCellStyleInfo(ByVal sender As Object, ByVal e As GridTableCellStyleInfoEventArgs)  If e.TableCellIdentity.Column IsNot Nothing AndAlso e.TableCellIdentity.Column.Name = "Password" Then   e.Style.PasswordChar = "*"c  End If End Sub View Sample in GitHub  ConclusionI hope you enjoyed learning how to show the password column in WinForms GridGroupingControl.You can refer to WinForms GridGrouping feature tour page to know about its other groundbreaking feature representations and documentation, and how to quickly get started for configuration specifications. You can also explore our WinForms GridGrouping example to understand how to create and manipulate data.For current customers, you can check out our components from the License and Downloads page. If you are new to Syncfusion, you can try our 30-day free trial to check out our other controls.If you have any queries or require clarifications, please let us know in the comments section below. You can also contact us through our support forums, Direct-Trac, or feedback portal. We are always happy to assist you!  
How to create custom password protected view to load the encrypted PDF document in Xamarin Forms
This KB article explains the creation of a custom password-protected view to load a password-protected PDF document into the PDF viewer control. To start with, add a new method named InitializePasswordView in the MainPage.xaml.cs. In this method, you can create a custom password-protected view using the SfPopupLayout. The entire InitializePasswordView method is as follows. C#: private void InitializePasswordView()         {             #region Password Protected             // Initialize the PopupLayout             popup = new SfPopupLayout();             popup.PopupView.ShowFooter = true;             popup.StaysOpen = true;             popup.PopupView.MinimumWidthRequest = 100;             popup.PopupView.MinimumHeightRequest = 100;             popup.PopupView.WidthRequest = 400;             popup.PopupView.HeightRequest = 210;             popup.Closing += Popup_Closing;             popup.Closed += Popup_Closed;             if (Device.RuntimePlatform == Device.iOS)                 popup.PopupView.ShowCloseButton = false;                                    #region HeaderTemplate              // Initialize the header view of the PopupLayout             popup.PopupView.HeaderTemplate = new DataTemplate(() =>             {                 StackLayout layout = new StackLayout()                 {                     Padding = new Thickness(20, 15, 0, 0),                     BackgroundColor = Color.White,                     HeightRequest = 20                 };                   Label headerLabel = new Label()                 {                     Text = "Password Protected",                     FontSize = 20,                     TextColor = Color.Black,                     FontFamily = "Roboto-Medium",                     HeightRequest = 24,                 };                 if (Device.RuntimePlatform == Device.iOS)                     headerLabel.HorizontalOptions = LayoutOptions.CenterAndExpand;                 layout.Children.Add(headerLabel);                 return layout;             });             #endregion               #region ContentTemplate             // Initialize the content view of the PopupLayout             popup.PopupView.ContentTemplate = new DataTemplate(() =>             {                 StackLayout contentLayout = new StackLayout()                 {                     BackgroundColor = Color.Transparent,                     Padding = new Thickness(20, 10, 20, 0),                     Spacing = 10                 };                   if (Device.RuntimePlatform == Device.iOS)                 {                     contentLayout.Padding = new Thickness(20, 0, 20, 0);                 }                 Label bodyContent = new Label()                 {                     BackgroundColor = Color.Transparent,                     Text = "Enter the password to open this PDF File.",                     TextColor = Color.Black,                     FontSize = 15,                     FontFamily = "Roboto-Regular"                 };                   passwordEntry.BackgroundColor = Color.Transparent;                 passwordEntry.Text = "";                 passwordEntry.TextColor = Color.Black;                 passwordEntry.Placeholder = "Password: syncfusion";                 passwordEntry.FontSize = 15;                 passwordEntry.FontFamily = "Roboto-Regular";                 passwordEntry.Completed += OkButton_Clicked;                 passwordEntry.IsPassword = true;                 passwordEntry.TextChanged += PasswordEntry_TextChanged;                 if (Device.RuntimePlatform == Device.Android)                     passwordEntry.Margin = new Thickness(-3, 0, 0, 0);                 if (Device.RuntimePlatform == Device.iOS)                 {                     passwordEntry.MinimumHeightRequest = 40;                     passwordEntry.HeightRequest = 40;                 }                   contentLayout.Children.Add(bodyContent);                 contentLayout.Children.Add(passwordEntry);                 return contentLayout;             });                 #endregion             #region FooterTemplate             // Initialize the footer view of the PopupLayout             popup.PopupView.FooterTemplate = new DataTemplate(() =>             {             StackLayout layout = new StackLayout()             {                 Orientation = StackOrientation.Horizontal,                 Spacing = 10             };                            Button cancelButton = new Button()             {                 Text = "Cancel",                 FontSize = 15,                 TextColor = Color.FromRgb(176, 176, 176),                 FontFamily = "Roboto-Medium",                 BackgroundColor = Color.Transparent,                 MinimumWidthRequest = 80,                                HorizontalOptions = LayoutOptions.FillAndExpand                              };             if (Device.RuntimePlatform == Device.iOS)                 cancelButton.HorizontalOptions = LayoutOptions.FillAndExpand;                        cancelButton.Clicked += CancelButton_Clicked;               okButton.Text = "Ok";             okButton.FontSize = 15;             okButton.HorizontalOptions = LayoutOptions.FillAndExpand;             okButton.FontFamily = "Roboto-Medium";             okButton.Clicked += OkButton_Clicked;                        okButton.TextColor = Color.FromRgb(176, 176, 176);             okButton.BackgroundColor = Color.Transparent;                        okButton.MinimumWidthRequest = 70;             okButton.IsEnabled = true;                   if (Device.RuntimePlatform == Device.iOS)                     okButton.HorizontalOptions = LayoutOptions.FillAndExpand;                                  layout.Children.Add(cancelButton);                 layout.Children.Add(okButton);                   return layout;             }             );               #endregion               #endregion         }   Call the InitializePasswordView method in the MainPage constructor method of the MainPage class to initialize the custom password-protected view. Please refer to the following code snippet for reference. C#:   public MainPage()         {             InitializeComponent();             InitializePasswordView();         }   To load the encrypted PDF document using the custom password-protected view, you need to disable the inbuilt password-protected view by setting the `IsPasswordViewEnabled` API to `false`. You need to set the `IsPasswordViewEnabled` property and wire up the `PasswordErrorOccurred` event (to handle password errors) before loading the password-protected PDF document as follows: C#:    protected override void OnAppearing(){    base.OnAppearing();    // To disable the in-built password-protected view    pdfViewerControl.IsPasswordViewEnabled = false;    // Wire up the events to trigger when the PDF document is loaded with an invalid password or without a password    pdfViewerControl.PasswordErrorOccurred += PdfViewerControl_PasswordErrorOccurred;    pdfViewerControl.DocumentLoaded += PdfViewerControl_DocumentLoaded;}        To show the custom password-protected view in the viewport or display, call the popup.Show() API in the PdfViewerControl_PasswordErrorOccurred method as follows: C#: private void PdfViewerControl_PasswordErrorOccurred(object sender, PasswordErrorOccurredEventArgs args)         {             if (args.Title == "Error loading encrypted PDF document")             {                 if (callCount == 0)                 {                     callCount++;                    if(popup!=null)                    // To show the PopupLayout to enter the password                     popup.Show();                     isDocumentLoaded = false;                 }                               passwordEntry.Text = "";                 passwordEntry.Focus();             }         }   On execution, the custom password protected UI view will look alike follows:   Now, you can enter the password for the loaded PDF document from the text entry available in the custom password-protected view. Then, pressing the `Ok` button will reload the same PDF document with the entered password into the PDF viewer control. Please refer to the following code snippet for your reference, C#: private void OkButton_Clicked(object sender, EventArgs e)         {             if (passwordEntry.Text != "")             {                 passwordEntry.Unfocus();                 fileStream = typeof(App).GetTypeInfo().Assembly.GetManifestResourceStream("PdfViewerSample.Assets.Encrypted Document.pdf");                 pdfViewerControl.LoadDocument(fileStream, passwordEntry.Text);             }                    }   Pressing the Cancel button will close the custom password-protected view. To know about loading the password-protected PDFs in Xamarin PdfViewer, please refer to the following documentation.https://help.syncfusion.com/xamarin/pdf-viewer/loading-password-protected-pdfs Sample link:Also, please find the custom password-protected view sample from the following link: https://www.syncfusion.com/downloads/support/directtrac/general/ze/PdfViewerSample694698751.zip Note:The password used to open the password-protected PDF document provided in the sample is “Password”.
How to Remove Password in Protected WinForms PDF Using C# and VB.NET?
Syncfusion Essential PDF is a .NET PDF library used to create, read, and edit PDF documents. Using this library, you can remove a password from an encrypted PDF document using C# and VB.NET. Steps to remove a password from a protected PDF programmatically: Create a new C# console application project. Install the Syncfusion.Pdf.WinForms NuGet package as reference to your .NET Framework application from NuGet.org. Include the following namespaces in Program.cs file. C# using Syncfusion.Pdf.Parsing;   VB.NET Imports Syncfusion.Pdf.Parsing   Use the following code snippet to hide the signature field in a PDF document. C# // Load the password-protected PDF document PdfLoadedDocument loadedDocument = new PdfLoadedDocument("ProtectedDocument.pdf", "password"); // Setting permission flags to default loadedDocument.Security.Permissions = PdfPermissionsFlags.Default; // Change the user and owner passwords loadedDocument.Security.UserPassword = string.Empty; loadedDocument.Security.OwnerPassword = string.Empty; // Save the password-removed PDF document loadedDocument.Save("Output.pdf"); loadedDocument.Close(true); // This will open the PDF file so the result will be seen in the default PDF Viewer Process.Start("Output.pdf"); VB.NET ' Load the password-protected PDF document Dim loadedDocument As New PdfLoadedDocument("ProtectedDocument.pdf", "password") ' Setting permission flags to default loadedDocument.Security.Permissions = PdfPermissionsFlags.Default ' Change the user and owner passwords loadedDocument.Security.UserPassword = String.Empty loadedDocument.Security.OwnerPassword = String.Empty ' Save the password-removed PDF document loadedDocument.Save("Output.pdf") loadedDocument.Close(True) ' This will open the PDF file so the result will be seen in the default PDF Viewer Process.Start("Output.pdf") Note:To remove only the open password in a protected PDF document, just empty the user password. By executing the program, you will get the password-removed PDF document as follows. A complete working sample can be downloaded from RemovePasswordSample.zip. Take a moment to peruse the documentation, where you can find other options like encrypt PDF document, protect an existing PDF document, changing the password of the PDF document, change the permission of the PDF document and features like digitally sign a PDF document and redaction with code examples. Refer here to learn more about PDF encryption and decryption. Note:Starting with v16.2.0.x, if you reference Syncfusion® assemblies from the trial setup or the NuGet feed, include a license key in your projects. Refer to the link to learn about generating and registering the Syncfusion® license key in your application to use the components without a trial message.
Export SSRS, RDL and RDLC report with password protection
Syncfusion Report Writer allows you to protect the exported document from unauthorized users by encrypting the document using password. The following code snippet is used to initialize an RDLC report to the Report Writer.   string reportPath = @"../../ReportTemplate/Product Catalog.rdlc"; string fileName = null; WriterFormat format; ReportDataSourceCollection dataSources = new ReportDataSourceCollection(); dataSources.Add(new ReportDataSource { Name = "ProductCatalog", Value = ProductCatalogSource.GetData() }); ReportWriter reportWriter = new ReportWriter(reportPath, dataSources);   The following code snippet illustrates how to encrypt the exported document with the user password. PDF encryption reportWriter.PDFOptions = new PDFOptions(); reportWriter.PDFOptions.Security = new Syncfusion.Pdf.Security.PdfSecurity(); reportWriter.PDFOptions.Security.UserPassword = "password";   Word encryption reportWriter.WordOptions = new WordOptions(); reportWriter.WordOptions.EncryptionPassword = "password";   Excel encryption reportWriter.ExcelOptions = new ExcelOptions(); reportWriter.ExcelOptions.PasswordToOpen = "password";    PPT encryption reportWriter.PPTOptions = new PPTOptions(); reportWriter.PPTOptions.EncryptionPassword = "password";   Sample Download report writer encryption sample
How to protect a PDF with the password using C# and VB.NET?
Syncfusion Essential PDF is a .NET PDF library used to create, read, and edit PDF documents. Using this library, you can protect the PDF document using encryption and set permission to the PDF document operations like printing, editing, and copy content in C# and VB.NET. The Essential PDF supports basic to advanced encryption standards: RC4 (Rivest Cipher 4) 40-bit RC4 128-bit AES 128-bit AES 256-bit Revision 5 AES 256-bit Revision 6 (PDF 2.0)  Steps to protect PDF with password programmatically: Create a new C# console application project. Install the Syncfusion.Pdf.WinForms NuGet package as reference to your .NET Framework application from NuGet.org. Include the following namespaces in the Program.cs file. C# using Syncfusion.Pdf; using Syncfusion.Pdf.Graphics; using Syncfusion.Pdf.Security; using System.Drawing;   VB.NET Imports Syncfusion.Pdf Imports Syncfusion.Pdf.Graphics Imports Syncfusion.Pdf.Security Imports System.Drawing   Use the following code snippet to protect PDF with password. C# //Create PDF document PdfDocument document = new PdfDocument(); //Add a page in the PDF document PdfPage page = document.Pages.Add(); //Access the PDF graphics instance of the page PdfGraphics graphics = page.Graphics; //Create the PDF font instance PdfStandardFont font = new PdfStandardFont(PdfFontFamily.TimesRoman, 20f, PdfFontStyle.Bold); //PDF document security PdfSecurity security = document.Security; //Specifies encryption key size, algorithm, and permission security.KeySize = PdfEncryptionKeySize.Key256BitRevision6; security.Algorithm = PdfEncryptionAlgorithm.AES; //Customize permission in the document security.Permissions = PdfPermissionsFlags.Print | PdfPermissionsFlags.FullQualityPrint; //Provide owner and user password security.OwnerPassword = "SyncOPÜ256PDF"; security.UserPassword = "SyncUP€99PDF"; //Draw text in PDF page graphics.DrawString("Document is encrypted with AES 256 Revision 6", font, PdfBrushes.Black, PointF.Empty); //Save the document to file system document.Save("EncryptedDocument.pdf"); //Close the document document.Close(true); //This will open the PDF file so, the result will be seen in default PDF viewer Process.Start("EncryptedDocument.pdf");   VB.NET 'Create PDF document Dim document As New PdfDocument() 'Add a page in the PDF document Dim page As PdfPage = document.Pages.Add() 'Access the PDF graphics instance of the page Dim graphics As PdfGraphics = page.Graphics 'Create the PDF font instance Dim font As New PdfStandardFont(PdfFontFamily.TimesRoman, 20.0F, PdfFontStyle.Bold) 'PDF document security Dim security As PdfSecurity = document.Security 'Specifies encryption key size, algorithm, and permission security.KeySize = PdfEncryptionKeySize.Key256BitRevision6 security.Algorithm = PdfEncryptionAlgorithm.AES 'Customize permission in the document security.Permissions = PdfPermissionsFlags.Print Or PdfPermissionsFlags.FullQualityPrint 'Provide owner and user password security.OwnerPassword = "SyncOPÜ256PDF" security.UserPassword = "SyncUP€99PDF" 'Draw text in PDF page graphics.DrawString("Document is encrypted with AES 256 Revision 6", font, PdfBrushes.Black, PointF.Empty) 'Save the document to file system document.Save("EncryptedDocument.pdf") 'Close the document document.Close(True) 'This will open the PDF file so, the result will be seen in default PDF viewer Process.Start("EncryptedDocument.pdf")   Download the work sample from CreateSecurePDFSample.Zip. By executing the program, you will get the PDF document’s security settings as follows. Take a moment to peruse the documentation, where you can  find other options like protect an existing PDF document, change the password, change the permission, remove the password of the PDF document and the features like digitally sign a PDF file, and adding a timestamp in digital signature, with code examples. Refer here to explore the rich set of Syncfusion Essential PDF features. An online sample link to protect PDF file with passwords using c# Note:Starting with v16.2.0.x, if you reference Syncfusion® assemblies from the trial setup or the NuGet feed, include a license key in your projects. Refer to the link to learn about generating and registering the Syncfusion® license key in your application to use the components without a trial message. Conclusion:I hope you enjoyed learning about how to protect a PDF with the password using C# and VB.NET. You can refer to our Flutter PDF feature tour page to learn about its other groundbreaking features and documentation, and how to quickly get started with configuration specifications. You can also explore our Flutter PDF Flutter PDF examples to understand how to create and manipulate data.For current customers, you can check out our components from the License and Downloads page. If you are new to Syncfusion®, you can try our 30-day free trial to explore our other controls.If you have any queries or require clarifications, please let us know in the comments section below. You can also contact us through our support forums or feedback portal. We are always happy to assist you!
How to Open the Secured WinForms PDF File in C#, VB.NET?
Secured PDF file requires a password to open, edit, or remove the restricted operation. Syncfusion Essential® PDF is a .NET PDF Library used to create, read, and edit PDF documents. Using this library, you can open a secured PDF file using a password in C# and VB.NET with our WinForms PDF feature tour page. Steps to open a secured PDF programmatically: Create a new C# console application project. Install the Syncfusion.Pdf.WinForms NuGet package as a reference to your .NET Framework application from NuGet.org. Include the following namespace in the Program.cs file. C# using Syncfusion.Pdf.Parsing; using Syncfusion.Pdf.Security;   VB.NET Imports Syncfusion.Pdf.Parsing Imports Syncfusion.Pdf.Security   Use the following code snippet to open a secured PDF file. C# // Load the password-protected PDF document PdfLoadedDocument loadedDocument = new PdfLoadedDocument("SecuredPDF.pdf", "password"); // Change the permission loadedDocument.Security.Permissions = PdfPermissionsFlags.CopyContent | PdfPermissionsFlags.AssembleDocument; // Save the PDF document loadedDocument.Save("Security.pdf"); // Close the document loadedDocument.Close(true); // This will open the PDF file, so the result will be seen in the default PDF viewer Process.Start("Security.pdf"); VB.NET ' Load the password-protected PDF document Dim loadedDocument As New PdfLoadedDocument("SecuredPDF.pdf", "password") ' Change the permission loadedDocument.Security.Permissions = PdfPermissionsFlags.CopyContent Or PdfPermissionsFlags.AssembleDocument ' Save the PDF document loadedDocument.Save("Security.pdf") ' Close the document loadedDocument.Close(True) ' This will open the PDF file, so the result will be seen in the default PDF viewer Process.Start("Security.pdf") You can download the work sample from PDFSecuritySample.Zip. By executing the program, you will get the PDF document’s security settings as follows. Take a moment to peruse the documentation, where you will find other options like opening a corrupted PDF document, opening an existing document from a stream, opening an existing document from a byte array, saving a PDF document to a stream, saving a PDF document to the same file or stream and features like encrypt PDF document, and adding a digital signature to the PDF document with code examples.Refer here to explore the rich set of Syncfusion Essential® PDF features.An online sample link to encrypt the PDF document. Note:Starting with v16.2.0.x, if you reference Syncfusion® assemblies from the trial setup or the NuGet feed, include a license key in your projects. Refer to the link to learn about generating and registering the Syncfusion® license key in your application to use the components without a trial message.ConclusionI hope you enjoyed learning about how to open the secured WinForms PDF file in C#, VB.NET.You can refer to our WinForms PDF feature tour page to learn about its other groundbreaking feature representations and documentation, and how to quickly get started with configuration specifications. You can also explore our WinForms PDF example to understand how to create and manipulate data.For current customers, you can check out our Document processing libraries from the License and Downloads page. If you are new to Syncfusion®, you can try our 30-day free trial to check out our ASP.NET Core File Format PDF and other .NET Corcontrols.If you have any queries or require clarifications, please let us know in the comments section below. You can also contact us through our support forums or feedback portal. We are always happy to assist you!
How to secure PDF file with passwords
Syncfusion Essential&reg; PDF is a .NET PDF library used to create, read, and edit PDF documents. Using this library, you can protect the PDF document using encryption and set permission to the PDF document operations like printing, editing, and copy content in C# and VB.NET. The Essential PDF supports basic to advanced encryption standards. RC4 (Rivest Cipher 4) 40-bit RC4 128-bit AES 128-bit AES 256-bit Revision 5 AES 256-bit Revision 6 (PDF 2.0)  Steps to create secured PDF programmatically: Create a new C# console application project. Install the Syncfusion.Pdf.WinForms NuGet package as a reference to your .NET Framework application from NuGet.org. Include the following namespace in the Program.cs file. C# using Syncfusion.Pdf; using Syncfusion.Pdf.Graphics; using Syncfusion.Pdf.Security; using System.Drawing;   VB.NET Imports Syncfusion.Pdf Imports Syncfusion.Pdf.Graphics Imports Syncfusion.Pdf.Security Imports System.Drawing   Use the following code snippet to create secured PDF and encrypt it with both owner and user passwords. C# // Create PDF documentPdfDocument document = new PdfDocument();// Add a page in the PDF documentPdfPage page = document.Pages.Add();// Access the PDF graphics instance of the pagePdfGraphics graphics = page.Graphics;// Create the PDF font instancePdfStandardFont font = new PdfStandardFont(PdfFontFamily.TimesRoman, 20f, PdfFontStyle.Bold);// PDF document securityPdfSecurity security = document.Security;// Specify encryption key size, algorithm, and permissionssecurity.KeySize = PdfEncryptionKeySize.Key256BitRevision6;security.Algorithm = PdfEncryptionAlgorithm.AES;// Customize permissions in the documentsecurity.Permissions = PdfPermissionsFlags.Print | PdfPermissionsFlags.FullQualityPrint;// Provide owner and user passwordssecurity.OwnerPassword = "SyncOPÜ256PDF";security.UserPassword = "SyncUP€99PDF";// Draw text in PDF pagegraphics.DrawString("Document is encrypted with AES 256 Revision 6", font, PdfBrushes.Black, PointF.Empty);// Save the document to the file systemdocument.Save("EncryptedDocument.pdf");// Close the documentdocument.Close(true);// This will open the PDF file so the result will be seen in the default PDF viewerProcess.Start("EncryptedDocument.pdf");   VB.NET ' Create PDF documentDim document As New PdfDocument()' Add a page in the PDF documentDim page As PdfPage = document.Pages.Add()' Access the PDF graphics instance of the pageDim graphics As PdfGraphics = page.Graphics' Create the PDF font instanceDim font As New PdfStandardFont(PdfFontFamily.TimesRoman, 20.0F, PdfFontStyle.Bold)' PDF document securityDim security As PdfSecurity = document.Security' Specify encryption key size, algorithm, and permissionssecurity.KeySize = PdfEncryptionKeySize.Key256BitRevision6security.Algorithm = PdfEncryptionAlgorithm.AES' Customize permissions in the documentsecurity.Permissions = PdfPermissionsFlags.Print Or PdfPermissionsFlags.FullQualityPrint' Provide owner and user passwordssecurity.OwnerPassword = "SyncOPÜ256PDF"security.UserPassword = "SyncUP€99PDF"' Draw text in PDF pagegraphics.DrawString("Document is encrypted with AES 256 Revision 6", font, PdfBrushes.Black, PointF.Empty)' Save the document to the file systemdocument.Save("EncryptedDocument.pdf")' Close the documentdocument.Close(True)' This will open the PDF file so the result will be seen in the default PDF viewerProcess.Start("EncryptedDocument.pdf")   Download the work sample from CreateSecurePDFSample.Zip. By executing the program, you will get the PDF document’s security settings as follows. Take a moment to peruse the documentation, where you can  find other options like protect an existing PDF document, change the  password, change the permission, remove the password of the PDF document and the features like digitally sign a PDF file, and adding a timestamp in digital signature, with code examples. Refer here to explore the rich set of Syncfusion Essential&reg; PDF features. An online sample link to secure PDF file with passwords. Note:Starting with v16.2.0.x, if you reference Syncfusion&reg; assemblies from a trial setup or from the NuGet feed, include a license key in your projects. Refer to the link to learn about generating and registering the Syncfusion&reg; license key in your application to use the components without a trial message. ConclusionI hope you enjoyed learning about how to secure PDF file with passwords.You can refer to our WinForms PDF’s feature tour page to know about its other groundbreaking feature representations. You can also explore our WinForms PDF documentation to understand how to present and manipulate data.For current customers, you can check out our WinForms components from the License and Downloads page. If you are new to Syncfusion, you can try our 30-day free trial to check out our WinForms PDF and other WinForms components.If you have any queries or require clarifications, please let us know in comments below. You can also contact us through our support forums, Direct-Trac, or feedback portal. We are always happy to assist you!
No articles found
No articles found
1 of 1 pages (9 items)