@build-qube/papyra-native-wasm32-wasi 0.1.0 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/papyra.wasi.d.cts +144 -4
- package/papyra.wasm32-wasi.wasm +0 -0
package/package.json
CHANGED
package/papyra.wasi.d.cts
CHANGED
|
@@ -33,13 +33,22 @@ export declare class PdfDocument {
|
|
|
33
33
|
/** Load an encrypted PDF. */
|
|
34
34
|
static loadWithPassword(data: Uint8Array, password: string): PdfDocument
|
|
35
35
|
get pageCount(): number
|
|
36
|
+
/** The PDF specification version the file declares, e.g. `"1.7"`. */
|
|
37
|
+
get pdfVersion(): string | null
|
|
36
38
|
pageSize(index: number): PageDimensions
|
|
37
39
|
/** Render one page on the calling thread. Blocks; prefer `renderPageAsync`. */
|
|
38
|
-
renderPage(index: number, dpi?: number | undefined | null): RenderedPage
|
|
40
|
+
renderPage(index: number, dpi?: number | undefined | null, annotations?: boolean | undefined | null): RenderedPage
|
|
39
41
|
/** Render one page off the JS thread. Several of these run concurrently. */
|
|
40
|
-
renderPageAsync(index: number, dpi?: number | undefined | null): Promise<RenderedPage>
|
|
42
|
+
renderPageAsync(index: number, dpi?: number | undefined | null, annotations?: boolean | undefined | null): Promise<RenderedPage>
|
|
41
43
|
/** Render one page and keep it in Rust, for encoding. The pixels never reach JS. */
|
|
42
|
-
renderPageImageAsync(index: number, dpi?: number | undefined | null, signal?: AbortSignal | undefined | null): Promise<PageImage>
|
|
44
|
+
renderPageImageAsync(index: number, dpi?: number | undefined | null, annotations?: boolean | undefined | null, signal?: AbortSignal | undefined | null): Promise<PageImage>
|
|
45
|
+
/**
|
|
46
|
+
* Convert one page to a standalone SVG document, off the JS thread.
|
|
47
|
+
*
|
|
48
|
+
* There is no DPI: an SVG carries the page's own point dimensions and rasterises at
|
|
49
|
+
* whatever size it is drawn.
|
|
50
|
+
*/
|
|
51
|
+
renderPageSvgAsync(index: number, whiteBackground?: boolean | undefined | null, annotations?: boolean | undefined | null, signal?: AbortSignal | undefined | null): Promise<string>
|
|
43
52
|
/** Extract the text of one page, off the JS thread. */
|
|
44
53
|
pageTextAsync(index: number): Promise<PageText>
|
|
45
54
|
/** Extract `[start, end)` in one async task, parallelised internally with rayon. */
|
|
@@ -51,8 +60,67 @@ export declare class PdfDocument {
|
|
|
51
60
|
* common case.
|
|
52
61
|
*/
|
|
53
62
|
outline(): Promise<Array<OutlineEntry>>
|
|
63
|
+
/**
|
|
64
|
+
* Read the document structure tree (tagged PDF), in pre-order.
|
|
65
|
+
*
|
|
66
|
+
* Resolves to an empty array when the document is untagged, which is the common
|
|
67
|
+
* case. Join to text through `TextLine.mcid` and `StructEntry.content`.
|
|
68
|
+
*/
|
|
69
|
+
structTree(): Promise<Array<StructEntry>>
|
|
70
|
+
/**
|
|
71
|
+
* List the files embedded in the document, in the order it files them.
|
|
72
|
+
*
|
|
73
|
+
* Resolves to an empty array when there are none, which is the common case.
|
|
74
|
+
* Metadata only — fetch the bytes with `attachmentData`.
|
|
75
|
+
*/
|
|
76
|
+
attachments(): Promise<Array<Attachment>>
|
|
77
|
+
/** Decompress one embedded file, by its index in `attachments`. */
|
|
78
|
+
attachmentData(index: number): Promise<Uint8Array>
|
|
79
|
+
/**
|
|
80
|
+
* Read the document information dictionary.
|
|
81
|
+
*
|
|
82
|
+
* Synchronous: hayro parses it while loading, so this only decodes eight strings.
|
|
83
|
+
*/
|
|
84
|
+
info(): DocumentInfo
|
|
85
|
+
/**
|
|
86
|
+
* Read the links on one page.
|
|
87
|
+
*
|
|
88
|
+
* Resolves to an empty array for a page with no links, which is most pages.
|
|
89
|
+
*/
|
|
90
|
+
pageLinks(index: number): Promise<Array<PageLink>>
|
|
91
|
+
/**
|
|
92
|
+
* Read the label printed on each page, one entry per page.
|
|
93
|
+
*
|
|
94
|
+
* Resolves to an empty array when the document defines no `/PageLabels`.
|
|
95
|
+
*/
|
|
96
|
+
pageLabels(): Promise<Array<string>>
|
|
54
97
|
/** Render `[start, end)` in one async task, parallelised internally with rayon. */
|
|
55
|
-
renderPagesAsync(start: number, end: number, dpi?: number | undefined | null): Promise<Array<RenderedPage>>
|
|
98
|
+
renderPagesAsync(start: number, end: number, dpi?: number | undefined | null, annotations?: boolean | undefined | null): Promise<Array<RenderedPage>>
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* One file embedded in the document. Metadata only; the bytes come from
|
|
103
|
+
* `attachmentData`.
|
|
104
|
+
*/
|
|
105
|
+
export interface Attachment {
|
|
106
|
+
/** The name to save the file under — `/UF`, else `/F`, else its key in the tree. */
|
|
107
|
+
name: string
|
|
108
|
+
/** The document's own description of what the file is for. */
|
|
109
|
+
description?: string
|
|
110
|
+
/** e.g. `"application/xml"`. Absent more often than not. */
|
|
111
|
+
mediaType?: string
|
|
112
|
+
/** Length in bytes, uncompressed, as the document claims it. A hint, not a promise. */
|
|
113
|
+
size?: number
|
|
114
|
+
/** ISO 8601. */
|
|
115
|
+
created?: string
|
|
116
|
+
/** ISO 8601. */
|
|
117
|
+
modified?: string
|
|
118
|
+
/**
|
|
119
|
+
* `Source`, `Data`, `Alternative`, `Supplement`, `EncryptedPayload` or
|
|
120
|
+
* `Unspecified` — what the file is to the document. A ZUGFeRD invoice's XML is
|
|
121
|
+
* `Alternative` or `Data`.
|
|
122
|
+
*/
|
|
123
|
+
relationship?: string
|
|
56
124
|
}
|
|
57
125
|
|
|
58
126
|
/** Name of the rendering backend, currently always `"hayro"`. */
|
|
@@ -67,6 +135,21 @@ export declare function backendName(): string
|
|
|
67
135
|
*/
|
|
68
136
|
export declare function configureThreadPool(threads: number, stackSizeMb?: number | undefined | null): number
|
|
69
137
|
|
|
138
|
+
/** The document information dictionary. Every field is independently optional. */
|
|
139
|
+
export interface DocumentInfo {
|
|
140
|
+
title?: string
|
|
141
|
+
author?: string
|
|
142
|
+
subject?: string
|
|
143
|
+
keywords?: string
|
|
144
|
+
/** The application that authored the original document, e.g. `AutoCAD`. */
|
|
145
|
+
creator?: string
|
|
146
|
+
/** The application that wrote the PDF itself, e.g. `Ghostscript`. */
|
|
147
|
+
producer?: string
|
|
148
|
+
/** ISO 8601, converted from the PDF's own date form. */
|
|
149
|
+
created?: string
|
|
150
|
+
modified?: string
|
|
151
|
+
}
|
|
152
|
+
|
|
70
153
|
/** Encode a raw RGBA8 buffer off the JS thread. */
|
|
71
154
|
export declare function encodeBitmap(data: Uint8Array, width: number, height: number, stride: number, format: ImageFormat, quality?: number | undefined | null, signal?: AbortSignal | undefined | null): Promise<Uint8Array>
|
|
72
155
|
|
|
@@ -86,6 +169,18 @@ export declare const enum ImageFormat {
|
|
|
86
169
|
Jpeg = 'jpeg'
|
|
87
170
|
}
|
|
88
171
|
|
|
172
|
+
/**
|
|
173
|
+
* The outline walk, off the JS thread.
|
|
174
|
+
*
|
|
175
|
+
* One run of page content owned by a structure element.
|
|
176
|
+
*/
|
|
177
|
+
export interface MarkedContent {
|
|
178
|
+
/** 0-based page index. */
|
|
179
|
+
page: number
|
|
180
|
+
/** Matches `TextLine.mcid` on that page. */
|
|
181
|
+
mcid: number
|
|
182
|
+
}
|
|
183
|
+
|
|
89
184
|
/**
|
|
90
185
|
* Where an outline entry points. Coordinates are PDF points from the page's
|
|
91
186
|
* bottom-left; `null` means "leave this axis unchanged".
|
|
@@ -123,6 +218,26 @@ export interface PageDimensions {
|
|
|
123
218
|
height: number
|
|
124
219
|
}
|
|
125
220
|
|
|
221
|
+
/**
|
|
222
|
+
* One link annotation.
|
|
223
|
+
*
|
|
224
|
+
* The rectangle is in the page-as-rendered space — pixels from the top-left at
|
|
225
|
+
* 72 DPI, rotation and crop box applied — so it is the same space as `PageText` and
|
|
226
|
+
* scales to any render with one multiply.
|
|
227
|
+
*/
|
|
228
|
+
export interface PageLink {
|
|
229
|
+
x0: number
|
|
230
|
+
y0: number
|
|
231
|
+
x1: number
|
|
232
|
+
y1: number
|
|
233
|
+
/** Set when the link points into this document; `uri` is then absent. */
|
|
234
|
+
dest?: OutlineDestination
|
|
235
|
+
/** Set when the link points at a URI; `dest` is then absent. */
|
|
236
|
+
uri?: string
|
|
237
|
+
/** The annotation's `/Contents` — its tooltip. Usually absent. */
|
|
238
|
+
alt?: string
|
|
239
|
+
}
|
|
240
|
+
|
|
126
241
|
/**
|
|
127
242
|
* The text of one page.
|
|
128
243
|
*
|
|
@@ -163,6 +278,26 @@ export declare function reserveMemory(megabytes: number): number
|
|
|
163
278
|
/** `"native"` or `"wasm"`. The wrapper uses this to pick a concurrency strategy. */
|
|
164
279
|
export declare function runtime(): string
|
|
165
280
|
|
|
281
|
+
/** One structure-tree element. Flat and in pre-order; `level` carries the tree. */
|
|
282
|
+
export interface StructEntry {
|
|
283
|
+
/** Standard structure type, after `/RoleMap`: `"H1"`, `"P"`, `"Table"`, `"TD"`, … */
|
|
284
|
+
role: string
|
|
285
|
+
/** The document's own tag, before `/RoleMap`. Equal to `role` unless remapped. */
|
|
286
|
+
rawRole: string
|
|
287
|
+
/** Nesting depth. Top-level elements are 0. */
|
|
288
|
+
level: number
|
|
289
|
+
/** Content this element owns directly. Empty for a pure container. */
|
|
290
|
+
content: Array<MarkedContent>
|
|
291
|
+
/** `/Alt` — replacement text for a figure. */
|
|
292
|
+
alt?: string
|
|
293
|
+
/** `/ActualText` — text replacing the content rather than describing it. */
|
|
294
|
+
actualText?: string
|
|
295
|
+
/** `/Lang` — a BCP 47 tag for this subtree. */
|
|
296
|
+
lang?: string
|
|
297
|
+
/** `/T` — a human-readable title, e.g. a table's caption. */
|
|
298
|
+
title?: string
|
|
299
|
+
}
|
|
300
|
+
|
|
166
301
|
/**
|
|
167
302
|
* A run of glyphs sharing one baseline.
|
|
168
303
|
*
|
|
@@ -188,4 +323,9 @@ export interface TextLine {
|
|
|
188
323
|
ascent: number
|
|
189
324
|
/** Extent below the baseline. */
|
|
190
325
|
descent: number
|
|
326
|
+
/**
|
|
327
|
+
* Marked-content id of the line's first glyph, joining to `StructNode.content` on
|
|
328
|
+
* a tagged page. `null` on an untagged page, and for content outside any sequence.
|
|
329
|
+
*/
|
|
330
|
+
mcid?: number
|
|
191
331
|
}
|
package/papyra.wasm32-wasi.wasm
CHANGED
|
Binary file
|