GemBox.Document is a .NET component that enables you to read, write, edit, convert, and print document files from your .NET applications using one simple API.

Unit Conversion

All dimensional properties in GemBox.Document are measured in points unit.

Utility class LengthUnitConverter can be used to convert values between various measurement units.

Following example demonstrates how to convert points to all other measurement units.

Screenshot
Unit Conversion Screenshot

See the full code below, use Run Example to execute.

Upload your file(Drag files here)

Download a sample file

using System;
using System.IO;
using System.Text;
using GemBox.Document;

class Sample
{
    [STAThread]
    static void Main(string[] args)
    {
        // If using Professional version, put your serial key below.
        ComponentInfo.SetLicense("FREE-LIMITED-KEY");

        DocumentModel document = DocumentModel.Load("Reading.docx");

        StringBuilder sb = new StringBuilder();

        sb.AppendLine("Page size (width X height):");

        double width = document.Sections[0].PageSetup.PageWidth;
        double height = document.Sections[0].PageSetup.PageHeight;

        foreach (LengthUnit unit in Enum.GetValues(typeof(LengthUnit)))
        {
            sb.AppendFormat(
                "{0} X {1} {2}",
                LengthUnitConverter.Convert(width, LengthUnit.Point, unit),
                LengthUnitConverter.Convert(height, LengthUnit.Point, unit),
                unit.ToString().ToLowerInvariant());

            sb.AppendLine();
        }

        Console.WriteLine(sb.ToString());
    }
}
Imports System
Imports System.IO
Imports System.Text
Imports GemBox.Document

Module Samples

    Sub Main()

        ' If using Professional version, put your serial key below.
        ComponentInfo.SetLicense("FREE-LIMITED-KEY")

        Dim document As DocumentModel = DocumentModel.Load("Reading.docx")

        Dim sb As New StringBuilder()

        sb.AppendLine("Page size (width X height):")

        Dim width As Double = document.Sections(0).PageSetup.PageWidth
        Dim height As Double = document.Sections(0).PageSetup.PageHeight

        For Each unit As LengthUnit In [Enum].GetValues(GetType(LengthUnit))

            sb.AppendFormat("{0} X {1} {2}",
                            LengthUnitConverter.Convert(width, LengthUnit.Point, unit),
                            LengthUnitConverter.Convert(height, LengthUnit.Point, unit),
                            unit.ToString().ToLowerInvariant())

            sb.AppendLine()

        Next

        Console.WriteLine(sb.ToString())

    End Sub

End Module

Check next sample.