Skip to content
ComPDF
DemoFAQ
New Release

Open-Source PDF SDK & AI Document Processing

Get the full self-hosted SDK and AI document processing on GitHub. One-click deploy to quickly build your document workflows.

Get Conversion Progress

Starting with the PHP SDK v4.1.0, every Conversion::pdfTo*() method accepts an optional ConvertCallback argument that mirrors the C++ CConvertCallback struct. Assigning a callable to $onProgress makes the SDK invoke it after each page is processed.

The callback is invoked synchronously from the same OS thread that called the conversion function — PHP FFI does not support cross-thread callbacks.

php
use ComPDFKit\Conversion\Conversion;
use ComPDFKit\Conversion\ConvertCallback;
use ComPDFKit\Conversion\ConvertOption;

$cb = new ConvertCallback();
$cb->onProgress = static function (int $currentPage, int $totalPage): void {
    printf("progress: %d / %d\n", $currentPage, $totalPage);
};

$option = new ConvertOption();
Conversion::pdfToWord('input.pdf', '', 'output.docx', $option, $cb);