WorkerProxy
Defined in: src/context/worker-proxy.ts:138
Worker proxy for off-main-thread PDF processing.
Provides the same API as the main-thread implementation but executes all operations in a Web Worker.
Example
Section titled “Example”await using proxy = await WorkerProxy.create(workerUrl, wasmBinary);const doc = await proxy.openDocument(pdfArrayBuffer);Extends
Section titled “Extends”Accessors
Section titled “Accessors”disposed
Section titled “disposed”Get Signature
Section titled “Get Signature”get disposed():
boolean
Defined in: src/core/disposable.ts:73
Whether this resource has been disposed.
Returns
Section titled “Returns”boolean
Inherited from
Section titled “Inherited from”Methods
Section titled “Methods”[asyncDispose]()
Section titled “[asyncDispose]()”[asyncDispose]():
Promise<void>
Defined in: src/core/disposable.ts:195
Asynchronously dispose of this resource.
Returns
Section titled “Returns”Promise<void>
Inherited from
Section titled “Inherited from”AsyncDisposable.[asyncDispose]
closeDocument()
Section titled “closeDocument()”closeDocument(
documentId):Promise<void>
Defined in: src/context/worker-proxy.ts:252
Close a document.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
documentId | string | Document ID returned from openDocument |
Returns
Section titled “Returns”Promise<void>
Throws
Section titled “Throws”If the document cannot be closed
closePage()
Section titled “closePage()”closePage(
pageId):Promise<void>
Defined in: src/context/worker-proxy.ts:285
Close a page.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
pageId | string | Page ID returned from loadPage |
Returns
Section titled “Returns”Promise<void>
Throws
Section titled “Throws”If the page cannot be closed
dispose()
Section titled “dispose()”dispose():
Promise<void>
Defined in: src/core/disposable.ts:206
Alias for Symbol.asyncDispose for explicit calls.
Returns
Section titled “Returns”Promise<void>
Inherited from
Section titled “Inherited from”getPageCount()
Section titled “getPageCount()”getPageCount(
documentId):Promise<number>
Defined in: src/context/worker-proxy.ts:263
Get the page count of a document.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
documentId | string | Document ID |
Returns
Section titled “Returns”Promise<number>
The page count
Throws
Section titled “Throws”If the page count cannot be retrieved
getPageSize()
Section titled “getPageSize()”getPageSize(
pageId):Promise<PageSizeResponse>
Defined in: src/context/worker-proxy.ts:296
Get the size of a page.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
pageId | string | Page ID |
Returns
Section titled “Returns”Promise<PageSizeResponse>
The page size
Throws
Section titled “Throws”If the page size cannot be retrieved
getText()
Section titled “getText()”getText(
pageId):Promise<string>
Defined in: src/context/worker-proxy.ts:333
Get text content from a page.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
pageId | string | Page ID |
Returns
Section titled “Returns”Promise<string>
The text content
Throws
Section titled “Throws”If text extraction fails
getTextLayout()
Section titled “getTextLayout()”getTextLayout(
pageId):Promise<{rects:Float32Array;text:string; }>
Defined in: src/context/worker-proxy.ts:343
Get text rects from a page.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
pageId | string | Page ID |
Returns
Section titled “Returns”Promise<{ rects: Float32Array; text: string; }>
Object with text and flat array of coordinates [left, right, bottom, top]
loadPage()
Section titled “loadPage()”loadPage(
documentId,pageIndex):Promise<LoadPageResponse>
Defined in: src/context/worker-proxy.ts:275
Load a page from a document.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
documentId | string | Document ID |
pageIndex | number | Zero-based page index |
Returns
Section titled “Returns”Promise<LoadPageResponse>
The page info
Throws
Section titled “Throws”If the page cannot be loaded
openDocument()
Section titled “openDocument()”openDocument(
data,password?):Promise<OpenDocumentResponse>
Defined in: src/context/worker-proxy.ts:242
Open a PDF document.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
data | ArrayBuffer | PDF file data |
password? | string | Optional password for encrypted documents |
Returns
Section titled “Returns”Promise<OpenDocumentResponse>
The document info
Throws
Section titled “Throws”If the document cannot be opened
ping()
Section titled “ping()”ping(
timeout):Promise<boolean>
Defined in: src/context/worker-proxy.ts:356
Check if the worker is alive and responsive.
Sends a lightweight PING message and waits for a response.
Parameters
Section titled “Parameters”| Parameter | Type | Default value | Description |
|---|---|---|---|
timeout | number | 5_000 | Timeout in milliseconds (default: 5000) |
Returns
Section titled “Returns”Promise<boolean>
true if the worker responded within the timeout, false otherwise
Throws
Section titled “Throws”Never — errors are caught internally and returned as false
renderPage()
Section titled “renderPage()”renderPage(
pageId,options,onProgress?):Promise<RenderResult>
Defined in: src/context/worker-proxy.ts:309
Render a page.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
pageId | string | Page ID |
options | RenderOptions | Render options |
onProgress? | ProgressCallback | Optional progress callback |
Returns
Section titled “Returns”Promise<RenderResult>
The render result
Throws
Section titled “Throws”If rendering fails
create()
Section titled “create()”
staticcreate(workerUrl,wasmBinary,options?):Promise<WorkerProxy>
Defined in: src/context/worker-proxy.ts:175
Create a new worker proxy.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
workerUrl | string | URL | URL to the worker script |
wasmBinary | ArrayBuffer | Pre-loaded WASM binary |
options? | WorkerProxyOptions | Optional configuration |
Returns
Section titled “Returns”Promise<WorkerProxy>
The worker proxy instance
Throws
Section titled “Throws”If worker creation or initialisation fails