pdf-signature-jtp-sdk 1.0.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/README.md ADDED
@@ -0,0 +1,182 @@
1
+ # pdf-signature-sdk
2
+
3
+ A **framework-agnostic** PDF Viewer + Signature SDK. Works with Vanilla JS, Vue 3, React, and Nuxt out of the box.
4
+
5
+ [![npm](https://img.shields.io/npm/v/pdf-signature-sdk)](https://npmjs.com/package/pdf-signature-sdk)
6
+ [![license](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE)
7
+
8
+ ---
9
+
10
+ ## Features
11
+
12
+ - 📄 **PDF.js rendering** — High-fidelity canvas rendering
13
+ - 🖊️ **Signatures** — Click-to-place, draggable signature placeholders
14
+ - 🔴 **E-Materai** — Electronic stamp placement
15
+ - 📑 **Sidebar** — Page thumbnails with click navigation
16
+ - 🧰 **Toolbar** — Upload, pagination, zoom, signature controls
17
+ - ⚙️ **UI Config** — Show/hide any UI element via config
18
+ - 🔄 **Dynamic switching** — Change document without page reload
19
+ - 🎯 **Framework-free core** — No Vue/React in the core engine
20
+
21
+ ---
22
+
23
+ ## Installation
24
+
25
+ ```bash
26
+ npm install pdf-signature-sdk
27
+ ```
28
+
29
+ ---
30
+
31
+ ## Usage
32
+
33
+ ### Vanilla JS / HTML
34
+
35
+ ```js
36
+ import { createViewer } from 'pdf-signature-sdk';
37
+
38
+ const viewer = createViewer({
39
+ container: '#app', // CSS selector or HTMLElement
40
+ file: 'path/to/doc.pdf', // URL, File, Blob, or ArrayBuffer
41
+ scale: 1.5, // zoom level
42
+ ui: {
43
+ topbar: {
44
+ upload: true,
45
+ signature: true,
46
+ eStamp: true,
47
+ pagination: true,
48
+ zoom: true,
49
+ },
50
+ sidebar: {
51
+ thumbnails: true,
52
+ },
53
+ },
54
+ });
55
+
56
+ // Listen to events
57
+ viewer.on('signaturePlaced', ({ x, y, page, id }) => {
58
+ console.log('Signature at', x, y, 'on page', page);
59
+ });
60
+
61
+ viewer.on('pageChanged', ({ page, total }) => {
62
+ console.log(`Page ${page} of ${total}`);
63
+ });
64
+
65
+ // API
66
+ viewer.loadDocument(newFile); // Switch documents
67
+ viewer.nextPage();
68
+ viewer.prevPage();
69
+ viewer.goToPage(3);
70
+ viewer.enableSignatureMode();
71
+ viewer.disableSignatureMode();
72
+ viewer.placeSignature({ x: 100, y: 200, page: 1 });
73
+ viewer.placeEStamp({ x: 300, y: 400 });
74
+ viewer.clearSignatures();
75
+ const sigs = viewer.getSignatures(); // array of all placed items
76
+ viewer.destroy();
77
+ ```
78
+
79
+ ### Vue 3 / Nuxt
80
+
81
+ ```vue
82
+ <script setup>
83
+ import { PdfViewer } from 'pdf-signature-sdk/vue';
84
+ import 'pdf-signature-sdk/style.css';
85
+
86
+ const file = ref(null);
87
+ const ui = { sidebar: { thumbnails: true }, topbar: { signature: true } };
88
+
89
+ function onSignature(sig) {
90
+ console.log('Signature placed:', sig);
91
+ }
92
+ </script>
93
+
94
+ <template>
95
+ <PdfViewer
96
+ :file="file"
97
+ :ui="ui"
98
+ style="height: 700px"
99
+ @signature-placed="onSignature"
100
+ @page-changed="({ page }) => console.log(page)"
101
+ />
102
+ </template>
103
+ ```
104
+
105
+ ### React
106
+
107
+ ```jsx
108
+ import { PdfViewer } from 'pdf-signature-sdk/react';
109
+ import 'pdf-signature-sdk/style.css';
110
+
111
+ function App() {
112
+ const [file, setFile] = useState(null);
113
+
114
+ return (
115
+ <PdfViewer
116
+ file={file}
117
+ ui={{ sidebar: { thumbnails: true } }}
118
+ style={{ width: '100%', height: '700px' }}
119
+ onSignaturePlaced={(sig) => console.log(sig)}
120
+ onPageChanged={({ page, total }) => console.log(page, total)}
121
+ />
122
+ );
123
+ }
124
+ ```
125
+
126
+ ---
127
+
128
+ ## UI Config Reference
129
+
130
+ | Key | Type | Default | Description |
131
+ |-----|------|---------|-------------|
132
+ | `ui.topbar.upload` | boolean | `true` | Upload / change document button |
133
+ | `ui.topbar.signature` | boolean | `true` | Add signature button |
134
+ | `ui.topbar.eStamp` | boolean | `true` | E-Materai stamp button |
135
+ | `ui.topbar.pagination` | boolean | `true` | Prev / Next / page indicator |
136
+ | `ui.topbar.zoom` | boolean | `true` | Zoom in / out controls |
137
+ | `ui.sidebar.thumbnails` | boolean | `true` | Page thumbnail sidebar |
138
+
139
+ ---
140
+
141
+ ## Events
142
+
143
+ | Event | Payload | Description |
144
+ |-------|---------|-------------|
145
+ | `documentLoaded` | `{ totalPages }` | New document loaded |
146
+ | `pageChanged` | `{ page, total }` | User navigated to a page |
147
+ | `signaturePlaced` | `{ id, x, y, page, type }` | Signature placed on canvas |
148
+ | `eStampPlaced` | `{ id, x, y, page, type }` | E-Materai placed |
149
+ | `signatureMoved` | `{ id, x, y, page }` | Signature dragged to new position |
150
+ | `signatureModeChanged` | `{ active }` | Signature mode toggled |
151
+ | `coordinateCapture` | `{ x, y, page, canvasWidth, canvasHeight }` | Raw click coordinate captured |
152
+
153
+ ---
154
+
155
+ ## API Reference
156
+
157
+ | Method | Description |
158
+ |--------|-------------|
159
+ | `loadDocument(source)` | Load PDF from File, Blob, URL, or ArrayBuffer |
160
+ | `nextPage()` | Go to next page |
161
+ | `prevPage()` | Go to previous page |
162
+ | `goToPage(n)` | Go to page n (1-indexed) |
163
+ | `enableSignatureMode()` | Enable click-to-place mode |
164
+ | `disableSignatureMode()` | Disable placement mode |
165
+ | `placeSignature({ x, y, page?, label? })` | Programmatic signature placement |
166
+ | `placeEStamp({ x, y, page? })` | Programmatic e-materai placement |
167
+ | `removeSignature(id)` | Remove specific item by ID |
168
+ | `clearSignatures()` | Remove all signatures/stamps |
169
+ | `getSignatures()` | Get all placed items (all pages) |
170
+ | `getSignaturesByPage(page)` | Get items for a specific page |
171
+ | `on(event, fn)` | Subscribe to an event |
172
+ | `off(event, fn)` | Unsubscribe from an event |
173
+ | `updateConfig(partialConfig)` | Update UI config dynamically |
174
+ | `getCanvas()` | Get the main PDF canvas element |
175
+ | `getOverlayCanvas()` | Get the overlay canvas element |
176
+ | `destroy()` | Destroy viewer and clean up resources |
177
+
178
+ ---
179
+
180
+ ## License
181
+
182
+ JTP © 2026