Get Page Offset in C++

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

Get page offsets

Print page 1 X and Y offsets in inches.

  1. Create PdfFileInfo with the input PDF path.
  2. Read the X offset with PdfFileInfo::GetPageXOffset().
  3. Read the Y offset with PdfFileInfo::GetPageYOffset().
  4. Close the facade with PdfFileInfo::Close().
  5. 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 GetPageOffsets(String inputFile)
	{
		auto pdfInfo = MakeObject<PdfFileInfo>(inputFile);
		std::cout << "Page X Offset: " << (pdfInfo->GetPageXOffset(1) / 72.0) << " inches" << std::endl;
		std::cout << "Page Y Offset: " << (pdfInfo->GetPageYOffset(1) / 72.0) << " inches" << std::endl;
		pdfInfo->Close();
	}
} // namespace Facades::Examples::PDF_FileInfo