I'm using iText7 to sign a pdf with a timestamp from a TSA. I use this little piece of code:
using (PdfReader reader = new PdfReader(pdf_filename))
{
using (FileStream output = new FileStream($"dts_{pdf_filename}", FileMode.Create))
{
PdfSigner signer = new PdfSigner(reader, output, new StampingProperties());
signer.SetFieldName("SignatureField");
var tsa_client = new TSAClientBouncyCastle(Config.TSA_URL, null, null, 8192, "sha256");
signer.Timestamp(tsa_client, "SignatureTimeStamp");
}
}
The timestamp gets added, valid and working.
But I'm trying to make that timestamp visible with no results.
I tried signer.GetSignatureAppearance()
and then set the page, reason and a few more data, but the timestamp is invisible every time.
How can I make it visible?
I tried setting an appearance with signer.GetSignatureAppearance()
but no matter what changes make there, nothing appear.
I didn't try mucho more than that and reading the api reference which states the following:
If you create new signature field (either use SetFieldName(System.String) with the name that doesn't exist in the document or don't specify it at all) then the signature is invisible by default.
But i'm really unsure how to use that information.
For a signature to have a visualization in the document, you have to set the page area where that visualization shall appear.
You already have retrieved the associated PdfSignatureAppearance
object using signer.GetSignatureAppearance()
. Use the SetPageRect
method of that object to set the page area for the visualization.