HTML5 SDK Sample Codes

HTML5Point is a comprehensive and efficient conversion tool that helps you easily convert professional-looking PowerPoint presentations to HTML5 slideshows. Check out the following sample codes.

C# C# Code

Sample showing how to instantiate PresentationConverter, configure output settings, and convert a .pptx to HTML5 from a console application.

using System;
using DigitalOfficePro.Html5PointSdk;

namespace Html5Converter
{
    class Program
    {
        static void Main(string[] args)
        {
            if (args.Length != 2)
            {
                Console.WriteLine("Html5Point SDK C# sample.\n");
                Console.WriteLine("Usage:\n");
                Console.WriteLine("Html5Converter.exe <input-ppt-file-name> <output-HTML5-file-name>\n");
                return;
            }

            // Create powerpoint to html5 converter object.
            PresentationConverter presentationConverter = new PresentationConverter();

            // Initialize library using userName and productKey in case of redistributable license.
            // presentationConverter.InitLibrary("userName", "productKey");

            // Update conversion settings
            presentationConverter.Settings.CreateDirectoryForOutput = true;

            // Output settings
            presentationConverter.Settings.Output.AdvanceOnMouseClick   = true;
            presentationConverter.Settings.Output.BackgroundColor       = -16777216; // ARGB of black
            presentationConverter.Settings.Output.EmbedFonts            = true;
            presentationConverter.Settings.Output.FitToWindow           = true;
            presentationConverter.Settings.Output.IncludeHiddenSlides   = true;
            presentationConverter.Settings.Output.WindowScale           = 100;

            // For LMS output
            // presentationConverter.Settings.Lms = new LmsSettings();
            // presentationConverter.Settings.Lms.LmsType     = LmsType.Scorm1Point2;
            // presentationConverter.Settings.Lms.CourseTitle = "Sample course title";
            // presentationConverter.Settings.Lms.Description = "Sample description";

            // For thumbnail generation
            presentationConverter.Settings.Thumbnail        = new ThumbnailSettings();
            presentationConverter.Settings.Thumbnail.Format = ThumbnailImageFormat.Jpg;
            presentationConverter.Settings.Thumbnail.Scale  = 10;

            // To add company logo
            // presentationConverter.Settings.Logo = new LogoSettings();
            // presentationConverter.Settings.Logo.Left      = 10;
            // presentationConverter.Settings.Logo.Top       = 10;
            // presentationConverter.Settings.Logo.Width     = 200;
            // presentationConverter.Settings.Logo.Height    = 100;
            // presentationConverter.Settings.Logo.Hyperlink = "https://www.digitalofficepro.com";
            // presentationConverter.Settings.Logo.ImagePath = @"C:\Users\user\Documents\Logo.png";

            // For custom player
            // presentationConverter.Settings.Player = new PlayerSettings();
            // presentationConverter.Settings.Player.Path = @"C:\Program Files (x86)\DigitalOfficePro\HTML5PointSDK\Players\classic";

            // Open presentation
            string presentationName = args[0];
            presentationConverter.OpenPresentation(presentationName);
            Console.WriteLine("PowerPoint presentation '{0}' is opened.", presentationName);

            string outputHtmlFile = args[1];

            // HTML5 conversion
            presentationConverter.Convert(outputHtmlFile);
            Console.WriteLine("Converted presentation '{0}' to '{1}'.", presentationName, outputHtmlFile);

            presentationConverter.ClosePresentation();
            Console.WriteLine("Presentation closed");
        }
    }
}

VB VB.NET Code

Identical workflow expressed in Visual Basic .NET - useful for legacy desktop integrations.

Imports DigitalOfficePro.Html5PointSdk

Module Module1

    Sub Main(ByVal args As String())
        ' To check args length
        If args.Length <> 2 Then
            Console.WriteLine("Html5Point SDK C# sample." & vbLf)
            Console.WriteLine("Usage:" & vbLf)
            Console.WriteLine("Html5Converter.exe <input-ppt-file-name> <output-HTML5-file-name>" & vbLf)
            Return
        End If

        ' Create powerpoint to html5 converter object.
        Dim presentationConverter As New PresentationConverter()

        ' Initialize library using userName and productKey in case of redistributable license.
        ' presentationConverter.InitLibrary("userName", "productKey")

        ' Update conversion settings
        presentationConverter.Settings.CreateDirectoryForOutput = True

        ' Output settings
        presentationConverter.Settings.Output.AdvanceOnMouseClick = True
        presentationConverter.Settings.Output.BackgroundColor     = -16777216 ' ARGB of black.
        presentationConverter.Settings.Output.EmbedFonts          = True
        presentationConverter.Settings.Output.FitToWindow         = True
        presentationConverter.Settings.Output.IncludeHiddenSlides = True
        presentationConverter.Settings.Output.WindowScale         = 100

        ' For LMS output
        ' presentationConverter.Settings.Lms = New LmsSettings()
        ' presentationConverter.Settings.Lms.LmsType     = LmsType.Scorm1Point2
        ' presentationConverter.Settings.Lms.CourseTitle = "Sample course title"
        ' presentationConverter.Settings.Lms.Description = "Sample description"

        ' For thumbnail generation
        presentationConverter.Settings.Thumbnail        = New ThumbnailSettings()
        presentationConverter.Settings.Thumbnail.Format = ThumbnailImageFormat.Jpg
        presentationConverter.Settings.Thumbnail.Scale  = 10

        ' To add company logo
        ' presentationConverter.Settings.Logo = New LogoSettings()
        ' presentationConverter.Settings.Logo.Left      = 10
        ' presentationConverter.Settings.Logo.Top       = 10
        ' presentationConverter.Settings.Logo.Width     = 200
        ' presentationConverter.Settings.Logo.Height    = 100
        ' presentationConverter.Settings.Logo.Hyperlink = "https://www.digitalofficepro.com"
        ' presentationConverter.Settings.Logo.ImagePath = "C:\Users\user\Documents\Logo.png"

        ' For custom player
        ' presentationConverter.Settings.Player = New PlayerSettings()
        ' presentationConverter.Settings.Player.Path = "C:\Program Files (x86)\DigitalOfficePro\HTML5PointSDK\Players\classic"

        ' Open presentation
        Dim presentationName As String = args(0)
        presentationConverter.OpenPresentation(presentationName)
        Console.WriteLine("PowerPoint presentation '{0}' is opened.", presentationName)

        Dim outputHtmlFile As String = args(1)

        ' HTML5 conversion
        presentationConverter.Convert(outputHtmlFile)
        Console.WriteLine("Converted presentation '{0}' to '{1}'.", presentationName, outputHtmlFile)

        presentationConverter.ClosePresentation()
        Console.WriteLine("Presentation closed")
    End Sub

End Module

C++ C++ Code

Drive the SDK over COM from native C++ - ideal for embedding into existing Windows desktop products.

#include "stdafx.h"
#import "..\..\..\..\Include\DigitalOfficePro.Html5PointSdk.tlb" named_guids

int _tmain(int argc, _TCHAR* argv[])
{
    if (argc != 3)
    {
        wprintf(L"Html5Point SDK C++ sample.\n");
        wprintf(L"Usage:\n");
        wprintf(L"  Simple_Cpp.exe <input-ppt-file-name> <output-HTML5-file-name>\n");
        return 0;
    }

    bool initialized = SUCCEEDED(CoInitialize(NULL));

    CComQIPtr<DigitalOfficePro_Html5PointSdk::IPresentationConverter> pConverter;
    HRESULT hr = pConverter.CoCreateInstance(__uuidof(DigitalOfficePro_Html5PointSdk::PresentationConverter));
    if (FAILED(hr))
    {
        wprintf(L"Html5Point SDK is not installed.\n");
        return 1;
    }

    pConverter->Settings->CreateDirectoryForOutput = true;

    wprintf(L"Opening the presentation %s\n", argv[1]);
    hr = pConverter->OpenPresentation(argv[1]);
    if (FAILED(hr))
    {
        _bstr_t errorDescription = pConverter->LastErrorDescription;
        wprintf(L"Can't open the presentation %s.\nError description is: %s\n", argv[1], errorDescription);
        return 3;
    }

    wprintf(L"Converting to HTML5 file %s\n", argv[2]);
    hr = pConverter->Convert(argv[2]);
    if (FAILED(hr))
    {
        _bstr_t errorDescription = pConverter->LastErrorDescription;
        wprintf(L"Can't generate html5 file %s.\nError description is: %s\n", argv[2], errorDescription);
        return 4;
    }

    hr = pConverter->ClosePresentation();
    if (FAILED(hr))
    {
        _bstr_t errorDescription = pConverter->LastErrorDescription;
        wprintf(L"Can't close presentation.\nError description is: %s\n", errorDescription);
        return 5;
    }

    wprintf(L"Done\n");

    if (initialized)
        CoUninitialize();

    return 0;
}

PHP PHP Code

Use the DOTNET class to instantiate the SDK and call the conversion. Update Version and PublicKeyToken to match your installed DigitalOfficePro.Html5PointSdk.dll.

// **********************************************************************
$objPresentationConverter = new DOTNET(
    "DigitalOfficePro.Html5PointSdk, Version=1.2.8.2, Culture=neutral, PublicKeyToken=5e90c5baa3624fc1",
    "DigitalOfficePro.Html5PointSdk.PresentationConverter"
);

$presentationPath = "C:\\Test\\input.pptx";
$outputPath       = "C:\\Test\\output.html";

$objPresentationConverter->OpenPresentation($presentationPath);
$objPresentationConverter->Convert($outputPath);
$objPresentationConverter->ClosePresentation();
// **********************************************************************

// Locate your installed DLL at:
//   C:\Program Files (x86)\DigitalOfficePro\HTML5PointSDK\Include\DigitalOfficePro.Html5PointSdk.dll
// then update Version and PublicKeyToken accordingly:
$objPresentationConverter = new DOTNET(
    "DigitalOfficePro.Html5PointSdk, Version=<your-version>, Culture=neutral, PublicKeyToken=<your-token>",
    "DigitalOfficePro.Html5PointSdk.PresentationConverter"
);

PY Python Code

You'll need IronPython to call .NET SDK components from Python.

  1. Download and install IronPython.
  2. Start Python by running ipy.exe from the IronPython install folder.
  3. Copy DigitalOfficePro.Html5PointSDK.dll to %ironPython-installpath%/Dlls.
  4. Run the following code in the Python interface:
# Simple python converter
import clr

# Before calling the following function copy
# DigitalOfficePro.Html5PointSDK.dll to %ironPython installpath%/Dlls
clr.AddReference("DigitalOfficePro.HTML5PointSDK")
# clr.AddReferenceToFile("DigitalOfficePro.Html5PointSDK.dll")

from DigitalOfficePro import *
import DigitalOfficePro
import DigitalOfficePro.Html5PointSdk
from DigitalOfficePro.Html5PointSdk import *

converter = PresentationConverter()
converter.OpenPresentation("e:\\test.pptx")
converter.Convert("e:\\output.html")
converter.ClosePresentation()

Need the full programmer's guide?

Browse the online SDK documentation for the complete API reference.

Open SDK guide →