We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

How can use SignaturePad

Hello everyone! I'm currently exploring the integration between the Syncfusion SfSignaturePad widget and the ability to add signatures to PdfSignatureField fields within PDF documents. However, if direct embedding isn't feasible, I'm interested in understanding whether there's a way to retrieve the coordinates of this PdfSignatureField field, allowing me to replace it with an image containing the signature captured by the SfSignaturePad. Could anyone share an example or provide guidance on how I could approach this situation? I appreciate your help in advance




1 Reply

RB Ravikumar Baladhandapani Syncfusion Team August 16, 2023 03:59 PM UTC

We can add an image in a signature field in two ways, draw the image in the signature field appearance or draw the image directly to page graphics with signature field bounds. Please refer the below code snippet,


            //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;

 

         

            //Load image

            PdfBitmap image = new PdfBitmap("../../Data/logo.png");

 

            //Save the graphics state

            PdfGraphicsState state = field.Signature.Appearance.Normal.Graphics.Save();

 

            //Insert an image in the signature appearance

            field.Signature.Appearance.Normal.Graphics.DrawImage(image, new RectangleF(0, 0, field.Bounds.Width, field.Bounds.Height));

 

            //Restore the graphics state

            field.Signature.Appearance.Normal.Graphics.Restore();

 

            //Save and close the document

            loadedDocument.Save("Sample.pdf");

            loadedDocument.Close(true);

 


(Or)

           //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;

 

 

            //Load image

            PdfBitmap image = new PdfBitmap("../../Data/logo.png");

 

            page.Graphics.DrawImage(image, field.Bounds);           

 

            //Save and close the document

            loadedDocument.Save("Sample.pdf");

            loadedDocument.Close(true);


Kindly try the above solution and let us know, if you need any further assistance on this.


Loader.
Live Chat Icon For mobile
Up arrow icon