pdfCreateRectilinearMeasure
Attach a rectilinear (/Subtype /RL) /Measure dictionary to
int32_t __stdcall pdfCreateRectilinearMeasureA(PPDF IPDF, uint32_t Viewport, double Scale, const char* UnitDescription, const char* LabelDistance, const char* LabelArea);
int32_t __stdcall pdfCreateRectilinearMeasureW(PPDF IPDF, uint32_t Viewport, double Scale, const wchar_t* UnitDescription, const wchar_t* LabelDistance, const wchar_t* LabelArea);
function pdfCreateRectilinearMeasureA(const IPDF: PPDF; Viewport: Cardinal; Scale: Double; const UnitDescription, LabelDistance, LabelArea: PAnsiChar): Integer; stdcall;
function pdfCreateRectilinearMeasureW(const IPDF: PPDF; Viewport: Cardinal; Scale: Double; const UnitDescription, LabelDistance, LabelArea: PWideChar): Integer; stdcall;
Purpose. Attach a rectilinear (/Subtype /RL) /Measure dictionary to an existing page viewport, describing a scale ratio for that region (e.g. "1 inch = 10 feet" on an architectural drawing).
Description. Requires the current page to have at least Viewport viewports already defined (1-based; fails if Viewport < 1 or exceeds Pg.Viewports.Count) — a viewport must be created through the separate viewport-creation mechanism (not covered in this chapter) before this call can succeed. Builds a /Measure dict with /Subtype /RL, an /R scale- ratio label string ("1 = <Scale> <UnitDescription>"), and single-entry /X (distance-unit format), /D (distance label format), and /A (area label format) number-format arrays, then attaches it to the target viewport dict. W UTF-8-encodes its wide strings before storage; A stores the raw ANSI bytes as given.
Parameters.
| Parameter | Description |
|---|---|
IPDF | Document handle. |
Viewport | 1-based index of an existing viewport on the current page. |
Scale | The numeric scale ratio (e.g. 120 for "1 = 120 units"). |
UnitDescription | Unit label appended to the /R ratio string and used in the /X number-format entry. |
LabelDistance | Distance number-format label (/D). |
LabelArea | Area number-format label (/A). |
Return value. The Viewport index itself (not a distinct handle) on success; 0 if there is no open page, or Viewport doesn't identify an existing viewport.
See also. pdfCreateGeospatialMeasure (a sibling /Subtype /GEO measure — not covered in this chapter).
C# (P/Invoke)
public static extern int pdfCreateRectilinearMeasureA(IntPtr IPDF, uint Viewport, double Scale, [MarshalAs(UnmanagedType.LPStr)] string UnitDescription, [MarshalAs(UnmanagedType.LPStr)] string LabelDistance, [MarshalAs(UnmanagedType.LPStr)] string LabelArea);
public static extern int pdfCreateRectilinearMeasureW(IntPtr IPDF, uint Viewport, double Scale, [MarshalAs(UnmanagedType.LPWStr)] string UnitDescription, [MarshalAs(UnmanagedType.LPWStr)] string LabelDistance, [MarshalAs(UnmanagedType.LPWStr)] string LabelArea);
Object Creation
pdfCreateRectilinearMeasureA
pdfCreateRectilinearMeasureW
The …A form takes UTF-8, …W
takes UTF-16; a bare name aliases the ANSI form.
Worked examples — complete programs in ten languages.