SetMeasurementUnit
Measurement and coordinate units
Description
Sets the unit used for every measurement passed to and returned from the library, taking the typed TPDFlibMeasurementUnit value (muPixels, muMillimeters, muInches, muTwips or muPoints) instead of the legacy 0/1/2 codes. It is the typed counterpart of SetMeasurementUnits and always returns 1.
Syntax
Delphi
Function TPDFlib.SetMeasurementUnit(AUnit: TPDFlibMeasurementUnit): Integer;
Parameters
AUnit is the unit to adopt: muPixels and muPoints both mean one user unit per PDF point, muMillimeters means one unit is 72/25.4 points, muInches means one unit is 72 points, and muTwips means one unit is 1/20 point. The value is stored as a scale factor on the selected document, so only these five members carry meaning.
Return values
Always 1. The function cannot fail: it performs no validation beyond the case dispatch, so even a value cast into the enumeration from an out-of-range ordinal returns success.
Remarks
The scale is per document: it is stored on the currently selected document, survives switching pages, and is what GetMeasurementUnit reads back. Because muPixels and muPoints map to the same factor of 1, a round trip through GetMeasurementUnit reports muPoints for both, and an ordinal outside the declared members falls through the dispatch without changing the current unit, again reporting 1 - drive the parameter from the enumeration rather than from an integer. Changing the unit does not rewrite or rescale anything already emitted into the document; it only changes how later coordinates and sizes are interpreted, so existing content keeps the geometry it was drawn with. Page dimensions read back through the page-size getters are scaled by the same factor.