iSpring._iSpringEvents Interface

The _iSpringEvents Interface provides information about presentation conversion progress. When one of the conversion progress event occurs the corresponding method of this interface is called. In order to track conversion progress it is necessary to add handlers for specified methods in application.

Table 1. Methods
Method Method description
OnStartConversion(ConversionMode cm) Occurs when the presentation conversion is started.
OnStartCollectingData() Occurs when the collecting data about presentation is started.
OnStartProcessingData() Occurs when the presentation procesing is started.
OnStartSwfWriting(string filePath) Occurs when the output file writing is started.
OnSlideProgressChanged(int slideIndex, int totalSlides) Occurs when the slide conversion progress is changed.
OnSlideItemProgressChanged( int slideItemIndex, int totalSlideItems) Occurs when the regular slide conversion is finished.
OnStartProcessingVideo() Occurs when the video object processing is stared.
OnVideoProgressChanged(double progress) Occurs when the video object processing progress is changed.
OnFinishProcessingVideo() Occurs when the video object processing is finished.
OnFinishCollectingData() Occurs when the collecting data about presentation is finished.
OnFinishProcessingData() Occurs when the presentation data processing is finished.
OnFinishSwfWriting() Occurs when the swf file writing is is finished.
OnFinishConversion() Occurs when the presentation conversion is finished.
OnIdle() Occurs constantly during during conversation process. This event can be used for updating user interface.

Samples

The following samples illustrate a way of addings event handlers for _iSpringEvents in different programming languages.

Language Sample code
C#
using System;
using System.Collections.Generic;
using System.Text;
using iSpring;

namespace ispring_samples
{

public class Р РЋonverter
{
    static void Main(String[] args)
    {
        PresentationConverter converter = new PresentationConverter();
        try
        {
            converter.OnStartConversion += new _iSpringEvents_OnStartConversionEventHandler(converter_OnStartConversion);
            converter.OnFinishConversion += new _iSpringEvents_OnFinishConversionEventHandler(converter_OnFinishConversion);

            converter.OnStartProcessingData += new _iSpringEvents_OnStartProcessingDataEventHandler(converter_OnStartProcessingData);
            converter.OnFinishProcessingData += new _iSpringEvents_OnFinishProcessingDataEventHandler(converter_OnFinishProcessingData);

            converter.OnStartSwfWriting += new _iSpringEvents_OnStartSwfWritingEventHandler(converter_OnStartSwfWriting);
            converter.OnFinishSwfWriting += new _iSpringEvents_OnFinishSwfWritingEventHandler(converter_OnFinishSwfWriting);

            converter.OnSlideItemProgressChanged += new _iSpringEvents_OnSlideItemProgressChangedEventHandler(converter_OnSlideItemProgressChanged);
            converter.OnSlideProgressChanged += new _iSpringEvents_OnSlideProgressChangedEventHandler(converter_OnSlideProgressChanged);

            converter.OnStartProcessingVideo += new _iSpringEvents_OnStartProcessingVideoEventHandler(converter_OnStartProcessingVideo);
            converter.OnVideoProgressChanged += new _iSpringEvents_OnVideoProgressChangedEventHandler(converter_OnVideoProgressChanged);
            converter.OnFinishProcessingVideo += new _iSpringEvents_OnFinishProcessingVideoEventHandler(converter_OnFinishProcessingVideo);

            converter.OnIdle += new _iSpringEvents_OnIdleEventHandler(converter_OnIdle);

            converter.OpenPresentation("C:\\1.ppt");

            converter.GenerateSolidPresentation("C:\\1.swf", "", "");
            converter.ClosePresentation();
        }
        catch (Exception )
        {
            PrintMessage(("Error: " + converter.LastErrorDescription));
        }
    }

    private static void PrintMessage(String message)
    {
        Console.Out.WriteLine(message);
    }

    private static void converter_OnStartConversion(ConversionMode cm)
    {
        PrintMessage("Conversion started");
    }

    private static void converter_OnFinishConversion()
    {
        PrintMessage("Conversion finished");
    }

    private static void converter_OnStartProcessingData()
    {
        PrintMessage("Data processing started");
    }

    private static void converter_OnFinishProcessingData()
    {
        PrintMessage("Data processing finished");
    }

    private static void converter_OnStartSwfWriting(String fileName)
    {
        PrintMessage("SWF file writing started");
    }

    private static void converter_OnFinishSwfWriting()
    {
        PrintMessage("SWF file writing finished");
    }

    private static void converter_OnSlideItemProgressChanged(int slideItemIndex, int totalSlideItems)
    {
        PrintMessage(String.Format("Processing slide item {0} / {1}", slideItemIndex + 1, totalSlideItems));
    }

    private static void converter_OnSlideProgressChanged(int slideIndex, int totalSlides)
    {
        PrintMessage(String.Format("Processing slide {0} / {1}", slideIndex + 1, totalSlides));
    }

    private static void converter_OnStartProcessingVideo()
    {
        PrintMessage("Video processing started");
    }

    private static void converter_OnVideoProgressChanged(double progress)
    {
        PrintMessage(String.Format("Video processing progress {0}%", progress * 100));
    }

    private static void converter_OnFinishProcessingVideo()
    {
        PrintMessage("Video processing finished");
    }

    private static void converter_OnIdle()
    {
    // Do nothing here
    }
}
}
        
Visual Basic .NET
Imports iSpring

Public Class Р РЋonverter

    Shared Sub Main(ByVal args() As [String])
        Dim converter As PresentationConverter = New PresentationConverter
        Try
            AddHandler converter.OnStartConversion, AddressOf converter_OnStartConversion
            AddHandler converter.OnFinishConversion, AddressOf converter_OnFinishConversion

            AddHandler converter.OnStartProcessingData, AddressOf converter_OnStartProcessingData
            AddHandler converter.OnFinishProcessingData, AddressOf converter_OnFinishProcessingData

            AddHandler converter.OnStartSwfWriting, AddressOf converter_OnStartSwfWriting
            AddHandler converter.OnFinishSwfWriting, AddressOf converter_OnFinishSwfWriting

            AddHandler converter.OnSlideItemProgressChanged, AddressOf converter_OnSlideItemProgressChanged
            AddHandler converter.OnSlideProgressChanged, AddressOf converter_OnSlideProgressChanged

            AddHandler converter.OnStartProcessingVideo, AddressOf converter_OnStartProcessingVideo
            AddHandler converter.OnVideoProgressChanged, AddressOf converter_OnVideoProgressChanged
            AddHandler converter.OnFinishProcessingVideo, AddressOf converter_OnFinishProcessingVideo

            AddHandler converter.OnIdle, AddressOf converter_OnIdle

            converter.OpenPresentation("C:\1.ppt")

            converter.GenerateSolidPresentation("C:\1.swf", "", "")
            converter.ClosePresentation
        Catch __exception As Exception
            PrintMessage(("Error: " + converter.LastErrorDescription))
        End Try
    End Sub

    Private Shared Sub PrintMessage(ByVal message As [String])
        Console.Out.WriteLine(message)
    End Sub

    Private Shared Sub converter_OnStartConversion(ByVal cm As ConversionMode)
        PrintMessage("Conversion started")
    End Sub

    Private Shared Sub converter_OnFinishConversion()
        PrintMessage("Conversion finished")
    End Sub

    Private Shared Sub converter_OnStartProcessingData()
        PrintMessage("Data processing started")
    End Sub

    Private Shared Sub converter_OnFinishProcessingData()
        PrintMessage("Data processing finished")
    End Sub

    Private Shared Sub converter_OnStartSwfWriting(ByVal fileName As [String])
        PrintMessage("SWF file writing started")
    End Sub

    Private Shared Sub converter_OnFinishSwfWriting()
        PrintMessage("SWF file writing finished")
    End Sub

    Private Shared Sub converter_OnSlideItemProgressChanged(ByVal slideItemIndex As Integer, ByVal totalSlideItems As Integer)
        PrintMessage(String.Format("Processing slide item {0} / {1}", slideItemIndex + 1, totalSlideItems))
    End Sub

    Private Shared Sub converter_OnSlideProgressChanged(ByVal slideIndex As Integer, ByVal totalSlides As Integer)
        PrintMessage(String.Format("Processing slide {0} / {1}", slideIndex + 1, totalSlides))
    End Sub

    Private Shared Sub converter_OnStartProcessingVideo()
        PrintMessage("Video processing started")
    End Sub

    Private Shared Sub converter_OnVideoProgressChanged(ByVal progress As Double)
        PrintMessage(String.Format("Video processing progress {0}%", progress * 100))
    End Sub

    Private Shared Sub converter_OnFinishProcessingVideo()
        PrintMessage("Video processing finished")
    End Sub

    Private Shared Sub converter_OnIdle()
        'Do nothing here
    End Sub
End Class
        
PHP
<?
// Event listener class
class CEventListener
{
    function OnStartConversion($mode)
    {
        echo "OnStartConversion\n";
    }

    function OnStartCollectingData()
    {
        echo "Data collecting started\n";
    }

    function OnFinishCollectingData()
    {
        echo "Data collecting finished\n";
    }

    function OnStartProcessingData()
    {
        echo "Data processing started\n";
    }

    function OnFinishProcessingData()
    {
        echo "Data processing finished\n";
    }

    function OnStartSwfWriting($filePath)
    {
        echo "SWF writing started. File path: $filePath\n";
    }

    function OnFinishSwfWriting()
    {
        echo "SWF writing finished\n";
    }

    function OnSlideProgressChanged($slideIndex, $totalSlides)
    {
        echo "  Processing slide " . ($slideIndex + 1) . " / $totalSlides\n";
    }
}

    $PPT_FILE = "../../media/presentations/quicktour.ppt";
    $SWF_FOLDER = "";
    $SWF_FILE = "quicktour.swf";

    $fs = new COM("iSpring.PresentationConverter");

    $listener =& new CEventListener();

    com_event_sink($fs, $listener, "_iSpringEvents");

    echo "Opening presentation\n";
    $fs->OpenPresentation($PPT_FILE);

    echo "Generating flash...\n";
    $fs->GenerateFlash($SWF_FOLDER, $SWF_FILE, 0, "Standard");

    echo "Done\n";


    // Warning! When you don't need iSpring object it is necessary to set it to null
    // otherwise error will occur when PHP script finishes.
    $fs = null;
?>