Skip to main content

Streaming and asynchronous jobs

@markpdf/react-native does not expose convertStream — Fragment streaming (ReadableStream) has inconsistent support between the RN JS engine (Hermes/JSC) and RN versions. To show progress to the user, use the upload progress of useConvertFile, and for large documents consider pages to request smaller ranges instead of response streaming.

Upload progress with useConvertFile

useConvertFile uses XMLHttpRequest (available as global in React Native) instead of fetch, because fetch does not expose upload progress events in any JS runtime.

Jobs due to saturation (202)

convertLocalFile and convertFromUrl handle 202 automatically with autoPoll: true (default):

Poll manual

In a mobile app with intermittent connection, consider an explicit timeoutMs in waitForJob to not leave the UI waiting indefinitely if the user loses signal.
If the app goes to the background during the poll (the user exits the app), the waitForJob timer may be paused depending on the operating system. Upon returning to foreground, if jobId is still in effect (within ~1 hour), you can resume the poll by calling getJob(jobId) again.