ConversionErrorEventHandler Delegate

Represents the method that will handle the Converter ConversionError event of the Converter.

public delegate void ConversionErrorEventHandler(Object sender, ConversionErrorEventArgs e)
Public Delegate Sub ConversionErrorEventHandler(sender As Object, e As ConversionErrorEventArgs)

Parameters

sender
Object

The source of the event.

Inheritance: ObjectDelegateMulticastDelegateConversionErrorEventHandler

Licensing Info

This delegate is a DynamicPDF Converter feature. One of the following is required for non-evaluation usage:

Examples

This example shows how to make use of ConversionError event.
Imports System.IO
Imports ceTe.DynamicPDF.Conversion        

Module Module1

    Sub Main()

        ' create an instance of AsyncConverter
        Dim converter As AsyncConverter = New AsyncConverter          

        ' Events to know if conversion completed successfully or not
        AddHandler converter.Converted, AddressOf converter_Converted
        AddHandler converter.ConversionError, AddressOf converter_ConversionError

        ' Call Convert method to start conversion asynchronously and  Get the status of conversion
        Dim asyncConversion As AsyncConversion = converter.Convert("C:\MyDocument.doc", "C:\MyOutput.pdf")
        While (True)
            If (asyncConversion.Completed) Then
                Dim MyData() As Byte = asyncConversion.GetOutputData()
                Exit While
            End If
            Else If(asyncConversion.Aborted || asyncConversion.Exception isNot Nothing)
                Exit While
        End While   
    End Sub

    Sub converter_Converted(ByVal sender As Object, ByVal e As ConvertedEventArgs)

        Console.WriteLine(e.SourceFilePath + " was converted successfully.")

    End Sub

    Sub converter_ConversionError(ByVal sender As Object, ByVal e As ConversionErrorEventArgs)

        Console.WriteLine(e.SourceFilePath + " conversion failed for the following reason:")
        Console.WriteLine("\"" + e.Exception.Message + " \ "")

    End Sub
End Module
using System;
using ceTe.DynamicPDF.Conversion;

class MyClass
{
    static void Main()
    {
        // create an instance of AsyncConverter
        AsyncConverter converter = new AsyncConverter();

        // Events to know if conversion completed successfully or not
        converter.Converted += new ConvertedEventHandler(converter_Converted);
        converter.ConversionError += new ConversionErrorEventHandler(converter_ConversionError);

        // Call Convert method to start conversion asynchronously and  Get the status of conversion
        AsyncConversion asyncConversion = converter.Convert(@"C:\MyDocument.doc", @"C:\MyOutput.pdf");
        while(true)
        {
            if (asyncConversion.Completed)
            {
                byte[] MyData = asyncConversion.GetOutputData();
                break;
            }
            else if(asyncConversion.Aborted || asyncConversion.Exception != null)
            {
                break;
            }
            
        }
    }

    private static void converter_Converted(object sender, ConvertedEventArgs e)
    {
        Console.WriteLine(e.SourceFilePath + " was converted successfully.");
    }

    private static void converter_ConversionError(object sender, ConversionErrorEventArgs e)
    {
        Console.WriteLine(e.SourceFilePath + " conversion failed for the following reason:");
        Console.WriteLine("\"" + e.Exception.Message + "\"");
    }
}

See Also

ceTe.DynamicPDF.Conversion

In this topic