THotPDF.GetLoadedPageBox Method

Syntax

function GetLoadedPageBox(
  PageIndex: Integer;
  Box      : THPDFPageBoundary;
  out Left, Bottom, Right, Top: Single): Boolean;

Description

GetLoadedPageBox reads a page boundary from a PDF loaded with LoadFromFile. PageIndex is zero-based and Box accepts pbMediaBox, pbCropBox, pbBleedBox, pbTrimBox, or pbArtBox.

The method returns True when the requested boundary can be resolved. It follows the PDF page-box default chain: a missing CropBox resolves to MediaBox, and a missing BleedBox, TrimBox, or ArtBox resolves to CropBox and then MediaBox

MediaBox and CropBox are inherited from the page tree when the page does not carry them itself BleedBox, TrimBox, and ArtBox are not inheritable in PDF, so only the page's own entries are read; a value placed on a /Pages node is ignored

Example

var
  L, B, R, T: Single;
begin
  PDF.LoadFromFile('Input.pdf');
  if PDF.GetLoadedPageBox(0, pbTrimBox, L, B, R, T) then
    Writeln(Format('TrimBox: %.2f %.2f %.2f %.2f', [L, B, R, T]));
end;

See Also