Listening to conversion process events

In some cases, there is a need to monitor the conversion process and to receive updates upon a start, progress and completion of a conversion. For such situations, GroupDocs.Conversion exposes an extension point where the client application may hook up and receive updates. 

To enable listening, follow these steps:

  1. Create your own implementation of the IConverterListener interface.
  2. Instantiate the ConverterSettings class and pass an instance of the class created in the first step.
  3. Pass the ConverterSettings object factory to the constructor of a Converter class.
  4. Call the Convert method of the Converter class.

The following code snippet shows how to enable listening for GroupDocs.Conversion:

import com.groupdocs.conversion.Converter;
import com.groupdocs.conversion.ConverterSettings;
import com.groupdocs.conversion.options.convert.PdfConvertOptions;
import com.groupdocs.conversion.reporting.IConverterListener;
...
public class ConverterListener implements IConverterListener
	{
	    public void started()
	    {
	        System.out.println("Conversion started...");
	    }
	    public void progress(byte current)
	    {
	        System.out.println("... " + current + "% ...");
	    }
	    public void completed()
	    {
	        System.out.println("... conversion completed");
	    }
	
    public static void run()
    {              
        IConverterListener listener = new ConverterListener();        
        ConverterSettings settingsFactory = new ConverterSettings();
        settingsFactory.setListener(listener); 
                
        try(Converter converter = new Converter("sample.docx", settingsFactory))
        {
            PdfConvertOptions options = new PdfConvertOptions();
            converter.convert("converted.pdf", options);
        } 
    }
}