DocumentUnitClass
Definition
- Namespace
- DOM.MeasurementUnits
- Assembly
- DOM.dll
Represents a document measurement value that can be expressed either as an absolute length stored internally in EMUs (English Metric Units) or as a relative . Percentage
Remarks
is the universal measurement type used throughout the DOM for layout, sizing, spacing, borders, margins, and page geometry. It is a convenience wrapper around a canonical internal representation () stored as EMUs plus a nullable . DocumentUnit _value Percentage Read accessors convert the internal EMU value to the requested unit using the extension methods defined in . Writing any absolute-unit property (Point, Inch, CM, MM, PX, Twips) sets the internal EMU value and clears any percentage; writing sets the relative value and clears the absolute EMU. Vega.Extensions Percentage EMU is the storage unit used by Office Open XML (1 pt = 12700 EMU, 1 inch = 914400 EMU). Storing values as EMUs guarantees lossless conversion between units.
Examples
Constructors
Initializes a new empty instance with no value set. DocumentUnit
Initializes a new by converting the specified value from the given unit into the internal EMU representation. DocumentUnit
Properties
Gets or sets the measurement expressed in centimeters.
Gets or sets the measurement expressed in EMUs (the internal storage unit).
Gets or sets the measurement expressed in inches.
Gets or sets the measurement expressed in millimeters.
Gets or sets the value as a . Setting this property makes the instance represent a relative value and clears any stored absolute EMU. Percentage
Gets or sets the measurement expressed in typographic points.
Gets or sets the measurement expressed in pixels.
The getter converts EMU → points and multiplies by 1.33 to approximate pixels. The setter converts the provided pixel value into EMU by first treating it as points. Pixel conversion is approximate — for precise layout use points or inches.
Gets or sets the measurement expressed in twips (1/20 of a point).
Methods
Implicit conversion from to . Treats the provided as points and stores the equivalent EMU value. Double, DocumentUnit, Double
Returns a string representation of the unit.
Fields
Internal relative measurement when the unit represents a percentage of some reference. When non-null this value is authoritative and will be null. _value
Internal absolute value stored in EMUs. When non-null this value is the authoritative absolute measurement for the instance.