Signature Information in C++

Use PdfFileSignature for this task. The examples below retain the original C++ code and API Reference steps.

Get signature information

List signature names and print the first signature’s signer, date, reason, and location.

  1. Create PdfFileSignature.
  2. Bind the PDF input with Facade::BindPdf().
  3. Read signature identifiers with PdfFileSignature::GetSignatureNames().
  4. List signature names with PdfFileSignature::GetSignNames().
  5. Read the signer name with PdfFileSignature::GetSignerName().
  6. Read the signing date with PdfFileSignature::GetDateTime().
  7. Read the signing reason with PdfFileSignature::GetReason().
  8. Read the signing location with PdfFileSignature::GetLocation().
  9. 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/date_time.h>
#include <system/string.h>

namespace Facades::Examples::PDF_FileSignature
{
using namespace System;
using namespace Aspose::Pdf;
using namespace Aspose::Pdf::Facades;

void GetSignatureInformation(String inputFile)
{
    auto pdfSignature = MakeObject<PdfFileSignature>();
    pdfSignature->BindPdf(inputFile);
    auto signatureName = pdfSignature->GetSignatureNames()->idx_get(0);
    for (const auto &name : pdfSignature->GetSignNames())
        std::cout << "Signature Name: " << name << std::endl;
    std::cout << "Signer: " << pdfSignature->GetSignerName(signatureName) << std::endl;
    std::cout << "Date: " << pdfSignature->GetDateTime(signatureName).ToString() << std::endl;
    std::cout << "Reason: " << pdfSignature->GetReason(signatureName) << std::endl;
    std::cout << "Location: " << pdfSignature->GetLocation(signatureName) << std::endl;
}
} // namespace Facades::Examples::PDF_FileSignature