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