使用 iTextSharp 自定义 PDFStamper
我正在使用 iTextSharp 签署 PDF。签名时,它会在文档上标记 4 个字段:签名者、时间、原因和地点。我的意思是在下面(或上面,这并不重要)添加一个包含自定义信息的字段。
有什么想法吗?
这是我生成邮票的代码:
PdfStamper stp = PdfStamper.CreateSignature(reader, memoryOut, '\0');
PdfSignatureAppearance sap = stp.SignatureAppearance;
iTextSharp.text.Rectangle rectangle = new iTextSharp.text.Rectangle(100, 100, 500, 200);
sap.SetVisibleSignature(rectangle, stp.Reader.NumberOfPages, null);
sap.SignDate = DateTime.Now;
sap.SetCrypto(null, chain, null, null);
sap.Reason = ssReason;
sap.Contact = ssContact;
sap.Location = ssLocation;
sap.Acro6Layers = true;
//sap.SignatureGraphic = iTextSharp.text.Image.GetInstance(ssImageUrl);
//sap.SignatureGraphic.ScaleToFit(131, 45);
sap.Render = PdfSignatureAppearance.SignatureRender.Description;
I'm using iTextSharp to sign PDFs. When signing, it stamps the document with 4 fields: who signed, when, reason and location. What I meant to do is to add a field below (or above, that doesn't matter) with custom information.
Any Idea?
Here's my code that is generating the stamp:
PdfStamper stp = PdfStamper.CreateSignature(reader, memoryOut, '\0');
PdfSignatureAppearance sap = stp.SignatureAppearance;
iTextSharp.text.Rectangle rectangle = new iTextSharp.text.Rectangle(100, 100, 500, 200);
sap.SetVisibleSignature(rectangle, stp.Reader.NumberOfPages, null);
sap.SignDate = DateTime.Now;
sap.SetCrypto(null, chain, null, null);
sap.Reason = ssReason;
sap.Contact = ssContact;
sap.Location = ssLocation;
sap.Acro6Layers = true;
//sap.SignatureGraphic = iTextSharp.text.Image.GetInstance(ssImageUrl);
//sap.SignatureGraphic.ScaleToFit(131, 45);
sap.Render = PdfSignatureAppearance.SignatureRender.Description;
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
几个选项:
修改
sap.getLayer(int)
中的PdfTemplate
之一。调用
sap.setLayer2Text()
以包含您的额外信息。使用图形。您可以将
PdfTemplate
包装在Image
中,这样您就可以绘制任何您想要的内容。然后sap.Render = PdfSignatureAppearance.SignatureRender.GraphicAndDescription
破解源代码。
Several options:
modify one of the
PdfTemplate
s fromsap.getLayer(int)
.call
sap.setLayer2Text()
to include your extra information.Use a graphic. You can wrap a
PdfTemplate
in anImage
, so you can draw anything you want. Thensap.Render = PdfSignatureAppearance.SignatureRender.GraphicAndDescription
Hack The Source.