We made thousands of pre-made source code pieces for easy implementation in your own programming projects. ByteScout Premium Suite is the set that includes 12 SDK products from ByteScout including tools and components for PDF, barcodes, spreadsheets, screen video recording. It can add passwords and permissions in pdf with pdf sdk in C#.
The following code snippet for ByteScout Premium Suite works best when you need to quickly add passwords and permissions in pdf with pdf sdk in your C# application. This C# sample code is all you need for your app. Just copy and paste the code, add references (if needs to) and you are all set! Use of ByteScout Premium Suite in C# is also described in the documentation included along with the product.
If you want to try other source code samples then the free trial version of ByteScout Premium Suite is available for download from our website. Just try other source code samples for C#.
On-demand (REST Web API) version:
Web API (on-demand version)
On-premise offline SDK for Windows:
60 Day Free Trial (on-premise)
using System.Diagnostics; using Bytescout.PDF; namespace PasswordsAndPermissions { /// <summary> /// This example demonstrates how to lock the document with a password. /// PDF format supports two kinds of passwords: owner and user password. /// User password allows to view document and perform allowed actions. /// Owner password allows everything, including changing passwords and permissions. /// </summary> class Program { static void Main() { // Create new document Document pdfDocument = new Document(); pdfDocument.RegistrationName = "demo"; pdfDocument.RegistrationKey = "demo"; // Add page pdfDocument.Pages.Add(new Page(PaperFormat.A4)); // Set document encryption algorythm pdfDocument.Security.EncryptionAlgorithm = EncryptionAlgorithm.RC4_40bit; // Set various user permissions pdfDocument.Security.AllowPrintDocument = false; pdfDocument.Security.AllowContentExtraction = false; pdfDocument.Security.AllowModifyAnnotations = false; pdfDocument.Security.PrintQuality = PrintQuality.LowResolution; // Set owner password pdfDocument.Security.OwnerPassword = "ownerpassword"; // Set user password pdfDocument.Security.UserPassword = "userpassword"; // Save document to file pdfDocument.Save("result.pdf"); // Cleanup pdfDocument.Dispose(); // Open result document in default associated application (for demo purpose) ProcessStartInfo processStartInfo = new ProcessStartInfo("result.pdf"); processStartInfo.UseShellExecute = true; Process.Start(processStartInfo); } } }
60 Day Free Trial or Visit ByteScout Premium Suite Home Page
Explore ByteScout Premium Suite Documentation
Explore Samples
Sign Up for ByteScout Premium Suite Online Training
Get Your API Key
Explore Web API Docs
Explore Web API Samples
60 Day Free Trial or Visit ByteScout Premium Suite Home Page
Explore ByteScout Premium Suite Documentation
Explore Samples
Sign Up for ByteScout Premium Suite Online Training
Get Your API Key
Explore Web API Docs
Explore Web API Samples
also available as: