取消转换任务
ComPDF Conversion SDK 支持随时中断您正在进行的转档任务,以下示例演示了如何中断您正在进行的转档任务。
kotlin
// Implement the `ConvertCallback` interface to receive conversion progress updates, and to control cancellation of the conversion task.
class ConversionTask(
var path: String,
var outputPath: String,
var options: WordOptions
) : ConvertCallback {
override fun onProgress(current: Int, total: Int) {
println("progress: $current / $total")
}
// When the conversion task is running, set `cancelled` to true to interrupt the ongoing conversion task.
@Volatile
var cancelled: Boolean = false
override fun isCancelled() {
return cancelled
}
fun startTask() {
val errorCode = ComPDFConverter.startPDFToWord(path, "", outputPath, options, this)
}
}