Spire.Doc is a professional Word .NET library specifically designed for developers to create, read, write, convert and print Word document files. Get free and professional technical support for Spire.Doc for .NET, Java, Android, C++, Python.

Sun Mar 17, 2024 10:37 pm

How can I add multiple signatures one after another on a document? (at the end of each document the signatures are inserted one by one, and if the page is full, a new page is added and the rest are added on it)

Johnmc13
 
Posts: 8
Joined: Fri Sep 24, 2021 8:11 am

Mon Mar 18, 2024 8:40 am

Hello,

Thanks for your inquiry.
Sorry, our Spire Doc currently does not support adding multiple signatures to Word files.

Sincerely,
William
E-iceblue support team
User avatar

William.Zhang
 
Posts: 732
Joined: Mon Dec 27, 2021 2:23 am

Mon Mar 18, 2024 11:11 am

I'm using Spire PDF

Johnmc13
 
Posts: 8
Joined: Fri Sep 24, 2021 8:11 am

Tue Mar 19, 2024 8:18 am

Hello,

Thanks for your reply.
Please refer to the following code to add multiple signatures to the PDF file. If you have any questions, please feel free to write to us at any time.
Code: Select all
String inputFile = @"test.pdf";
String outputFile = @"res.pdf";
String inputFile_Pfx = @"gary.pfx";

PdfDocument doc = new PdfDocument();
doc.LoadFromFile(inputFile);
X509Certificate2 x509 = new X509Certificate2(inputFile_Pfx, "e-iceblue");
PdfOrdinarySignatureMaker signatureMaker = new PdfOrdinarySignatureMaker(doc, x509);
PdfCustomSignatureAppearance pdfCustomSignatureAppearance = new PdfCustomSignatureAppearance();

for (int i = 0; i < doc.Pages.Count; i++)
{
    signatureMaker.MakeSignature("signName_" + (i + 1), doc.Pages[i], 100, 100, 250, 200, pdfCustomSignatureAppearance);
}

doc.SaveToFile(outputFile, FileFormat.PDF);
doc.Close();
public class PdfCustomSignatureAppearance : IPdfSignatureAppearance
{
    public void Generate(PdfCanvas g)
    {
        float x = 2;
        float y = 2;
        float fontSize = 10;
        PdfTrueTypeFont font = new PdfTrueTypeFont(new Font("Arabic", fontSize), true);
        float lineHeight = fontSize;
        g.DrawString("التوقيع الرقمي: مرحبا ", font, PdfBrushes.Red, new PointF(x, y));
        y += lineHeight;
        g.DrawString("التوقيع الرقمي: مرحبا", font, PdfBrushes.Red, new PointF(x, y));

    }
}

Sincerely,
William
E-iceblue support team
User avatar

William.Zhang
 
Posts: 732
Joined: Mon Dec 27, 2021 2:23 am

Tue Mar 19, 2024 2:52 pm

I still have same issue and i attach my problem.
also i don't want show my signature in all pages. i want all signatures listed in a row.
for example i have a document that 10 people should sign that. The signatures must be in the following order. And when the page had no place to show signature. Create a new page and put the rest of the signatures there.
Thanks

Johnmc13
 
Posts: 8
Joined: Fri Sep 24, 2021 8:11 am

Wed Mar 20, 2024 6:37 am

Hello,
Thanks for your feedback.
For the font issue, please modify the code in the PdfCustomimSignatureAppearance class as follows.
Code: Select all
public class PdfCustomSignatureAppearance : IPdfSignatureAppearance
{
    public void Generate(PdfCanvas g)
    {
        float x = 2;
        float y = 2;
        float fontSize = 14;
        PdfTrueTypeFont font = new PdfTrueTypeFont(new Font("Arial", 14f), true);
        float lineHeight = fontSize;
        PdfStringFormat pdfStringFormat = new PdfStringFormat();
        pdfStringFormat.RightToLeft = true;
        g.DrawString("التوقيع الرقمي: مرحبا ", font, PdfBrushes.Red, new PointF(x, y),pdfStringFormat);
        y += lineHeight;
        g.DrawString("التوقيع الرقمي: مرحبا", font, PdfBrushes.Red, new PointF(x, y), pdfStringFormat);
    }
}


For the issue of adding multiple signatures, we can add multiple signatures on the PDF page and display them in different positions by modifying their coordinates, as shown in the following code. However, for your needs, as the content of the PDF can actually overlap, there is currently no way to determine whether there is still a space on the current page where signatures can be placed. Hope you can understand.
Code: Select all
String inputFile = @"test.pdf";
String outputFile = @"res.pdf";
String inputFile_Pfx = @"gary.pfx";
PdfDocument doc = new PdfDocument();
doc.LoadFromFile(inputFile);
X509Certificate2 x509 = new X509Certificate2(inputFile_Pfx, "e-iceblue");
PdfOrdinarySignatureMaker signatureMaker = new PdfOrdinarySignatureMaker(doc, x509);
PdfCustomSignatureAppearance pdfCustomSignatureAppearance = new PdfCustomSignatureAppearance();
float x = 10;
float y = 50;
float width = 200;
float height = 100;
for (int i = 0; i < 3; i++)
{
    signatureMaker.MakeSignature("signName_" + (i + 1), doc.Pages[0], x, y, width, height, pdfCustomSignatureAppearance);
    x = x + width + 20;         
}
doc.SaveToFile(outputFile, FileFormat.PDF);
doc.Close();


Sincerely,
William
E-iceblue support team
User avatar

William.Zhang
 
Posts: 732
Joined: Mon Dec 27, 2021 2:23 am

Return to Spire.Doc