Table of Contents

Units and measurements

Word measures most things in twips (twentieths of a point) and drawings in EMU (English Metric Units). DocWright uses the same units, as whole numbers, which is part of how it matches Word's layout exactly.

Type One unit is Per inch Used for
Twips 1/20 point 1,440 Page size, margins, indents, spacing, font sizes, table widths
Emu 1/914,400 inch 914,400 Images, shapes, charts
Points 1/72 inch 72 What you think in. Twips.FromPoints converts.

Both types live in DocWright.Core.Primitives. Their Value is the whole number of units.

Converting

using DocWright.Core.Primitives;

Console.WriteLine($"12 pt      = {Twips.FromPoints(12).Value} twips");
Console.WriteLine($"1 inch     = {Twips.FromInches(1).Value} twips");
Console.WriteLine($"2.5 cm     = {Twips.FromCentimeters(2.5).Value} twips");
Console.WriteLine($"A4 width   = {Twips.FromMillimeters(210).Value} twips");
Console.WriteLine($"1 inch     = {Emu.FromInches(1).Value} EMU");
Console.WriteLine($"1 twip     = {Emu.FromTwips(new Twips(1)).Value} EMU");

Output

12 pt      = 240 twips
1 inch     = 1440 twips
2.5 cm     = 1417 twips
A4 width   = 11906 twips
1 inch     = 914400 EMU
1 twip     = 635 EMU

Twips has FromPoints, FromInches, FromCentimeters, FromMillimeters, FromHalfPoints and FromEmus. Emu has FromInches, FromCentimeters, FromTwips and more. Conversion rounds once, half away from zero. After that, all layout arithmetic is exact integer arithmetic.

Where you'll meet them

  • CharacterFormat.FontSize is Twips: Twips.FromPoints(11) for 11 pt.
  • ParagraphFormat.SpacingAfter, IndentLeft and the others are Twips.
  • AppendTable(..., columnWidth: Twips.FromInches(2)).
  • AppendImage(bytes, type, Emu.FromInches(2), Emu.FromInches(1)).
  • Composition methods take a double with a Unit instead (Point, Millimetre, Centimetre or Inch) and convert for you.
  • Report definitions write sizes as text such as 2.5in. RdlMeasure.Parse converts them to Twips.