ByteScout PDF SDK - VB.NET - Signing for PDF - 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 PDF SDK – VB.NET – Signing for PDF

  • Home
  • /
  • Articles
  • /
  • ByteScout PDF SDK – VB.NET – Signing for PDF

ByteScout PDF SDK – VB.NET – Signing for PDF

Program.vb

Imports System.Drawing
Imports Bytescout.PDF

''' <summary>
''' This example demonstrates how to digitally sign PDF document.
''' </summary>
Class Program

	Shared Sub Main()

		' Create new document
		Dim pdfDocument = New Document()
		pdfDocument.RegistrationName = "demo"
		pdfDocument.RegistrationKey = "demo"
		' Add page
		Dim page = New Page(PaperFormat.A4)
		pdfDocument.Pages.Add(page)

		' Add sample page content
		Dim brush = New Bytescout.PDF.SolidBrush()
		Dim font = New Bytescout.PDF.Font("Arial", 16)
		Dim rect = New RectangleF(0, 50, page.Width, 100)
		Dim stringFormat = New Bytescout.PDF.StringFormat()
		stringFormat.HorizontalAlign = HorizontalAlign.Center
		page.Canvas.DrawString("Signature Test", font, brush, rect, stringFormat)

		' Signing parameters
		Dim certficateFile = ".\demo_certificate.pfx"
		Dim certficatePassword = "123"
		' Optional parameters
		Dim signingReason = "Approval"
		Dim contactName = "John Smith"
		Dim location = "Corporate HQ"

		' Invisible signature
		'pdfDocument.Sign(certficateFile, certficatePassword)

		' Visible signature
		Dim 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 document in default PDF viewer application
		Process.Start("result.pdf")

	End Sub

End Class


  Click here to get your Free Trial version of the SDK

Tutorials:

prev
next