Unit Conversion

Length type can be used to convert values between various measurement units and the following example demonstrates how to use it.

Screenshot of PowerPoint length unit conversion with GemBox.Presentation
PowerPoint length unit conversion with GemBox.Presentation
Upload your file (Drag file here)
using System;
using System.Text;
using GemBox.Presentation;

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

        var presentation = PresentationDocument.Load("%InputFileName%");

        var sb = new StringBuilder();

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

        var width = presentation.SlideSize.Width;
        var height = presentation.SlideSize.Height;

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

            sb.AppendLine();
        }

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

Module Program

    Sub Main()

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

        Dim presentation = PresentationDocument.Load("%InputFileName%")

        Dim sb = New StringBuilder()

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

        Dim width = presentation.SlideSize.Width
        Dim height = presentation.SlideSize.Height

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

            sb.AppendFormat(
                "{0} X {1} {2}",
                width.To(unit),
                height.To(unit),
                unit.ToString().ToLowerInvariant())

            sb.AppendLine()
        Next

        Console.WriteLine(sb.ToString())
    End Sub
End Module

Check next example or download examples from GitHub.