Skip to content

cant call PdfDocumentRefCustom in web and not PdfDocumentRefUri support range based fetch #616

@moizali2134

Description

@moizali2134

Description

I am attempting to implement HTTP Range-based progressive PDF loading in a Flutter Web application using pdfrx. My backend API correctly supports byte-range requests (Accept-Ranges, Content-Range, 206 Partial Content). However, the current Web implementation of pdfrx appears to prevent range-based streaming due to limitations in the WASM backend.

There are two main blockers:

  1. PdfDocumentRefCustom not implemented on Web

Attempting to use a custom reader:

return PdfDocumentRefCustom(
sourceName: filename,
fileSize: reader.fileSize,
read: reader.read,
onDispose: reader.dispose,
);

results in the runtime error:

pdfrxentrywasmimpl.openCustom is not implemented

This prevents implementing a custom HTTP range reader, which would otherwise allow progressive loading.

  1. preferRangeAccess not supported on Web

Using:

PdfDocumentRefUri(
Uri.parse(url),
preferRangeAccess: true,
)

does not trigger range requests in Flutter Web.

From the documentation:

preferRangeAccess: Not supported on Web

As a result, the WASM backend always downloads the entire PDF file via fetch() before rendering.

Expected Behavior

Ideally one of the following should be supported on Web:

PdfDocumentRefCustom implemented for WASM so a custom byte reader can be used

preferRangeAccess supported in PdfDocumentRefUri

A streaming API exposed by pdfrx_engine to enable HTTP range access

This would allow progressive loading for large PDFs (e.g., 50–200MB) using a range-capable backend.

Current Behavior

On Flutter Web:

PdfDocumentRefCustom → not implemented

preferRangeAccess → ignored

Viewer performs full file download

Server logs confirm that no Range header is sent.

Example request:

GET /api/pdfs/file
Range: undefined
Backend

Backend supports HTTP range streaming:

Accept-Ranges: bytes
Content-Range
206 Partial Content
HEAD requests

PDF files are also linearized.

Use Case

Large PDF libraries (50–200MB files) where progressive streaming is necessary to reduce initial load time.

Without range streaming, the viewer must download the entire PDF before rendering.

Question

Is there any plan to support either:

PdfDocumentRefCustom for WASM

or HTTP Range access in the Web implementation?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions