使用itext Sharp将流数据添加到签名字典中

时间:2015-05-27 17:25:19

标签: pdf itextsharp

我想在签名字典中包含某种私人信息(当然,不会使签名无效)。我想我必须将它包含在PDFName.CONTENTS条目中(因为签名不包含内容),但是我在这里搞砸了,我无法进步。

简单地说,我得到下一个代码:

PdfReader reader = new PdfReader(pdfOrigen);
FileStream os = new FileStream(pdfDestino, FileMode.Create);
PdfStamper stamper = PdfStamper.CreateSignature(reader, os, '\0', null, true);

PdfSignatureAppearance appearance = stamper.SignatureAppearance;
appearance.Reason = razon;
appearance.Location = localizacion;


IExternalSignature pks = new    X509Certificate2Signature(pk,DigestAlgorithms.SHA1); 
MakeSignature.SignDetached(appearance, pks, chain, crlList, ocspClient, tsaClient, 0, CryptoStandard.CMS);

///this doesn't works             
PdfDictionary sv = new PdfDictionary();
sv.Put(PdfName.CONTENTS, new PdfName("MyPrivateData"));

我知道还有一些内容可以将其包含在PDF中,但我不知道是什么。 我甚至得到了AcroField签名,但我不知道如何将PdfDictionay放入其中:

AcroFields acroFields = new    PdfReader(pdfOrigen).AcroFields;
List<string> names = acroFields.GetSignatureNames();


foreach (var name in names)
{
PdfDictionary dict = acroFields.GetSignatureDictionary(name); 
}

有任何线索吗?

0 个答案:

没有答案