Unit conversion in PowerPoint files using C# and VB.NET

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;

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

var presentation = PresentationDocument.Load("Reading.pptx");

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("Reading.pptx")

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 done with GemBox.Presentation

Next steps

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