THotPDF.AddPageRectilinearViewport Method

Adds a /Type /Viewport dictionary with a rectilinear (/Subtype /RL) /Measure to the /VP array of a loaded document’s page, so conforming viewers can measure distances and areas in real-world units (ISO 32000-1 ยง12.9, Tables 260–263)

Declaration

function AddPageRectilinearViewport(PageIndex: Integer; const Name: AnsiString; Left, Bottom, Right, Top: Double; const ScaleRatio: AnsiString; ConversionFactor: Double; const UnitLabel: AnsiString; const AreaUnitLabel: AnsiString= ''; OriginX: Double= 0.0; OriginY: Double= 0.0; CYX: Double= 1.0): Integer;

Unit

HPDFDoc

Parameters

NamePurpose
PageIndexZero-based index of the loaded page to attach the viewport to
NameOptional viewport name written as /Name
LeftViewport BBox edge in PDF user space
BottomViewport BBox edge in PDF user space
RightViewport BBox edge in PDF user space
TopViewport BBox edge in PDF user space
ScaleRatioScale ratio text written as /R, for example '1 pt = 0.01 m'; when empty, a ratio is generated from ConversionFactor and UnitLabel
ConversionFactorFactor converting default user space units to UnitLabel units along the x axis (and the y axis when no separate /Y is given). Per ISO 32000-1 Table 262 the first /D and /A number formats convert from the x units (squared for area), and the viewer applies the axis factor first, so this simple overload writes their conversion factors as 1: distance is measured in UnitLabel and area in its square
UnitLabelUnit label (/U) for the x axis and for distance, for example 'm'
AreaUnitLabelUnit label for area; defaults to 'sq ' + UnitLabel
OriginXx coordinate of the measurement origin (/O) in default user space; written when either origin coordinate is non-zero
OriginYy coordinate of the measurement origin (/O) in default user space
CYXRatio of y axis units to x axis units (/CYX); meaningful when the axes use different scales

Return value

The zero-based index of the new viewport in the page’s /VP array, suitable for SetPageViewportPointDataCloud

Usage notes

Related APIs