Unit Conversion in PowerPoint
You can use the length type
to convert values between various measurement units, such as converting from inches to centimeters.
The following example shows how you can use unit conversion in your presentations in C# and VB.NET, using GemBox.Presentation.

using System;
using System.Text;
using GemBox.Presentation;
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 System
Imports System.Text
Imports GemBox.Presentation
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
See also
Next steps
Published: December 13, 2018 | Modified: December 19, 2022 | Author: Stipo Rubic