Skip to content
全新发布

PDF SDK 与 AI 文档处理

在 GitHub 获取完整的私有化部署SDK 包及 AI 智能文档处理能力,一键部署,快速构建您的文档处理工作流。

取消转换任务

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)
    }
}