Get Page Information in C++

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

Get page information

Print page 1 width, height, and rotation.

  1. Create PdfFileInfo with the input PDF path.
  2. Read the page width with PdfFileInfo::GetPageWidth().
  3. Read the page height with PdfFileInfo::GetPageHeight().
  4. Read the page rotation with PdfFileInfo::GetPageRotation().
  5. Close the facade with PdfFileInfo::Close().
  6. 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 GetPageInformation(String inputFile)
{
    auto pdfInfo = MakeObject<PdfFileInfo>(inputFile);
    std::cout << "Page Width: " << pdfInfo->GetPageWidth(1) << std::endl;
    std::cout << "Page Height: " << pdfInfo->GetPageHeight(1) << std::endl;
    std::cout << "Page Rotation: " << pdfInfo->GetPageRotation(1) << std::endl;
    pdfInfo->Close();
}
} // namespace  Facades::Examples::PDF_FileInfo