Skip to content

Support for progressive rendering of a page #190

@arun-mani-j

Description

@arun-mani-j

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:

  1. Divide the page into fixed blocks of a size, like say 64x64.
  2. Use matrix argument of page.toPixmap to decide which block to be rendered.
  3. If the request is cancelled in-between, then stop immediately.
  4. Else continue for all the blocks.
  5. 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions