@build-qube/papyra-native-wasm32-wasi 0.1.0 → 0.2.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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@build-qube/papyra-native-wasm32-wasi",
3
- "version": "0.1.0",
3
+ "version": "0.2.0",
4
4
  "main": "papyra.wasi.cjs",
5
5
  "files": [
6
6
  "papyra.wasm32-wasi.wasm",
package/papyra.wasi.d.cts CHANGED
@@ -33,6 +33,8 @@ 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
40
  renderPage(index: number, dpi?: number | undefined | null): RenderedPage
@@ -40,6 +42,13 @@ export declare class PdfDocument {
40
42
  renderPageAsync(index: number, dpi?: number | undefined | null): Promise<RenderedPage>
41
43
  /** Render one page and keep it in Rust, for encoding. The pixels never reach JS. */
42
44
  renderPageImageAsync(index: number, dpi?: number | 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, 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,6 +60,24 @@ export declare class PdfDocument {
51
60
  * common case.
52
61
  */
53
62
  outline(): Promise<Array<OutlineEntry>>
63
+ /**
64
+ * Read the document information dictionary.
65
+ *
66
+ * Synchronous: hayro parses it while loading, so this only decodes eight strings.
67
+ */
68
+ info(): DocumentInfo
69
+ /**
70
+ * Read the links on one page.
71
+ *
72
+ * Resolves to an empty array for a page with no links, which is most pages.
73
+ */
74
+ pageLinks(index: number): Promise<Array<PageLink>>
75
+ /**
76
+ * Read the label printed on each page, one entry per page.
77
+ *
78
+ * Resolves to an empty array when the document defines no `/PageLabels`.
79
+ */
80
+ pageLabels(): Promise<Array<string>>
54
81
  /** Render `[start, end)` in one async task, parallelised internally with rayon. */
55
82
  renderPagesAsync(start: number, end: number, dpi?: number | undefined | null): Promise<Array<RenderedPage>>
56
83
  }
@@ -67,6 +94,21 @@ export declare function backendName(): string
67
94
  */
68
95
  export declare function configureThreadPool(threads: number, stackSizeMb?: number | undefined | null): number
69
96
 
97
+ /** The document information dictionary. Every field is independently optional. */
98
+ export interface DocumentInfo {
99
+ title?: string
100
+ author?: string
101
+ subject?: string
102
+ keywords?: string
103
+ /** The application that authored the original document, e.g. `AutoCAD`. */
104
+ creator?: string
105
+ /** The application that wrote the PDF itself, e.g. `Ghostscript`. */
106
+ producer?: string
107
+ /** ISO 8601, converted from the PDF's own date form. */
108
+ created?: string
109
+ modified?: string
110
+ }
111
+
70
112
  /** Encode a raw RGBA8 buffer off the JS thread. */
71
113
  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
114
 
@@ -123,6 +165,26 @@ export interface PageDimensions {
123
165
  height: number
124
166
  }
125
167
 
168
+ /**
169
+ * One link annotation.
170
+ *
171
+ * The rectangle is in the page-as-rendered space — pixels from the top-left at
172
+ * 72 DPI, rotation and crop box applied — so it is the same space as `PageText` and
173
+ * scales to any render with one multiply.
174
+ */
175
+ export interface PageLink {
176
+ x0: number
177
+ y0: number
178
+ x1: number
179
+ y1: number
180
+ /** Set when the link points into this document; `uri` is then absent. */
181
+ dest?: OutlineDestination
182
+ /** Set when the link points at a URI; `dest` is then absent. */
183
+ uri?: string
184
+ /** The annotation's `/Contents` — its tooltip. Usually absent. */
185
+ alt?: string
186
+ }
187
+
126
188
  /**
127
189
  * The text of one page.
128
190
  *
Binary file