Unit Conversion in PowerPoint

The following example shows how you can convert length units in your presentations using the GemBox.Presentation library.

Upload your file (Drag file here)
using GemBox.Presentation;
using System;
using System.Text;

class Program
{
    static void Main()
    {
        // If using the 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 GemBox.Presentation
Imports System
Imports System.Text

Module Program

    Sub Main()

        ' If using the 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
PowerPoint length unit conversion with GemBox.Presentation
Screenshot of PowerPoint length unit conversion with GemBox.Presentation

See also


Next steps

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

Download Buy