Click or drag to resize

LengthUnitConverterConvert Method

Converts the specified length from sourceUnit measurement unit to destinationUnit measurement unit.

Namespace: SautinSoft.Document
Assembly: SautinSoft.Document (in SautinSoft.Document.dll) Version: 2024.7.18
public static double Convert(
	double length,
	LengthUnit sourceUnit,
	LengthUnit destinationUnit


length  Double
The length that will be converted.
sourceUnit  LengthUnit
The source measurement unit.
destinationUnit  LengthUnit
The destination measurement unit.

Return Value

The converted value in the destination measurement units.

See Developer Guide: Shows what is the one point is equal in different units

Shows what is the one point is equal in different units in C#
using System;
using SautinSoft.Document;

namespace Sample
    class Sample
        static void Main(string[] args)
            // Get your free 100-day key here:   


        /// <summary>
        /// Shows what is the one point is equal in different units.
        /// </summary>
        /// <remarks>
        /// Details:
        public static void ConvertPointsTo()
            foreach (LengthUnit unit in Enum.GetValues(typeof(LengthUnit)))
                string s = string.Format("1 point = {0} {1}",
                    LengthUnitConverter.Convert(1, LengthUnit.Point, unit),

            Console.WriteLine("Press any key...");

        /// <summary>
        /// How to convert between different units.
        /// </summary>
        /// <remarks>
        /// Details:
        public static void UsingUnitConversion()
            DocumentCore dc = new DocumentCore();

            // Add new section.
            Section s1 = new Section(dc);
            s1.PageSetup.PageWidth = LengthUnitConverter.Convert(100, LengthUnit.Millimeter, LengthUnit.Point);
            s1.PageSetup.PageHeight = LengthUnitConverter.Convert(1, LengthUnit.Inch, LengthUnit.Point);
            s1.PageSetup.PageMargins.Left = LengthUnitConverter.Convert(0.3, LengthUnit.Centimeter, LengthUnit.Point);
            s1.PageSetup.PageMargins.Top = LengthUnitConverter.Convert(7, LengthUnit.Pixel, LengthUnit.Point);
            s1.PageSetup.PageMargins.Right = LengthUnitConverter.Convert(100, LengthUnit.Twip, LengthUnit.Point);
            s1.PageSetup.PageMargins.Bottom = LengthUnitConverter.Convert(5, LengthUnit.Millimeter, LengthUnit.Point);

            s1.Content.Start.Insert("You are welcome!", new CharacterFormat() { FontColor = Color.Orange, Size = 36 });


            // Open the result for demonstration purposes.
            System.Diagnostics.Process.Start(new System.Diagnostics.ProcessStartInfo("Result.docx") { UseShellExecute = true });
Shows what is the one point is equal in different units in VB.Net
Imports System
Imports System.IO
Imports SautinSoft.Document

Module Sample
    Sub Main()
    End Sub
    ''' Get your free 100-day key here:   
    ''' <summary>
    ''' Shows what is the one point is equal in different units.
    ''' </summary>
    ''' <remarks>
    ''' Details:
    ''' </remarks>
    Sub ConvertPointsTo()
        For Each unit As LengthUnit In System.Enum.GetValues(GetType(LengthUnit))
            Dim s As String = String.Format("1 point = {0} {1}", LengthUnitConverter.Convert(1, LengthUnit.Point, unit), unit.ToString().ToLowerInvariant())

        Next unit
        Console.WriteLine("Press any key...")
    End Sub

    ''' <summary>
    ''' How to convert between different units.
    ''' </summary>
    ''' <remarks>
    ''' Details:
    ''' </remarks>
    Sub UsingUnitConversion()
        Dim dc As New DocumentCore()

        ' Add new section.
        Dim s1 As New Section(dc)
        s1.PageSetup.PageWidth = LengthUnitConverter.Convert(100, LengthUnit.Millimeter, LengthUnit.Point)
        s1.PageSetup.PageHeight = LengthUnitConverter.Convert(1, LengthUnit.Inch, LengthUnit.Point)
        s1.PageSetup.PageMargins.Left = LengthUnitConverter.Convert(0.3, LengthUnit.Centimeter, LengthUnit.Point)
        s1.PageSetup.PageMargins.Top = LengthUnitConverter.Convert(7, LengthUnit.Pixel, LengthUnit.Point)
        s1.PageSetup.PageMargins.Right = LengthUnitConverter.Convert(100, LengthUnit.Twip, LengthUnit.Point)
        s1.PageSetup.PageMargins.Bottom = LengthUnitConverter.Convert(5, LengthUnit.Millimeter, LengthUnit.Point)

        s1.Content.Start.Insert("You are welcome!", New CharacterFormat() With {
                .FontColor = Color.Orange,
                .Size = 36


        ' Open the result for demonstration purposes.
        System.Diagnostics.Process.Start(New System.Diagnostics.ProcessStartInfo("Result.docx") With {.UseShellExecute = True})
    End Sub
End Module
See Also