Progress bar for XOD conversion

After a user uploads a PDF document in our product, we convert that document to XOD. This can take several minutes for a very large document, so we want to show a progress bar to them showing the status of the conversion.

This thread had the same question, but the answer didn't solve the problem for me:!searchin/pdfnet-sdk/progress/pdfnet-sdk/ow-9iUmxCts/DPhFNrVRZ1QJ

The example in the answer above shows the bytes that have been converted, but without knowing the total size of the XOD file ahead of time, it isn't helpful in terms of providing a progress bar.

We are using PHP. Here is our code:

$filter = Convert::ToXod($this->pdfdoc(), $options);

$fReader = new FilterReader($filter);

$buffer = 64 * 1024; //64 KB chunks

$totalBytes = 0;
$fd = fopen("output-file.xod", 'w');

while ($bytesRead = $fReader->Read($buffer)) {
    fputs($fd, $bytesRead);

    $totalBytes += strlen($bytesRead);


Since I don't know the size of $totalBytes until the conversion is done, I can't show a progress bar. Is there a way to get the bytes that have been read (of the original pdf) instead of the bytes written to the XOD file?

Hi Thomas,

We are actually in the progress of doing this now. I will post back here when it is available.

Did this feature make it into a release? I’m dealing with some PDFs that take several minutes for conversion, too.


Donald Gordon

Hi Donald,

Thank you for letting us know this is important for you. This is not yet available, but your feedback helps us prioritize. In the meantime you could base progress off of the source file size, though of course if the output is smaller, then progress will jump to 100%, or if the output is larger it will sit at 100% for a while. Also, there is some work at the beginning, before the bytes are available, so progress might be 0% for a while.

So, you could do the following in the meantime.
Indefinite progress indicator until first read completes.
Then progress based off the bytes read relative to the source file size, but cap at say 95%, for the case where the output is larger, then worst case progress sits at 95% for a while.