Get PDF Version in C++

Contents
[ ]

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

Get PDF version

Print the PDF version.

  1. Create PdfFileInfo with the input PDF path.
  2. Read the PDF version with PdfFileInfo::GetPdfVersion().
  3. Close the facade with PdfFileInfo::Close().
  4. Print the results or diagnostic messages shown in the example.
#include <Aspose.PDF.Cpp/Facades/PdfFileInfo.h>
#include <iostream>
#include <system/string.h>

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

void GetPdfVersion(String inputFile)
{
    auto pdfInfo = MakeObject<PdfFileInfo>(inputFile);
    std::cout << std::endl;
    std::cout << String(u"PDF Version: ") << pdfInfo->GetPdfVersion() << std::endl;
    pdfInfo->Close();
}
} // namespace Facades::Examples::PDF_FileInfo