Skip to content

SCHOL-853: Enable range requests for linearized pdfs - #210

Draft
jackiequach wants to merge 4 commits into
mainfrom
SCHOL-853/enable-linearized-urls
Draft

SCHOL-853: Enable range requests for linearized pdfs#210
jackiequach wants to merge 4 commits into
mainfrom
SCHOL-853/enable-linearized-urls

Conversation

@jackiequach

@jackiequach jackiequach commented Sep 4, 2026

Copy link
Copy Markdown
Collaborator

SCHOL-853

Description

Enables range requests for linearized pdfs to better view large documents.

  • getDocument() now passes disableStream: true, disableAutoFetch: true, and rangeChunkSize to 1MB (from pdf.js's 64KB default).

Windowed page size measurement

  • For non-linearized PDFs PdfReaderContent calls pdfDoc.getPage(i) for every page up front to measure layout height/width.
  • For linearized PDFs, it seeds every page with a placeholder size (DEFAULT_PAGE_SIZE) so the scroll container exists right away, then only measures the real size of the current page and currently-visible pages (± PAGE_MEASURE_BUFFER) as the user scrolls or navigates.
  • The placeholder for not-yet-measured pages is updated once the first batch is measured, using the largest width/height seen in that batch.
  • Scroll position is preserved across placeholder to actual size swaps using the existing captureViewportAnchor.

Lazy Table of Contents

  • resolveOutline() calls pdfDoc.getPageIndex() once per outline entry, which can require a separate range request per entry for documents whose outline touches most of the file.
  • Outline resolution is now deferred until the user requests it (opens the TOC panel).

Loading UX (PdfPage.tsx)

  • Added a loading indicator shown while a page's canvas/text/annotation layers are still rendering.

Testing

  • Manually verified against local 1230 page PDF initial loads:
    • Normal network (240 Mbps)
      • Before linearization: 834,226 KB (834.22 MB) transferred, 3.8 s
      • After linearization: 6,897 KB (6.897 MB) transferred, 813 ms
    • "Fast 4G" throttling
      • Before linearization: 834,226 KB transferred, 13.8 min
      • After linearization: 6,905 KB (6.905 MB) transferred, 13.39 s

Future work

  • Page size placeholders are not the best for Enhanced Search since the documents do not have uniform page dimensions. If largest page dimensions become available from the manifest then the logic around page measurement can be simplified.

@vercel

vercel Bot commented Sep 4, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
web-reader Ready Ready Preview Sep 4, 2026 8:38pm UTC

Request Review

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant