Class DocUnit
Inheritance
System.Object
DocUnit
Assembly: IronPPT.dll
Syntax
public class DocUnit : Object, IDocUnit
Expressing a measurement in IronPPT, the width of a margin, the offset of a shape, the size of an element, runs through DocUnit. A single value can be read or written in whichever unit a project thinks in, so you set a position in centimeters and read it back in points without doing the arithmetic yourself.
A DocUnit is the measurement carried by layout and positioning members across the slide model, so it appears wherever a size or offset is set rather than as a standalone step. An ElementPosition, for instance, exposes its X and Y coordinates as IDocUnit values, so you place an element in whatever unit suits the source data. You assign the value in one unit and the type exposes the equivalent in the others, no conversion code required.
The unit properties are the same measurement viewed different ways. CM, MM, and Inch give metric and imperial lengths, Point gives the typographic point common in document layout, Twips gives twentieths of a point, and EMU gives English Metric Units, the integer unit the underlying OpenXML format stores. Each is Nullable, so an unset measurement reads as null rather than zero. The Percentage property holds a Percentage for measurements expressed relative to a parent rather than as an absolute length, and ToString renders the value for logging or display. Assign whichever unit your source data uses, then read the property that matches the API or format you are targeting.
using IronPPT.Models;
var unit = new DocUnit();
unit.CM = 2.5;
double asPoints = unit.Point ?? 0;
The add shape workflow in the add-slide how-to places elements that take measurements, the slide element tutorial covers sizing and positioning slide content, and the ElementPosition reference shows where a measurement is consumed.
Constructors
DocUnit()
Declaration
Fields
_percentage
Declaration
protected Percentage _percentage
Field Value
_value
Declaration
protected Nullable<long> _value
Field Value
| Type |
Description |
| System.Nullable<System.Int64> |
|
Properties
CM
Declaration
public Nullable<double> CM { get; set; }
Property Value
| Type |
Description |
| System.Nullable<System.Double> |
|
EMU
Declaration
public Nullable<long> EMU { get; set; }
Property Value
| Type |
Description |
| System.Nullable<System.Int64> |
|
Inch
Declaration
public Nullable<double> Inch { get; set; }
Property Value
| Type |
Description |
| System.Nullable<System.Double> |
|
MM
Declaration
public Nullable<double> MM { get; set; }
Property Value
| Type |
Description |
| System.Nullable<System.Double> |
|
Percentage
Declaration
public Percentage Percentage { get; set; }
Property Value
Point
Declaration
public Nullable<double> Point { get; set; }
Property Value
| Type |
Description |
| System.Nullable<System.Double> |
|
Twips
Declaration
public Nullable<double> Twips { get; set; }
Property Value
| Type |
Description |
| System.Nullable<System.Double> |
|
Methods
ToString()
Declaration
public override string ToString()
Returns
| Type |
Description |
| System.String |
|
Operators
Implicit(Percentage to DocUnit)
Declaration
public static implicit operator DocUnit(Percentage value)
Parameters
Returns
Implicit(Double to DocUnit)
Declaration
public static implicit operator DocUnit(double value)
Parameters
| Type |
Name |
Description |
| System.Double |
value |
|
Returns
Implements