Skip to content

Use #viewerContainer without position: absolute and overflow: auto #11626

Open
@hrst

Description

@hrst

I'm currently testing pdf.js and stuck with the components examples such as the simpleviewer. These work great with the #viewerContainer div having position: absolute and overflow: auto.

I understand this makes a lot of sense for a setup such as the default viewer, however, I'd like to display PDFs by adding it (basically) to the main body, i.e. utilizing the main browser window scrollbar. When I remove position: absolute and overflow: auto, the viewer works but loads all pages at once (I'm assuming because it cannot correctly detect which pages are visible to the user anymore).

I also tried using the pageviewer.js example, which again works great but here I did not really find good examples on how to, after loading the first page, continue loading pages on demand when they are visible to the user (and unloading them afterwards), and so on, i.e. lots of functionality that is already perfectly implemented in the default viewer. I tried extracting the relevant parts (as I do not need 95% of the other stuff such as search, annotation, thumbnails, etc.), but this obviously got out of hand quickly and I felt as if was on the wrong path.

Is there any basic example on how to use pdf.js in a div without position: absolute and overflow: auto, and loading and unloading pages on demand as they are viewed by the user?

Any help is highly appreciated, I really tried to work with the examples and documentation but I'm stuck.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions