Coroutines and asynchronous jobs
All MarkpdfClient methods are suspend fun: they do not block the thread while waiting for the HTTP response, and they integrate naturally with viewModelScope, lifecycleScope, Dispatchers.IO, or any CoroutineScope of their own.
Additionally, there is a separate mechanism on the server: when all conversion backends are saturated, the API responds 202 with a job_id instead of blocking the request. See GET /jobs/{id}.
Basic use with runBlocking
For scripts or main():
From ViewModel (Android)
Parallel conversions with async
Aggressively parallelizing requests can trigger 429. Limit concurrency (for example with Semaphore(n) around each async) if you convert many documents at once.
Jobs due to saturation (202)
By default, all conversion methods handle 202 transparently (ConvertOptions.autoPoll is true):
Poll manual
Expose progress as Flow
Under normal load conditions you won’t see 202 — it only happens when all backends are saturated. autoPoll: true (the default) already covers it without additional code in most cases.
Results for completed jobs expire in approximately 1 hour. If you save a jobId and receive 404 when querying it, resend the original conversion.