Analyzing your prompt, please hold on...
An error occurred while retrieving the results. Please refresh the page and try again.
当签名已添加到 PDF 文件中时,可以将其移除。您可以移除特定的签名,或移除文件中的所有签名。移除签名的最快方法也会移除签名字段,但可以仅移除签名,保留签名字段,以便文件可以再次签名。
PdfFileSignature 类的 RemoveSignature 方法允许您从 PDF 文件中移除签名。此方法将签名名称作为输入。可以直接指定签名名称,以移除所有签名,或使用 GetSignNames 方法获取签名名称。
以下代码片段演示如何从 PDF 文件中移除数字签名。
// For complete examples and data files, visit https://github.com/aspose-pdf/Aspose.PDF-for-.NET
private static void RemoveSignature()
{
// The path to the documents directory
var dataDir = RunExamples.GetDataDir_AsposePdf_SecuritySignatures();
using (var pdFileSignature = new Aspose.Pdf.Facades.PdfFileSignature())
{
// Bind PDF document
pdFileSignature.BindPdf(dataDir + "signed_rsa.pdf");
// Get list of signature names
var sigNames = pdFileSignature.GetSignNames();
// Remove all the signatures from the PDF file
for (int index = 0; index < sigNames.Count; index++)
{
Console.WriteLine($"Removed {sigNames[index]}");
pdFileSignature.RemoveSignature(sigNames[index]);
}
// Save PDF document
pdFileSignature.Save(dataDir + "RemoveSignature_out.pdf");
}
}
如上所示,PdfFileSignature 类的 RemoveSignature 方法允许您从 PDF 文件中移除签名字段。当使用此方法与 9.3.0 之前的版本时,签名和签名字段都会被移除。一些开发者希望仅移除签名并保留签名字段,以便可以用来重新签署文档。要保留签名字段并仅移除签名,请使用以下代码片段。
// For complete examples and data files, visit https://github.com/aspose-pdf/Aspose.PDF-for-.NET
private static void RemoveSignatureButKeepField()
{
// The path to the documents directory
var dataDir = RunExamples.GetDataDir_AsposePdf_SecuritySignatures();
using (var pdFileSignature = new Aspose.Pdf.Facades.PdfFileSignature())
{
// Bind PDF document
pdFileSignature.BindPdf(dataDir + "signed_rsa.pdf");
pdFileSignature.RemoveSignature("Signature1", false);
// Save PDF document
pdFileSignature.Save(dataDir + "RemoveSignature_out.pdf");
}
}
以下示例演示如何从字段中移除所有签名。
// For complete examples and data files, visit https://github.com/aspose-pdf/Aspose.PDF-for-.NET
private static void RemoveSignatureButKeepField2()
{
// The path to the documents directory
var dataDir = RunExamples.GetDataDir_AsposePdf_SecuritySignatures();
using (var pdFileSignature = new Aspose.Pdf.Facades.PdfFileSignature())
{
// Bind PDF document
pdFileSignature.BindPdf(dataDir + "signed_rsa.pdf");
var sigNames = pdFileSignature.GetSignatureNames();
foreach (var sigName in sigNames)
{
pdFileSignature.RemoveSignature(sigName, false);
}
// Save PDF document
pdFileSignature.Save(dataDir + "RemoveSignature_out.pdf");
}
}
Analyzing your prompt, please hold on...
An error occurred while retrieving the results. Please refresh the page and try again.