Listening to conversion process events
Leave feedback
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:
- Create your own implementation of the IConverterListener interface.
- Instantiate the ConverterSettings class and pass an instance of the class created in the first step.
- Pass the ConverterSettings object factory to the constructor of a Converter class.
- 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);
}
}
}
Was this page helpful?
Any additional feedback you'd like to share with us?
Please tell us how we can improve this page.
Thank you for your feedback!
We value your opinion. Your feedback will help us improve our documentation.