Get Page Offset in C++
Contents
[
Hide
]
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.
- Create PdfFileInfo with the input PDF path.
- Read the X offset with PdfFileInfo::GetPageXOffset().
- Read the Y offset with PdfFileInfo::GetPageYOffset().
- Close the facade with PdfFileInfo::
Close(). - 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