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.