Skip to content
DemoFAQ

取消转换任务

ComPDF Conversion SDK 支持随时中断您正在进行的转档任务,以下示例演示了如何中断您正在进行的转档任务。

java
class ProgressClass implements ConvertCallback {
    // When the conversion task is running, set `cancelled` to true to interrupt the ongoing conversion task.
    boolean cancelled = false;

    @Override
    public void onProgress(int current, int total) {
        System.out.printf("Current Progress: %d / %d%n", current, total);
    }

    @Override
    public boolean isCancelled() {
        return cancelled;
    }
}

CPDFConversion.startPDFToWord("word.pdf", "", "path/output.docx", new WordOptions(), new ProgressClass());