Articles in this section

How to add rotated string and image in digital signature appearance using C# and VB.NET?

The Syncfusion Essential® PDF is a feature-rich and high-performance .NET PDF library that is used to create, read, and edit PDF documents programmatically without Adobe dependencies. Using this library, you can add the rotated string and image in digital signature appearance using C# and VB.NET.

Steps to add the rotated string and image in digital signature appearance using C# and VB.NET programmatically

1. Create a new C# console application project.

Create console application.

2. Install the Syncfusion.PDF.WinForms NuGet packages as a reference to your .NET Framework application from NuGet.org.

Install NuGet packages.

3. Include the following namespaces in the Program.cs file.

C#

using Syncfusion.Pdf;
using Syncfusion.Pdf.Graphics;
using Syncfusion.Pdf.Parsing;
using Syncfusion.Pdf.Security;

 

VB.NET

Imports Syncfusion.Pdf
Imports Syncfusion.Pdf.Graphics
Imports Syncfusion.Pdf.Parsing
Imports Syncfusion.Pdf.Security

 

4. The following code example shows how to add the rotated string and image in a digital signature appearance using C#.

C#

           //Loads a PDF document
            PdfLoadedDocument loadedDocument = new PdfLoadedDocument("../../Data/Form1.pdf");
 
            //Gets the first page of the document
            PdfLoadedPage page = loadedDocument.Pages[0] as PdfLoadedPage;
 
            //Gets the first signature field of the PDF document
            PdfLoadedSignatureField field = loadedDocument.Form.Fields[0] as PdfLoadedSignatureField;
 
            //Creates a certificate
            PdfCertificate certificate = new PdfCertificate("../../Data/PDF.pfx", "syncfusion");
            field.Signature = new PdfSignature(loadedDocument, page, certificate, "Signature", field);
 
            //Load image 
            PdfBitmap image = new PdfBitmap("../../Data/logo.png");
 
            //Save the graphics state 
            PdfGraphicsState state = field.Signature.Appearance.Normal.Graphics.Save();
 
            //Rotate the graphics 
            field.Signature.Appearance.Normal.Graphics.TranslateTransform(image.Height, image.Width);
            field.Signature.Appearance.Normal.Graphics.RotateTransform(-90);
 
            //Insert an image in the signature appearance 
            field.Signature.Appearance.Normal.Graphics.DrawImage(image, new RectangleF(0, 0, image.Width, image.Height));
 
            //Restore the graphics state 
            field.Signature.Appearance.Normal.Graphics.Restore();
 
            //Save and close the document 
            loadedDocument.Save("Sample.pdf");
            loadedDocument.Close(true);
 
            Process.Start("Sample.pdf");

 

VB.NET

     'Loads a PDF document
        Dim loadedDocument As PdfLoadedDocument = New PdfLoadedDocument("../../Data/Form1.pdf")
        'Gets the first page of the document
        Dim page As PdfLoadedPage = TryCast(loadedDocument.Pages(0), PdfLoadedPage)
        'Gets the first signature field of the PDF document
        Dim field As PdfLoadedSignatureField = TryCast(loadedDocument.Form.Fields(0), PdfLoadedSignatureField)
        'Creates a certificate
        Dim certificate As PdfCertificate = New PdfCertificate("../../Data/PDF.pfx", "syncfusion")
        field.Signature = New PdfSignature(loadedDocument, page, certificate, "Signature", field)
        'Load image 
        Dim image As PdfBitmap = New PdfBitmap("../../Data/logo.png")
        'Save the graphics state 
        Dim state As PdfGraphicsState = field.Signature.Appearance.Normal.Graphics.Save()
        'Rotate the graphics 
        field.Signature.Appearance.Normal.Graphics.TranslateTransform(image.Height, image.Width)
        field.Signature.Appearance.Normal.Graphics.RotateTransform(-90)
 
        'Insert an image in the signature appearance 
        field.Signature.Appearance.Normal.Graphics.DrawImage(image, New RectangleF(0, 0, image.Width, image.Height))
 
        'Restore the graphics state 
        field.Signature.Appearance.Normal.Graphics.Restore()
 
        'Save And close the document 
        loadedDocument.Save("Sample.pdf")
        loadedDocument.Close(True)
 
        Process.Start("Sample.pdf")
 

 

By executing the program, you will get the PDF document as follows.

Output screenshot

A complete working sample can be downloaded from DigitalSignatureSample.zip.

Refer to here to explore a rich set of Syncfusion Essential® PDF features.

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.

 

See Also:

Working with digital signature

How to digitally sign an existing PDF document

How to remove the digital signature from an existing PDF

How to digitally sign a PDF file in C#, VB.NET

How to create the PDF digital signature with custom appearance

How to digitally sign PDF using X509Certificate2 in C# and VB.NET


Conclusion:

I hope you enjoyed learning about how to add rotated string and image in digital signature appearance 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!

Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments (0)
Access denied
Access denied