Skip to content
DemoFAQ

PDF 生成模板编辑器

开源可视化 PDF 生成引擎,支持自定义模板,并提供面向开发者的 API,灵活构建文档生成流程。

查看 GitHub

获取转换进度

ComPDF Conversion SDK 通过 ProgressCallback 接口的方式获取转换进度,以下示例演示了如何获取执行 PDF 转 Word 任务时的转换进度。

kotlin
// Implement the `ConvertCallback` interface to receive conversion progress updates.
class ConversionTask(
    var path: String,
    var outputPath: String,
    var options: WordOptions
) : ConvertCallback {

    override fun onProgress(current: Int, total: Int) {
        println("progress: $current / $total")
    }

    override fun isCancelled() {
        return false
    }

    fun startTask() {
        val errorCode = ComPDFConverter.startPDFToWord(path, "", outputPath, options, this)
    }
}