-
Notifications
You must be signed in to change notification settings - Fork 10.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to cancel or destroy a getPage request with disableAutoFetch set #11453
Comments
Huh, calling |
Oups. With
With Still, it looks like it is possible to cancel the _transport, but if one does that it is going to cancel all future requests.
Absolutely, the best way is not to call getPage if one should not. Still, this is not the point here 💯 and it is also better not to call getDocument if one should not. Is the following a workaround ?
|
There's no way of doing what you're asking, short of destroying the
First of all, note that there's a couple of different ways that data could be loaded (using Fetch, XMLHttpRequest, or a Hence what you're asking for isn't possible, nor will it be supported either unfortunately (as outlined above, and the use-case seems fairly specialized anyway). |
Ok. In my use case, I fetch say page [-1, current, 1] whenever the user moves to a page. If a user moves fast to another current page, I am going to cancelAllRequests().
Wait until all the requests are cancelled, and fetch the new [-1, current, 1] pages.
|
As explained in #11453 (comment) that will easily lead to all kinds of breakage, and isn't something that you should be calling manually (it's being used from
Please note that the default range request functionality in PDF.js isn't in any way connected with const loadingTask = getDocument({
range: /* custom PDFDataRangeTransport here */,
// more parameters here
}); |
OK. I am going to
What is the purpose of PDFDataRangeTransport ? Extending the range capabilities ? I found no examples or use cases out there Thank you for all your tips @Snuffleupagus 👍 |
It allows completely custom data delivery, that you thus can implement in what ever way you want/need in your case (it's being used in the PDF Viewer that's built-in to the Firefox browser). While it does allow a great deal of flexibility, it's consequently a fair bit more complex than just providing a URL when calling
There's the API unit-tests and also the default viewer usages here, here, here and finally here and here. |
Closing as answered by the comments above. |
I had a similar issue with very large non-linearized PDFs where I would quickly point out that it would be nice to be able to cancel an individual page load too though because, of course, page loading can sometimes take WAY longer than rendering. Hunting around the code it seems like during the |
Dear pdf.js contributors,
With
disableAutoFetch set
, is there a way to cancel fetching ongetPage()
? The same way onedestroy()
getDocument promiseIt looks like it is possible but I found only internal functions.
Best, A.
The text was updated successfully, but these errors were encountered: