Digital Signature, customize "sign by" text

From my sandbox test, signing a signature field with Aspose places the following text into the signature field:

Digitally Signed by “CN=xyz, OU=abc, OU=pki…”
Date: yyyy-mm-dd…

I am looking to be able to customize the “sign by” field so it reads something like:

Digitally Signed by “My Real Name”
Date:yyyy-mm-dd…

I am aware of this post from 2011 asking the same question: Digitally Sign PDF Document - Add Custom Image/Text to PDF Signature
It’s been 12 years since and I am wondering if there is a way now to set the text without having to draw a new image from scratch?

thank you!

@hao.deng

We have introduced CustomAppearance property for signatures. Have you tried it? Can you please share the complete code snippet and source files so that we can try to test the scenario in our environment and address it accordingly.

hello, thank you for your pointer. I follow your direction and played around with the CustomAppearence property. I did not find the text at first, but after you mentioned it I played around with DigitalSubjectFormat. I set the SubjectElementNames value to empty array, and put the text I want entirely in the DigitalSignedLabel property. This kind of achieves my goal but with 1 imperfection: It ends the label with a pair of quotes that was meant for the subject line which is now empty (see screenshot).

This is close enough to what I want. I am good with it. But if there’s more I can do to remove the quotes it’s even better.

thanks
asposepdf-sig.PNG (4.3 KB)

@hao.deng

Would you kindly share your sample document along with the complete code snippet that you used to generate the output? We will test the scenario in our environment and address it accordingly.

Here’s my C# code. It’s nothing special, borrowed and adapted from the official tutorial:

var fileName = "mydoc";
var sigName = "ReviewerSig";
using (Document document = new Document(($"{fileName}.pdf")))
{
	using (PdfFileSignature signature = new PdfFileSignature(document))
	{
		PKCS7 pkcs = new PKCS7(@"cert.pfx", "password");
		SignatureCustomAppearance appearance = new SignatureCustomAppearance()
		{
			FontSize = 7,
			UseDigitalSubjectFormat = true,
			BackgroundColor = Color.AliceBlue,
			DigitalSubjectFormat = new SubjectNameElements[] { },
			DigitalSignedLabel = $"Digitally signed by My Real Name",
			ShowContactInfo = false,
			ShowLocation = false,
			ShowReason = false
		};
		pkcs.CustomAppearance = appearance;
		signature.Sign(sigName, pkcs);
		signature.Save($"{fileName}_out2.pdf");
	}
}

@hao.deng

Thanks for sharing the code snippet. Would it be possible for you to share sample document and the PFX file as well? It would help us in investigating the scenario accordingly with the same files.

hello, thank you for continuing to follow up. Really appreciate it! Here is a visual studio solution I created to demonstrate the issue I encounter. Please check out.

AsposePDFEval.zip (152.6 KB)

@hao.deng

We have opened the following new ticket(s) in our internal issue tracking system and will deliver their fixes according to the terms mentioned in Free Support Policies.

Issue ID(s): PDFNET-54845

You can obtain Paid Support Services if you need support on a priority basis, along with the direct access to our Paid Support management team.