Signature Verification in C++
Contents
[
Hide
]
Use PdfFileSignature for this task. The examples below retain the original C++ code and API Reference steps.
Verify PDF signature
Print the first signature’s verification result and whether it covers the whole document.
- Create PdfFileSignature.
- Bind the PDF input with Facade::BindPdf().
- Read signature identifiers with PdfFileSignature::GetSignatureNames().
- Verify the signature with PdfFileSignature::VerifySignature().
- Check document coverage with PdfFileSignature::CoversWholeDocument().
- Print the results or diagnostic messages shown in the example.
#include <Aspose.PDF.Cpp/Facades/PdfFileSignature.h>
#include <Aspose.PDF.Cpp/Facades/SignatureName.h>
#include <iostream>
#include <system/collections/ilist.h>
#include <system/string.h>
namespace Facades::Examples::PDF_FileSignature
{
using namespace System;
using namespace Aspose::Pdf;
using namespace Aspose::Pdf::Facades;
void VerifyPdfSignature(String inputFile)
{
auto pdfSignature = MakeObject<PdfFileSignature>();
pdfSignature->BindPdf(inputFile);
auto signatureName = pdfSignature->GetSignatureNames()->idx_get(0);
std::cout << "Signature '" << signatureName->ToString()
<< "' is valid: " << pdfSignature->VerifySignature(signatureName) << std::endl;
std::cout << "Signature covers whole document: " << pdfSignature->CoversWholeDocument(signatureName) << std::endl;
}
} // namespace Facades::Examples::PDF_FileSignature