@docmentis/udoc-viewer 0.4.4 → 0.5.1
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/README.md +122 -18
- package/dist/package.json +19 -3
- package/dist/src/wasm/LICENSE +104 -0
- package/dist/src/wasm/udoc_bg.wasm +0 -0
- package/package.json +19 -3
package/README.md
CHANGED
|
@@ -1,8 +1,23 @@
|
|
|
1
1
|
# @docmentis/udoc-viewer
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
A free, open-source, universal document viewer for the web. Render PDF, PPTX, and images with high fidelity — no server required.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
[](https://www.npmjs.com/package/@docmentis/udoc-viewer)
|
|
6
|
+
[](./LICENSE)
|
|
7
|
+
|
|
8
|
+
**[Live Demo](https://docmentis.com/viewer/demo)** · **[Guide](https://docmentis.com/viewer/guide)** · **[Report Issue](https://github.com/docmentis/docmentis-udoc-viewer/issues)**
|
|
9
|
+
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
## Why udoc-viewer?
|
|
13
|
+
|
|
14
|
+
Most web document viewers only handle PDF, rely on server-side rendering, or require expensive commercial licenses. udoc-viewer is different:
|
|
15
|
+
|
|
16
|
+
- **Truly universal** — PDF, PowerPoint, and images in a single viewer, with more formats coming
|
|
17
|
+
- **High fidelity** — powered by a custom Rust/WebAssembly rendering engine, not PDF.js
|
|
18
|
+
- **Client-side only** — everything runs in the browser, no server round-trips
|
|
19
|
+
- **Framework agnostic** — works with React, Vue, Angular, Svelte, or plain HTML
|
|
20
|
+
- **Free for commercial use** — MIT-licensed wrapper, free WASM engine
|
|
6
21
|
|
|
7
22
|
## Supported Formats
|
|
8
23
|
|
|
@@ -10,17 +25,19 @@ Universal Document Viewer built on top of a WebAssembly engine.
|
|
|
10
25
|
|--------|------------|
|
|
11
26
|
| PDF | .pdf |
|
|
12
27
|
| PPTX | .pptx |
|
|
13
|
-
| Images | .jpg, .jpeg, .
|
|
28
|
+
| Images | .png, .jpg, .jpeg, .gif, .webp, .bmp, .tif, .tiff, .ico, .tga, .ppm, .pgm, .pbm, .hdr, .exr, .qoi |
|
|
14
29
|
|
|
15
|
-
##
|
|
30
|
+
## Quick Start
|
|
31
|
+
|
|
32
|
+
### Install
|
|
16
33
|
|
|
17
34
|
```bash
|
|
18
35
|
npm install @docmentis/udoc-viewer
|
|
19
36
|
```
|
|
20
37
|
|
|
21
|
-
|
|
38
|
+
### Basic Usage
|
|
22
39
|
|
|
23
|
-
```
|
|
40
|
+
```js
|
|
24
41
|
import { UDocClient } from '@docmentis/udoc-viewer';
|
|
25
42
|
|
|
26
43
|
// Create a client (loads the WASM engine)
|
|
@@ -39,7 +56,62 @@ viewer.destroy();
|
|
|
39
56
|
client.destroy();
|
|
40
57
|
```
|
|
41
58
|
|
|
42
|
-
|
|
59
|
+
### HTML
|
|
60
|
+
|
|
61
|
+
```html
|
|
62
|
+
<div id="viewer" style="width: 100%; height: 600px;"></div>
|
|
63
|
+
|
|
64
|
+
<script type="module">
|
|
65
|
+
import { UDocClient } from '@docmentis/udoc-viewer';
|
|
66
|
+
|
|
67
|
+
const client = await UDocClient.create();
|
|
68
|
+
const viewer = await client.createViewer({ container: '#viewer' });
|
|
69
|
+
await viewer.load('/path/to/document.pdf');
|
|
70
|
+
</script>
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
### React
|
|
74
|
+
|
|
75
|
+
```jsx
|
|
76
|
+
import { useEffect, useRef } from 'react';
|
|
77
|
+
import { UDocClient } from '@docmentis/udoc-viewer';
|
|
78
|
+
|
|
79
|
+
function DocumentViewer({ src }) {
|
|
80
|
+
const containerRef = useRef(null);
|
|
81
|
+
|
|
82
|
+
useEffect(() => {
|
|
83
|
+
let client, viewer;
|
|
84
|
+
|
|
85
|
+
(async () => {
|
|
86
|
+
client = await UDocClient.create();
|
|
87
|
+
viewer = await client.createViewer({
|
|
88
|
+
container: containerRef.current,
|
|
89
|
+
});
|
|
90
|
+
await viewer.load(src);
|
|
91
|
+
})();
|
|
92
|
+
|
|
93
|
+
return () => {
|
|
94
|
+
viewer?.destroy();
|
|
95
|
+
client?.destroy();
|
|
96
|
+
};
|
|
97
|
+
}, [src]);
|
|
98
|
+
|
|
99
|
+
return <div ref={containerRef} style={{ width: '100%', height: '600px' }} />;
|
|
100
|
+
}
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
## Features
|
|
104
|
+
|
|
105
|
+
- 📄 **Multi-format rendering** — PDF, PPTX, and images in one unified viewer
|
|
106
|
+
- 🎯 **High-fidelity output** — custom Rust rendering engine compiled to WebAssembly
|
|
107
|
+
- 🔍 **Zoom & navigation** — toolbar with zoom controls, page thumbnails, and keyboard navigation
|
|
108
|
+
- 📱 **Responsive** — works on desktop and mobile browsers
|
|
109
|
+
- 🌊 **Streaming** — pages render progressively as the document loads
|
|
110
|
+
- 🔒 **Private** — documents never leave the browser; no server upload required
|
|
111
|
+
|
|
112
|
+
## API Reference
|
|
113
|
+
|
|
114
|
+
### Loading Documents
|
|
43
115
|
|
|
44
116
|
The viewer accepts multiple document sources:
|
|
45
117
|
|
|
@@ -57,7 +129,7 @@ await viewer.load(new Uint8Array(buffer));
|
|
|
57
129
|
viewer.close();
|
|
58
130
|
```
|
|
59
131
|
|
|
60
|
-
|
|
132
|
+
### Password-Protected Documents
|
|
61
133
|
|
|
62
134
|
When a password-protected document is loaded in UI mode, the viewer automatically prompts the user to enter the password. For headless mode, you can handle it programmatically:
|
|
63
135
|
|
|
@@ -72,7 +144,7 @@ if (await viewer.needsPassword()) {
|
|
|
72
144
|
}
|
|
73
145
|
```
|
|
74
146
|
|
|
75
|
-
|
|
147
|
+
### Client Options
|
|
76
148
|
|
|
77
149
|
```typescript
|
|
78
150
|
const client = await UDocClient.create({
|
|
@@ -82,7 +154,7 @@ const client = await UDocClient.create({
|
|
|
82
154
|
});
|
|
83
155
|
```
|
|
84
156
|
|
|
85
|
-
|
|
157
|
+
### Viewer Options
|
|
86
158
|
|
|
87
159
|
```typescript
|
|
88
160
|
const viewer = await client.createViewer({
|
|
@@ -129,7 +201,7 @@ const viewer = await client.createViewer({
|
|
|
129
201
|
});
|
|
130
202
|
```
|
|
131
203
|
|
|
132
|
-
|
|
204
|
+
### Navigation
|
|
133
205
|
|
|
134
206
|
```typescript
|
|
135
207
|
// Get current page (1-based)
|
|
@@ -142,7 +214,7 @@ viewer.goToPage(5);
|
|
|
142
214
|
viewer.goToDestination(destination);
|
|
143
215
|
```
|
|
144
216
|
|
|
145
|
-
|
|
217
|
+
### Document Information
|
|
146
218
|
|
|
147
219
|
```typescript
|
|
148
220
|
// Check if document is loaded
|
|
@@ -166,7 +238,7 @@ if (viewer.isLoaded) {
|
|
|
166
238
|
}
|
|
167
239
|
```
|
|
168
240
|
|
|
169
|
-
|
|
241
|
+
### Headless Rendering
|
|
170
242
|
|
|
171
243
|
Render pages to images without UI:
|
|
172
244
|
|
|
@@ -195,7 +267,7 @@ const dataUrl = await viewer.renderPage(0, {
|
|
|
195
267
|
const thumb = await viewer.renderThumbnail(0, { scale: 1 });
|
|
196
268
|
```
|
|
197
269
|
|
|
198
|
-
|
|
270
|
+
### Document Export
|
|
199
271
|
|
|
200
272
|
```typescript
|
|
201
273
|
// Export document as raw bytes
|
|
@@ -205,7 +277,7 @@ const bytes = await viewer.toBytes();
|
|
|
205
277
|
await viewer.download('document.pdf');
|
|
206
278
|
```
|
|
207
279
|
|
|
208
|
-
|
|
280
|
+
### Document Composition
|
|
209
281
|
|
|
210
282
|
Compose new documents by cherry-picking and rotating pages:
|
|
211
283
|
|
|
@@ -223,7 +295,7 @@ const bytes = await newDoc.toBytes();
|
|
|
223
295
|
await newDoc.download('composed.pdf');
|
|
224
296
|
```
|
|
225
297
|
|
|
226
|
-
|
|
298
|
+
### Document Utilities
|
|
227
299
|
|
|
228
300
|
```typescript
|
|
229
301
|
// Split a document by its outline (table of contents)
|
|
@@ -247,7 +319,7 @@ const compressed = await client.compress(source);
|
|
|
247
319
|
const decompressed = await client.decompress(source);
|
|
248
320
|
```
|
|
249
321
|
|
|
250
|
-
|
|
322
|
+
### Events
|
|
251
323
|
|
|
252
324
|
```typescript
|
|
253
325
|
// Document loaded
|
|
@@ -274,6 +346,38 @@ viewer.on('error', ({ error, phase }) => {
|
|
|
274
346
|
unsubscribe();
|
|
275
347
|
```
|
|
276
348
|
|
|
349
|
+
## How It Works
|
|
350
|
+
|
|
351
|
+
udoc-viewer uses a custom document processing engine written in Rust, compiled to WebAssembly. Documents are parsed and rendered entirely in the browser with near-native performance — no PDF.js, no iframe hacks, no server-side conversion.
|
|
352
|
+
|
|
353
|
+
The JavaScript wrapper (`@docmentis/udoc-viewer`) is MIT-licensed and open source. The WASM rendering engine is free to use, including in commercial applications. See [LICENSE](./LICENSE) for details.
|
|
354
|
+
|
|
355
|
+
## Browser Support
|
|
356
|
+
|
|
357
|
+
| Browser | Supported |
|
|
358
|
+
|---------|-----------|
|
|
359
|
+
| Chrome / Edge | ✅ 80+ |
|
|
360
|
+
| Firefox | ✅ 80+ |
|
|
361
|
+
| Safari | ✅ 15+ |
|
|
362
|
+
|
|
363
|
+
Requires WebAssembly support.
|
|
364
|
+
|
|
365
|
+
## Contributing
|
|
366
|
+
|
|
367
|
+
We welcome bug reports, feature requests, and pull requests.
|
|
368
|
+
|
|
369
|
+
- **Issues**: [github.com/docmentis/docmentis-udoc-viewer/issues](https://github.com/docmentis/docmentis-udoc-viewer/issues)
|
|
370
|
+
- **Discussions**: [github.com/docmentis/docmentis-udoc-viewer/discussions](https://github.com/docmentis/docmentis-udoc-viewer/discussions)
|
|
371
|
+
|
|
277
372
|
## License
|
|
278
373
|
|
|
279
|
-
MIT
|
|
374
|
+
The JavaScript/TypeScript source code is licensed under the [MIT License](../../LICENSE).
|
|
375
|
+
|
|
376
|
+
The WebAssembly binary (`src/wasm/udoc_bg.wasm`) is distributed under the [docMentis WASM Runtime License](src/wasm/LICENSE) -- free to use with the docMentis Viewer in commercial and non-commercial applications.
|
|
377
|
+
|
|
378
|
+
## Links
|
|
379
|
+
|
|
380
|
+
- 🌐 [docmentis.com](https://docmentis.com)
|
|
381
|
+
- 📦 [npm package](https://www.npmjs.com/package/@docmentis/udoc-viewer)
|
|
382
|
+
- 📂 [GitHub](https://github.com/docmentis/docmentis-udoc-viewer)
|
|
383
|
+
- 💬 [Report an issue](https://github.com/docmentis/docmentis-udoc-viewer/issues)
|
package/dist/package.json
CHANGED
|
@@ -1,14 +1,30 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@docmentis/udoc-viewer",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"license": "MIT",
|
|
6
|
-
"description": "
|
|
6
|
+
"description": "Free, open-source, universal document viewer for the web. Render PDF, PPTX, and images with high fidelity — no server required.",
|
|
7
|
+
"homepage": "https://docmentis.com/viewer/guide",
|
|
8
|
+
"repository": {
|
|
9
|
+
"type": "git",
|
|
10
|
+
"url": "https://github.com/docmentis/docmentis-udoc-viewer.git",
|
|
11
|
+
"directory": "packages/udoc-viewer"
|
|
12
|
+
},
|
|
13
|
+
"bugs": {
|
|
14
|
+
"url": "https://github.com/docmentis/docmentis-udoc-viewer/issues"
|
|
15
|
+
},
|
|
7
16
|
"keywords": [
|
|
8
17
|
"pdf",
|
|
18
|
+
"pptx",
|
|
19
|
+
"powerpoint",
|
|
9
20
|
"viewer",
|
|
10
21
|
"document",
|
|
11
|
-
"
|
|
22
|
+
"document-viewer",
|
|
23
|
+
"pdf-viewer",
|
|
24
|
+
"wasm",
|
|
25
|
+
"webassembly",
|
|
26
|
+
"image-viewer",
|
|
27
|
+
"client-side"
|
|
12
28
|
],
|
|
13
29
|
"main": "dist/src/index.js",
|
|
14
30
|
"types": "dist/src/index.d.ts",
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
docMentis WASM Runtime License
|
|
2
|
+
|
|
3
|
+
Version 1.0
|
|
4
|
+
|
|
5
|
+
Copyright (c) 2026 docMentis
|
|
6
|
+
All rights reserved.
|
|
7
|
+
|
|
8
|
+
1. Definitions
|
|
9
|
+
|
|
10
|
+
"Software" means the docMentis WebAssembly ("WASM") runtime and all
|
|
11
|
+
associated binary artifacts distributed by docMentis.
|
|
12
|
+
|
|
13
|
+
"Viewer" means the open-source JavaScript/TypeScript viewer published by
|
|
14
|
+
docMentis that loads and interacts with the Software.
|
|
15
|
+
|
|
16
|
+
"You" means the individual or legal entity using the Software.
|
|
17
|
+
|
|
18
|
+
"Derivative Work" means any modification, adaptation, or work based on
|
|
19
|
+
the Software.
|
|
20
|
+
|
|
21
|
+
2. License Grant
|
|
22
|
+
|
|
23
|
+
Subject to the terms of this License, docMentis grants You a non-exclusive,
|
|
24
|
+
worldwide, royalty-free license to:
|
|
25
|
+
|
|
26
|
+
(a) Use the Software solely in conjunction with the docMentis Viewer;
|
|
27
|
+
(b) Redistribute the unmodified Software as bundled with the Viewer;
|
|
28
|
+
(c) Use the Software in commercial or non-commercial applications.
|
|
29
|
+
|
|
30
|
+
This License does not grant You any rights to the Software's source code.
|
|
31
|
+
|
|
32
|
+
3. Restrictions
|
|
33
|
+
|
|
34
|
+
You may not, directly or indirectly:
|
|
35
|
+
|
|
36
|
+
(a) Reverse engineer, decompile, disassemble, or otherwise attempt to
|
|
37
|
+
derive the source code of the Software;
|
|
38
|
+
(b) Modify, patch, translate, or create Derivative Works of the Software;
|
|
39
|
+
(c) Use the Software independently of the docMentis Viewer;
|
|
40
|
+
(d) Sell, sublicense, rent, lease, or otherwise commercially distribute
|
|
41
|
+
the Software on a standalone basis;
|
|
42
|
+
(e) Use the Software to build or operate a competing document viewer,
|
|
43
|
+
document processing library, or document SaaS platform;
|
|
44
|
+
(f) Remove or obscure any copyright, license, or attribution notices.
|
|
45
|
+
|
|
46
|
+
4. SaaS and Hosting Limitation
|
|
47
|
+
|
|
48
|
+
You may use the Software in a hosted or SaaS environment only as part of an
|
|
49
|
+
application that embeds the docMentis Viewer for end-user document viewing.
|
|
50
|
+
|
|
51
|
+
Using the Software as part of a document processing service, API product, or
|
|
52
|
+
competing hosted offering requires a separate commercial license from
|
|
53
|
+
docMentis.
|
|
54
|
+
|
|
55
|
+
5. Ownership
|
|
56
|
+
|
|
57
|
+
The Software is licensed, not sold.
|
|
58
|
+
|
|
59
|
+
docMentis retains all right, title, and interest in and to the Software,
|
|
60
|
+
including all intellectual property rights therein.
|
|
61
|
+
|
|
62
|
+
No rights are granted except as expressly stated in this License.
|
|
63
|
+
|
|
64
|
+
6. Attribution
|
|
65
|
+
|
|
66
|
+
When redistributing the Software with the Viewer, You must retain all
|
|
67
|
+
copyright and license notices included by docMentis.
|
|
68
|
+
|
|
69
|
+
7. Termination
|
|
70
|
+
|
|
71
|
+
This License is effective until terminated.
|
|
72
|
+
|
|
73
|
+
docMentis may terminate this License immediately if You violate any of its
|
|
74
|
+
terms. Upon termination, You must cease all use and redistribution of the
|
|
75
|
+
Software.
|
|
76
|
+
|
|
77
|
+
8. Disclaimer of Warranty
|
|
78
|
+
|
|
79
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
80
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, FITNESS
|
|
81
|
+
FOR A PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
|
|
82
|
+
|
|
83
|
+
9. Limitation of Liability
|
|
84
|
+
|
|
85
|
+
IN NO EVENT SHALL DOCMENTIS BE LIABLE FOR ANY CLAIM, DAMAGES, OR OTHER
|
|
86
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT, OR OTHERWISE, ARISING
|
|
87
|
+
FROM, OUT OF, OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
|
88
|
+
DEALINGS IN THE SOFTWARE.
|
|
89
|
+
|
|
90
|
+
10. Future Licensing
|
|
91
|
+
|
|
92
|
+
docMentis may offer alternative licensing terms, including commercial
|
|
93
|
+
licenses, enterprise agreements, or source-available options, in the future.
|
|
94
|
+
|
|
95
|
+
11. Governing Law
|
|
96
|
+
|
|
97
|
+
This License shall be governed by and construed in accordance with the laws
|
|
98
|
+
of the State of California, USA, without regard to its conflict of law
|
|
99
|
+
principles.
|
|
100
|
+
|
|
101
|
+
12. Contact
|
|
102
|
+
|
|
103
|
+
For licensing questions or commercial agreements:
|
|
104
|
+
Email: licensing@docmentis.com
|
|
Binary file
|
package/package.json
CHANGED
|
@@ -1,14 +1,30 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@docmentis/udoc-viewer",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"license": "MIT",
|
|
6
|
-
"description": "
|
|
6
|
+
"description": "Free, open-source, universal document viewer for the web. Render PDF, PPTX, and images with high fidelity — no server required.",
|
|
7
|
+
"homepage": "https://docmentis.com/viewer/guide",
|
|
8
|
+
"repository": {
|
|
9
|
+
"type": "git",
|
|
10
|
+
"url": "https://github.com/docmentis/docmentis-udoc-viewer.git",
|
|
11
|
+
"directory": "packages/udoc-viewer"
|
|
12
|
+
},
|
|
13
|
+
"bugs": {
|
|
14
|
+
"url": "https://github.com/docmentis/docmentis-udoc-viewer/issues"
|
|
15
|
+
},
|
|
7
16
|
"keywords": [
|
|
8
17
|
"pdf",
|
|
18
|
+
"pptx",
|
|
19
|
+
"powerpoint",
|
|
9
20
|
"viewer",
|
|
10
21
|
"document",
|
|
11
|
-
"
|
|
22
|
+
"document-viewer",
|
|
23
|
+
"pdf-viewer",
|
|
24
|
+
"wasm",
|
|
25
|
+
"webassembly",
|
|
26
|
+
"image-viewer",
|
|
27
|
+
"client-side"
|
|
12
28
|
],
|
|
13
29
|
"main": "dist/src/index.js",
|
|
14
30
|
"types": "dist/src/index.d.ts",
|