在PDF上创建签名字段iTextSharp。用户签名后如何自动保存PDF

问题描述 投票:1回答:1

我用iTextSharp 5.5.13创建了pdf。我在PDF上有签名字段,我需要当用户在签名字段上签名时,PDF会自动保存在特定的路径上(例如 "c:signedpdf11.pdf")。我需要当用户在签名字段上签名时,pdf将自动保存在特定的路径上(例如 "c:signedpdf11.pdf")。这可能吗?

我的代码。

PdfFormField field = PdfFormField.CreateSignature(pdfWriter);
field.SetWidget(new iTextSharp.text.Rectangle(x1, y1, x2, y2), PdfAnnotation.HIGHLIGHT_NONE);
field.FieldName = name;
field.Flags = PdfAnnotation.FLAGS_PRINT;
field.SetPage();
field.MKBorderColor = iTextSharp.text.BaseColor.BLACK;
field.MKBackgroundColor = iTextSharp.text.BaseColor.LIGHT_GRAY;

PdfAppearance tp1 = PdfAppearance.CreateAppearance(pdfWriter, width, height);
tp1.Rectangle(0.5f, 0.5f, width - 0.5, height - 0.5);
tp1.Stroke();
field.SetAppearance(PdfAnnotation.APPEARANCE_NORMAL, tp1);
pdfWriter.AddAnnotation(field);
c# itext pdf-generation digital-signature
1个回答
0
投票

相当奇怪的设置,但确定让我们看看。你要找的所谓事件是(我假设)用户将签名文件保存到某个网络文件夹中。

写一个程序,检查网络文件夹的内容是否有新文件。如果有一个文件,加载它并检查它是否已经被签署。如果有的话,就把它保存到你想要的路径上。

有很多例子说明如何检查一个文件是否已经被签署,例如 这里.

© www.soinside.com 2019 - 2024. All rights reserved.