Hi.
When we want to render a page in web app, we call the page.toPixmap (this is done in a worker to not freeze UI). But the problem is, suppose the user clicks the Next button continuously, then we end up with sequence of calls to page.toPixmap. Once the user finally stopped clicking Next, we need to wait for all the intermediate pages to be rendered and discarded to get the output for current page.
pdf.js returns RenderTask which can be canceled when the rendering is no longer required.
Is there a way to do the same in MuPDF?
I thought of doing something like using microtasks on the worker side:
- Divide the page into fixed blocks of a size, like say 64x64.
- Use
matrix argument of page.toPixmap to decide which block to be rendered.
- If the request is cancelled in-between, then stop immediately.
- Else continue for all the blocks.
- Use an
OffscreenCanvas to render the blocks together as the final image.
Does this sound good? Or does MuPDF offer a better way to do progressive rendering?
Thank you.
Hi.
When we want to render a page in web app, we call the
page.toPixmap(this is done in a worker to not freeze UI). But the problem is, suppose the user clicks theNextbutton continuously, then we end up with sequence of calls topage.toPixmap. Once the user finally stopped clickingNext, we need to wait for all the intermediate pages to be rendered and discarded to get the output for current page.pdf.jsreturnsRenderTaskwhich can becanceled when the rendering is no longer required.Is there a way to do the same in MuPDF?
I thought of doing something like using microtasks on the worker side:
matrixargument ofpage.toPixmapto decide which block to be rendered.OffscreenCanvasto render the blocks together as the final image.Does this sound good? Or does MuPDF offer a better way to do progressive rendering?
Thank you.