ByteScout Premium Suite - C# - Sign pdf and set security with pdf sdk - ByteScout
Announcement
Our ByteScout SDK products are sunsetting as we focus on expanding new solutions.
Learn More Open modal
Close modal
Announcement Important Update
ByteScout SDK Sunsetting Notice
Our ByteScout SDK products are sunsetting as we focus on our new & improved solutions. Thank you for being part of our journey, and we look forward to supporting you in this next chapter!

ByteScout Premium Suite – C# – Sign pdf and set security with pdf sdk

  • Home
  • /
  • Articles
  • /
  • ByteScout Premium Suite – C# – Sign pdf and set security with pdf sdk

How to sign pdf and set security with pdf sdk in C# using ByteScout Premium Suite

Continuous learning is a crucial part of computer science and this tutorial shows how to sign pdf and set security with pdf sdk in C#

Every ByteScout tool includes simple example C# source codes that you can get here or in the folder with installed ByteScout product. ByteScout Premium Suite: the set that includes 12 SDK products from ByteScout including tools and components for PDF, barcodes, spreadsheets, screen video recording. It can sign pdf and set security with pdf sdk in C#.

This prolific sample source code in C# for ByteScout Premium Suite contains various functions and other necessary options you should do calling the API to sign pdf and set security with pdf sdk. Just copy and paste the code into your C# application’s code and follow the instructions. This basic programming language sample code for C# will do the whole work for you to sign pdf and set security with pdf sdk.

Trial version of ByteScout Premium Suite is available for free. Source code samples are included to help you with your C# app.

On-demand (REST Web API) version:
 Web API (on-demand version)

On-premise offline SDK for Windows:
 60 Day Free Trial (on-premise)

Program.cs
      
using System.Diagnostics; using System.Drawing; using Bytescout.PDF; using Font = Bytescout.PDF.Font; using SolidBrush = Bytescout.PDF.SolidBrush; using StringFormat = Bytescout.PDF.StringFormat; namespace Signing { /// <summary> /// This example demonstrates how to digitally sign PDF document. /// </summary> class Program { static void Main() { // Create new document Document pdfDocument = new Document(); pdfDocument.RegistrationName = "demo"; pdfDocument.RegistrationKey = "demo"; // Add page Page page = new Page(PaperFormat.A4); pdfDocument.Pages.Add(page); // Add sample page content SolidBrush brush = new SolidBrush(); Font font = new Font("Arial", 16); RectangleF rect = new RectangleF(0, 50, page.Width, 100); StringFormat stringFormat = new StringFormat(); stringFormat.HorizontalAlign = HorizontalAlign.Center; page.Canvas.DrawString("Signature Test", font, brush, rect, stringFormat); // Signing parameters string certficateFile = ".\\demo_certificate.pfx"; string certficatePassword = "123"; // Optional parameters string signingReason = "Approval"; string contactName = "John Smith"; string location = "Corporate HQ"; // Invisible signature //pdfDocument.Sign(certficateFile, certficatePassword); // Visible signature RectangleF signatureRect = new RectangleF(400, 50, 150, 100); pdfDocument.Sign(certficateFile, certficatePassword, signatureRect, signingReason, contactName, location); // 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); } } }

ON-PREMISE OFFLINE SDK

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

ON-DEMAND REST WEB API

Get Your API Key

Explore Web API Docs

Explore Web API Samples

VIDEO

ON-PREMISE OFFLINE SDK

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

ON-DEMAND REST WEB API

Get Your API Key

Explore Web API Docs

Explore Web API Samples

Tutorials:

prev
next