Thanks for sharing this!
I've been wondering what the advantages are compared to FPDF_LoadCustomDocument(), but here's an attempt at a self-answer:
- Obviously, we can use download hints rather than blind forward downloading. (Esp. useful if we don't want to read from the first page onward, but move to a later page early on.)
- The non-blocking API design allows us to abort a pending operation, e.g. if the user is initially waiting on P but then switches to X, we don't have to wait for P to finish, but can proceed to X immediately.
Anything else?
Further, is downloading supposed to happen in the same thread, or in a separate thread? In the latter case, would we need any kind of mutexing?
I imagine, if the incoming spans being fed into the callback are small, that it could all happen on the same thread, but that we would need ability to interrupt the downloading of a span if they are larger?
Or would the downloading function let us plug in an interruption callback to periodically check in some internal loop, similar to the progressive rendering API provided by pdfium?