PDF: Как добавить информацию о долгосрочной проверке (LTV) ко всем цифровым подписям PDF-документа?
В этом разделе
Вот C#/VB.NET код, демонстрирующий добавление информации о долгосрочной проверке подлинности (LTV) ко всем цифровым подписям PDF-документа.
/// <summary>
/// Adds long term validation (LTV) information to all signatures of specified PDF document.
/// </summary>
/// <param name="inputPdfFilename">The filename of input PDF document.</param>
/// <param name="outputPdfFilename">The filename of output PDF document.</param>
public static bool AddVltInfo(string inputPdfFilename, string outputPdfFilename)
{
// open PDF document
using (Vintasoft.Imaging.Pdf.PdfDocument document =
new Vintasoft.Imaging.Pdf.PdfDocument(inputPdfFilename))
{
try
{
// add LTV info
int count = Vintasoft.Imaging.Pdf.Tree.DigitalSignatures.PdfDocumentLtv.AddLtvInfo(document);
if (count == 0)
System.Console.WriteLine("LTV information is not required for this document.");
else
System.Console.WriteLine("LTV information is added.");
}
catch (System.Exception ex)
{
System.Console.WriteLine("Error: " + ex.Message);
return false;
}
// save PDF document
if (inputPdfFilename == outputPdfFilename)
document.SaveChanges();
else
document.Save(outputPdfFilename);
return true;
}
}
''' <summary>
''' Adds long term validation (LTV) information to all signatures of specified PDF document.
''' </summary>
''' <param name="inputPdfFilename">The filename of input PDF document.</param>
''' <param name="outputPdfFilename">The filename of output PDF document.</param>
Public Shared Function AddVltInfo(inputPdfFilename As String, outputPdfFilename As String) As Boolean
' open PDF document
Using document As New Vintasoft.Imaging.Pdf.PdfDocument(inputPdfFilename)
Try
' add LTV info
Dim count As Integer = Vintasoft.Imaging.Pdf.Tree.DigitalSignatures.PdfDocumentLtv.AddLtvInfo(document)
If count = 0 Then
System.Console.WriteLine("LTV information is not required for this document.")
Else
System.Console.WriteLine("LTV information is added.")
End If
Catch ex As System.Exception
System.Console.WriteLine("Error: " & ex.Message)
Return False
End Try
' save PDF document
If inputPdfFilename = outputPdfFilename Then
document.SaveChanges()
Else
document.Save(outputPdfFilename)
End If
Return True
End Using
End Function