我正在使用iTextSharp签署pdf文档。它工作正常,但我想保护该文件,我希望该pdf签名不能再次打印,复制或签名,该怎么办?
我尝试过
PdfEncryptor.Encrypt(
reader,
new FileStream(this.outputPDF, FileMode.Create, FileAccess.Write),
true,
null,
null,
PdfWriter.AllowFillIn | PdfWriter.AllowScreenReaders);
但是不起作用,它说
iTextSharp.text.DocumentException:'原始文档已被重用。从文件中再次读取。'
public void Sign(string SigReason, string SigContact, string SigLocation, bool visible)
{
PdfReader reader = new PdfReader(this.inputPDF);
/*ERROR-->*/PdfEncryptor.Encrypt(reader, new FileStream(this.outputPDF, FileMode.Create, FileAccess.Write), true, null, null, PdfWriter.AllowFillIn | PdfWriter.AllowScreenReaders);
PdfStamper st = PdfStamper.CreateSignature(reader, new FileStream(this.outputPDF, FileMode.Create, FileAccess.Write), '\0', null, true);
st.MoreInfo = this.metadata.getMetaData();
st.XmpMetadata = this.metadata.getStreamedMetaData();
PdfSignatureAppearance sap = st.SignatureAppearance;
sap.SetCrypto(this.myCert.Akp, this.myCert.Chain, null, PdfSignatureAppearance.WINCER_SIGNED);
sap.Reason = SigReason;
sap.Contact = SigContact;
sap.Location = SigLocation;
if (visible)
sap.SetVisibleSignature(new iTextSharp.text.Rectangle(100, 100, 250, 150), 1, null);
st.Close();
}