Posted 1 May 2025, 2:16 pm EST
Hi
We are currently using your namespace C1.C1Pdf.
For each C1Page from the C1PrintDocument, we create an Image, add that Image as a PDF page in the C1PdfDocument, and include a PdfSignature with the logo and certificate.
When migrating to the new namespace C1.Pdf, we can no longer add System.Drawing.Image, but instead, we must use GrapeCity.Documents.Drawing.Image.
Do you perhaps have a better approach on how to create a PDF document from C1PrintDocument with an X509Certificate2?
Attached is the source of our current procedure.
Looking forward to your response.
public bool SignPDF(string fileNameWithPath,
X509Certificate2 cetificate,
RectangleF location,
Image signatureLogo)
{
C1PdfDocument c1PdfDocument1 = new();
foreach (C1Page page in _doc.Pages)
{
Image img = page.AsMetafile();
c1PdfDocument1.DrawImage(img, c1PdfDocument1.PageRectangle);
PdfSignature signature = new()
{
Reason = "Signature",
Certificate = cetificate,
Visibility = FieldVisibility.Visible,
Handler = SignatureHandler.PPKLite
};
signature.BorderWidth = FieldBorderWidth.Thin;
signature.BorderColor = Color.Gray;
signature.BackColor = Color.DarkGray;
signature.Image = signatureLogo;
c1PdfDocument1.AddField(signature, location);
}
c1PdfDocument1.Save(fileNameWithPath);
return true;
}