THPDFPage.AddRectilinearViewport Method
Adds a /Type /Viewport dictionary with a rectilinear (/Subtype /RL) /Measure to the page’s /VP array, so conforming viewers can measure distances and areas on the page in real-world units (ISO 32000-1 ยง12.9, Tables 260–263)
Declaration
function AddRectilinearViewport(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
| Name | Purpose |
|---|---|
Name | PDF resource name, packet name, profile name, or caller-defined identifier |
Left | Page coordinate or size value expressed in the current HotPDF coordinate space |
Bottom | Page coordinate or size value expressed in the current HotPDF coordinate space |
Right | Page coordinate or size value expressed in the current HotPDF coordinate space |
Top | Page coordinate or size value expressed in the current HotPDF coordinate space |
ScaleRatio | Scale ratio text written as /R, for example '1 pt = 0.01 m'; when empty, a ratio is generated from ConversionFactor and UnitLabel |
ConversionFactor | Factor 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 |
UnitLabel | Unit label (/U) for the x axis and for distance, for example 'm' |
AreaUnitLabel | Unit label for area; defaults to 'sq ' + UnitLabel |
OriginX | x coordinate of the measurement origin (/O) in default user space; written when either origin coordinate is non-zero |
OriginY | y coordinate of the measurement origin (/O) in default user space |
CYX | Ratio 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 SetViewportPointDataCloud
Usage notes
- Requires PDF 1.6; the document version is raised automatically unless a strict version lock is set
- For separate x/y scales or custom distance, area, angle and slope formats, use
AddRectilinearViewportExwith aTHPDFRectilinearMeasureInforecord, where each number format array carries its own conversion factors - The viewport
BBoxis given in the current HotPDF coordinate space like other page rectangles