Hello,
Thanks for your reply.
Please refer to the following method to add a digital signature.
- 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));
}
}
If your issue still exists, please provide us with the following information for further investigation.
1) Your input file and data (if any)
2) The code and the verion of Spire.Pdf that you are using
3) Your environment, such as OS information (E.g. Windows 10, 64 bit) and region settings (E.g. China, Chinese)
4) Your application type, such as Console app (. Net Framework 4.5) or springboot (JDK8)
Sincerely,
William
E-iceblue support team