Spire.PDF is a professional PDF library applied to creating, writing, editing, handling and reading PDF files without any external dependencies. Get free and professional technical support for Spire.PDF for .NET, Java, Android, C++, Python.

Mon Nov 01, 2021 1:50 pm

Hello,

I am new to Spire.PDF and was wondering if the following scenario is possible:

I have a specific text on my .pdf that gives me the information where I should put the Signature template.
E.g. "Signature Field" is the text and is placed in the middle of the document. (see picture)

Is it now possible to search for "Signature Field:", identify its coordinates, and then create a new signature template and place it below the "Signature Field:" Text based on the coordinates of the Signature field? (see picture)

The advantage would be that I do not have to identify the coordinates by my own but could just define a certain "keyword", identify it's coordinates and add maybe +10 in the PosY and then have the place identified where I want to place my signature.

Thank you for your help.
Last edited by MichelFreek1 on Tue Nov 02, 2021 12:48 pm, edited 1 time in total.

MichelFreek1
 
Posts: 1
Joined: Mon Nov 01, 2021 1:26 pm

Tue Nov 02, 2021 2:25 am

Hello Michel,

Thanks for your interest in our Spire.PDF.
Here are the links to download our Spire.PDF:
Our website link: https://www.e-iceblue.com/Download/download-pdf-for-net-now.html
NuGet link:https://www.nuget.org/packages/Spire.PDF

It appears that the pictures you attached here are not visible, could you please re-attach again?
According to your description, please refer to the following code for your requirement.
Code: Select all
   PdfDocument pdfDoc = new PdfDocument();
            pdfDoc.LoadFromFile("C:/sample.pdf");
            PdfPageBase page = pdfDoc.Pages[0];
            PdfTextFind find = page.FindText("Signature Field:", TextFindParameter.None).Finds[0];
            //The x coordinate value
            float x = find.Position.X;
            //The y coordinate value
            float y = find.Position.Y;

            PdfSignatureField signField = new PdfSignatureField(page, "digitalSignatureField");
            signField.Bounds = new System.Drawing.RectangleF(x, y + 10, 150, 100);

            pdfDoc.AllowCreateForm = true;
           
            pdfDoc.Form.Fields.Add(signField);

            pdfDoc.SaveToFile("C:/template.pdf");


Sincerely,
Amy
E-iceblue support team
User avatar

amy.zhao
 
Posts: 2767
Joined: Wed Jun 27, 2012 8:50 am

Wed Nov 03, 2021 9:49 am

Hello Michel,

Does the above code work for you?
I'm looking forward to your feedback.

Sincerely,
Amy
E-iceblue support team
User avatar

amy.zhao
 
Posts: 2767
Joined: Wed Jun 27, 2012 8:50 am

Return to Spire.PDF