jit-pdf 0.1.0 → 0.1.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 +319 -19
- package/README.zh-CN.md +46 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,30 +1,163 @@
|
|
|
1
1
|
# jit-pdf
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Enterprise-ready PDF viewing and editing SDK for business systems.
|
|
4
4
|
|
|
5
|
-
-
|
|
6
|
-
- 浏览器挂载式接入
|
|
7
|
-
- UMD `<script>` 直引
|
|
8
|
-
- 本地 `IndexedDB` 模式
|
|
9
|
-
- 服务端文件流模式
|
|
5
|
+
`jit-pdf` provides a polished Chinese UI, annotation tools, redaction workflow, local IndexedDB storage, HTTP file-service integration, and multiple integration styles for modern apps and plain HTML pages.
|
|
10
6
|
|
|
11
|
-
|
|
7
|
+
[中文文档 / Chinese Documentation](https://github.com/jitOffice/jit-pdf-sdk/blob/main/packages/pdf-sdk/README.zh-CN.md)
|
|
8
|
+
|
|
9
|
+
## Why jit-pdf
|
|
10
|
+
|
|
11
|
+
- Ready-to-use PDF workspace with toolbar, thumbnails, floating inspector, and annotation drawer
|
|
12
|
+
- Built-in annotation tools: highlight, note, free text, ink, delete, batch management
|
|
13
|
+
- Redaction workflow with save-as-copy support
|
|
14
|
+
- Full-text search, page navigation, zoom, and multi-page reading
|
|
15
|
+
- Two storage modes:
|
|
16
|
+
- pure local mode with IndexedDB
|
|
17
|
+
- remote file mode with HTTP / Range streaming
|
|
18
|
+
- Multiple integration styles:
|
|
19
|
+
- Vue component
|
|
20
|
+
- browser mount API
|
|
21
|
+
- UMD script tag
|
|
22
|
+
|
|
23
|
+
## Installation
|
|
24
|
+
|
|
25
|
+
For Vue projects:
|
|
12
26
|
|
|
13
27
|
```bash
|
|
14
|
-
|
|
28
|
+
npm install jit-pdf vue
|
|
15
29
|
```
|
|
16
30
|
|
|
17
|
-
|
|
31
|
+
Or:
|
|
18
32
|
|
|
19
|
-
```
|
|
33
|
+
```bash
|
|
34
|
+
pnpm add jit-pdf vue
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
## Package Outputs
|
|
38
|
+
|
|
39
|
+
This package ships with:
|
|
40
|
+
|
|
41
|
+
- `jit-pdf`
|
|
42
|
+
ESM / CJS entry for component usage
|
|
43
|
+
- `jit-pdf/browser`
|
|
44
|
+
mount-based browser entry for React, Angular, and other frameworks
|
|
45
|
+
- `jit-pdf/styles.css`
|
|
46
|
+
shared styles
|
|
47
|
+
- `dist/jit-pdf.umd.js`
|
|
48
|
+
UMD bundle for direct browser usage
|
|
49
|
+
|
|
50
|
+
## CDN Usage
|
|
51
|
+
|
|
52
|
+
### jsDelivr
|
|
53
|
+
|
|
54
|
+
Latest:
|
|
55
|
+
|
|
56
|
+
```html
|
|
57
|
+
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/jit-pdf/dist/style.css" />
|
|
58
|
+
<script src="https://cdn.jsdelivr.net/npm/jit-pdf/dist/jit-pdf.umd.js"></script>
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
Pinned version:
|
|
62
|
+
|
|
63
|
+
```html
|
|
64
|
+
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/jit-pdf@0.1.1/dist/style.css" />
|
|
65
|
+
<script src="https://cdn.jsdelivr.net/npm/jit-pdf@0.1.1/dist/jit-pdf.umd.js"></script>
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
### UNPKG
|
|
69
|
+
|
|
70
|
+
Latest:
|
|
71
|
+
|
|
72
|
+
```html
|
|
73
|
+
<link rel="stylesheet" href="https://unpkg.com/jit-pdf/dist/style.css" />
|
|
74
|
+
<script src="https://unpkg.com/jit-pdf/dist/jit-pdf.umd.js"></script>
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
Pinned version:
|
|
78
|
+
|
|
79
|
+
```html
|
|
80
|
+
<link rel="stylesheet" href="https://unpkg.com/jit-pdf@0.1.1/dist/style.css" />
|
|
81
|
+
<script src="https://unpkg.com/jit-pdf@0.1.1/dist/jit-pdf.umd.js"></script>
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
Global browser variable:
|
|
85
|
+
|
|
86
|
+
```js
|
|
87
|
+
window.JitPdfSdk
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
## Quick Start
|
|
91
|
+
|
|
92
|
+
### Vue 3 Component Usage
|
|
93
|
+
|
|
94
|
+
```vue
|
|
95
|
+
<script setup lang="ts">
|
|
96
|
+
import { ref } from "vue";
|
|
20
97
|
import "jit-pdf/styles.css";
|
|
21
98
|
import {
|
|
22
99
|
JitPdfEditor,
|
|
23
|
-
createIndexedDbPdfEditorService
|
|
100
|
+
createIndexedDbPdfEditorService,
|
|
101
|
+
type PdfSource
|
|
24
102
|
} from "jit-pdf";
|
|
103
|
+
|
|
104
|
+
const service = createIndexedDbPdfEditorService({
|
|
105
|
+
databaseName: "jit-pdf-demo"
|
|
106
|
+
});
|
|
107
|
+
|
|
108
|
+
const source = ref<PdfSource | null>(null);
|
|
109
|
+
|
|
110
|
+
async function onSelectFile(event: Event) {
|
|
111
|
+
const input = event.target as HTMLInputElement;
|
|
112
|
+
const file = input.files?.[0];
|
|
113
|
+
if (!file) return;
|
|
114
|
+
|
|
115
|
+
const uploaded = await service.uploadFile(file);
|
|
116
|
+
source.value = {
|
|
117
|
+
type: "local",
|
|
118
|
+
fileId: uploaded.id,
|
|
119
|
+
name: uploaded.name
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
</script>
|
|
123
|
+
|
|
124
|
+
<template>
|
|
125
|
+
<div style="height: 100vh">
|
|
126
|
+
<input type="file" accept=".pdf,application/pdf" @change="onSelectFile" />
|
|
127
|
+
<JitPdfEditor
|
|
128
|
+
v-if="source"
|
|
129
|
+
:source="source"
|
|
130
|
+
:service="service"
|
|
131
|
+
locale="zh-CN"
|
|
132
|
+
theme="blue-enterprise"
|
|
133
|
+
/>
|
|
134
|
+
</div>
|
|
135
|
+
</template>
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
### Remote File Service Mode
|
|
139
|
+
|
|
140
|
+
```ts
|
|
141
|
+
import { createHttpPdfEditorService } from "jit-pdf";
|
|
142
|
+
|
|
143
|
+
const service = createHttpPdfEditorService({
|
|
144
|
+
baseUrl: "http://localhost:4000",
|
|
145
|
+
annotationDatabaseName: "jit-pdf-annotations"
|
|
146
|
+
});
|
|
25
147
|
```
|
|
26
148
|
|
|
27
|
-
|
|
149
|
+
```vue
|
|
150
|
+
<JitPdfEditor
|
|
151
|
+
:source="{ type: 'remote', fileId: 'your-file-id' }"
|
|
152
|
+
:service="service"
|
|
153
|
+
locale="zh-CN"
|
|
154
|
+
theme="blue-enterprise"
|
|
155
|
+
/>
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
### Browser Mount API
|
|
159
|
+
|
|
160
|
+
Use this when your host app is not written in Vue, or when you want an embeddable container-based integration.
|
|
28
161
|
|
|
29
162
|
```ts
|
|
30
163
|
import "jit-pdf/styles.css";
|
|
@@ -32,19 +165,186 @@ import {
|
|
|
32
165
|
createIndexedDbPdfEditorService,
|
|
33
166
|
mountJitPdfEditor
|
|
34
167
|
} from "jit-pdf/browser";
|
|
168
|
+
|
|
169
|
+
const service = createIndexedDbPdfEditorService({
|
|
170
|
+
databaseName: "jit-pdf-browser-demo"
|
|
171
|
+
});
|
|
172
|
+
|
|
173
|
+
const mounted = mountJitPdfEditor({
|
|
174
|
+
target: "#app",
|
|
175
|
+
source: {
|
|
176
|
+
type: "local",
|
|
177
|
+
fileId: "your-file-id",
|
|
178
|
+
name: "sample.pdf"
|
|
179
|
+
},
|
|
180
|
+
service,
|
|
181
|
+
locale: "zh-CN",
|
|
182
|
+
theme: "blue-enterprise"
|
|
183
|
+
});
|
|
184
|
+
|
|
185
|
+
// later
|
|
186
|
+
mounted.unmount();
|
|
35
187
|
```
|
|
36
188
|
|
|
37
|
-
|
|
189
|
+
### Plain HTML / UMD
|
|
38
190
|
|
|
39
191
|
```html
|
|
40
|
-
|
|
41
|
-
<
|
|
192
|
+
<!doctype html>
|
|
193
|
+
<html lang="en">
|
|
194
|
+
<head>
|
|
195
|
+
<meta charset="UTF-8" />
|
|
196
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
197
|
+
<title>jit-pdf UMD Demo</title>
|
|
198
|
+
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/jit-pdf/dist/style.css" />
|
|
199
|
+
<style>
|
|
200
|
+
html, body, #app {
|
|
201
|
+
height: 100%;
|
|
202
|
+
margin: 0;
|
|
203
|
+
}
|
|
204
|
+
</style>
|
|
205
|
+
</head>
|
|
206
|
+
<body>
|
|
207
|
+
<input id="fileInput" type="file" accept=".pdf,application/pdf" />
|
|
208
|
+
<div id="app" style="height: calc(100% - 40px)"></div>
|
|
209
|
+
|
|
210
|
+
<script src="https://cdn.jsdelivr.net/npm/jit-pdf/dist/jit-pdf.umd.js"></script>
|
|
211
|
+
<script>
|
|
212
|
+
const { createIndexedDbPdfEditorService, mountJitPdfEditor } = window.JitPdfSdk;
|
|
213
|
+
const service = createIndexedDbPdfEditorService({
|
|
214
|
+
databaseName: "jit-pdf-html-demo"
|
|
215
|
+
});
|
|
216
|
+
|
|
217
|
+
let mounted = null;
|
|
218
|
+
|
|
219
|
+
document.getElementById("fileInput").addEventListener("change", async (event) => {
|
|
220
|
+
const file = event.target.files && event.target.files[0];
|
|
221
|
+
if (!file) return;
|
|
222
|
+
|
|
223
|
+
const uploaded = await service.uploadFile(file);
|
|
224
|
+
|
|
225
|
+
if (mounted) {
|
|
226
|
+
mounted.unmount();
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
mounted = mountJitPdfEditor({
|
|
230
|
+
target: "#app",
|
|
231
|
+
source: {
|
|
232
|
+
type: "local",
|
|
233
|
+
fileId: uploaded.id,
|
|
234
|
+
name: uploaded.name
|
|
235
|
+
},
|
|
236
|
+
service,
|
|
237
|
+
locale: "zh-CN",
|
|
238
|
+
theme: "blue-enterprise"
|
|
239
|
+
});
|
|
240
|
+
});
|
|
241
|
+
</script>
|
|
242
|
+
</body>
|
|
243
|
+
</html>
|
|
42
244
|
```
|
|
43
245
|
|
|
44
|
-
|
|
45
|
-
|
|
246
|
+
## Storage Modes
|
|
247
|
+
|
|
248
|
+
### Local IndexedDB Mode
|
|
249
|
+
|
|
250
|
+
Recommended for:
|
|
251
|
+
|
|
252
|
+
- demos
|
|
253
|
+
- PoCs
|
|
254
|
+
- local-only document workflows
|
|
255
|
+
- environments without backend integration
|
|
256
|
+
|
|
257
|
+
Use:
|
|
258
|
+
|
|
259
|
+
```ts
|
|
260
|
+
createIndexedDbPdfEditorService({
|
|
261
|
+
databaseName: "jit-pdf-demo"
|
|
262
|
+
});
|
|
263
|
+
```
|
|
264
|
+
|
|
265
|
+
### HTTP File Service Mode
|
|
266
|
+
|
|
267
|
+
Recommended for:
|
|
268
|
+
|
|
269
|
+
- large PDF streaming
|
|
270
|
+
- local directory browsing
|
|
271
|
+
- upload / delete / save-copy workflows
|
|
272
|
+
- backend-controlled document access
|
|
273
|
+
|
|
274
|
+
Use:
|
|
275
|
+
|
|
276
|
+
```ts
|
|
277
|
+
createHttpPdfEditorService({
|
|
278
|
+
baseUrl: "http://localhost:4000"
|
|
279
|
+
});
|
|
280
|
+
```
|
|
281
|
+
|
|
282
|
+
## Main APIs
|
|
283
|
+
|
|
284
|
+
### Component Entry
|
|
285
|
+
|
|
286
|
+
```ts
|
|
287
|
+
import { JitPdfEditor } from "jit-pdf";
|
|
288
|
+
```
|
|
289
|
+
|
|
290
|
+
### Service Factories
|
|
291
|
+
|
|
292
|
+
```ts
|
|
293
|
+
import {
|
|
294
|
+
createHttpPdfEditorService,
|
|
295
|
+
createIndexedDbPdfEditorService
|
|
296
|
+
} from "jit-pdf";
|
|
297
|
+
```
|
|
298
|
+
|
|
299
|
+
### Browser Mount Entry
|
|
300
|
+
|
|
301
|
+
```ts
|
|
302
|
+
import { mountJitPdfEditor } from "jit-pdf/browser";
|
|
303
|
+
```
|
|
304
|
+
|
|
305
|
+
### Types
|
|
306
|
+
|
|
307
|
+
```ts
|
|
308
|
+
import type {
|
|
309
|
+
PdfSource,
|
|
310
|
+
PdfEditorService,
|
|
311
|
+
JitPdfEditorProps
|
|
312
|
+
} from "jit-pdf";
|
|
313
|
+
```
|
|
314
|
+
|
|
315
|
+
## Supported Events
|
|
316
|
+
|
|
317
|
+
Both `JitPdfEditor` and `mountJitPdfEditor()` support:
|
|
318
|
+
|
|
319
|
+
- `ready`
|
|
320
|
+
- `dirty-change`
|
|
321
|
+
- `save-start`
|
|
322
|
+
- `save-success`
|
|
323
|
+
- `save-error`
|
|
324
|
+
- `load-error`
|
|
325
|
+
|
|
326
|
+
Example:
|
|
327
|
+
|
|
328
|
+
```ts
|
|
329
|
+
mountJitPdfEditor({
|
|
330
|
+
target: "#app",
|
|
331
|
+
source,
|
|
332
|
+
service,
|
|
333
|
+
onReady(event) {
|
|
334
|
+
console.log("Ready:", event.documentId);
|
|
335
|
+
},
|
|
336
|
+
onSaveSuccess(result) {
|
|
337
|
+
console.log("Saved:", result.relativePath);
|
|
338
|
+
},
|
|
339
|
+
onLoadError(error) {
|
|
340
|
+
console.error("Load failed:", error.message);
|
|
341
|
+
}
|
|
342
|
+
});
|
|
46
343
|
```
|
|
47
344
|
|
|
48
|
-
##
|
|
345
|
+
## GitHub and Examples
|
|
49
346
|
|
|
50
|
-
-
|
|
347
|
+
- Repository: https://github.com/jitOffice/jit-pdf-sdk
|
|
348
|
+
- Vue example: `packages/pdf-sdk/examples/vue-demo`
|
|
349
|
+
- HTML example: `packages/pdf-sdk/examples/html-demo`
|
|
350
|
+
- Chinese docs: https://github.com/jitOffice/jit-pdf-sdk/blob/main/packages/pdf-sdk/README.zh-CN.md
|
package/README.zh-CN.md
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
# jit-pdf 中文文档
|
|
2
|
+
|
|
3
|
+
英文版 npm 文档请查看:
|
|
4
|
+
|
|
5
|
+
- https://github.com/jitOffice/jit-pdf-sdk/blob/main/packages/pdf-sdk/README.md
|
|
6
|
+
|
|
7
|
+
仓库主文档请查看:
|
|
8
|
+
|
|
9
|
+
- https://github.com/jitOffice/jit-pdf-sdk/blob/main/README.md
|
|
10
|
+
|
|
11
|
+
## 简介
|
|
12
|
+
|
|
13
|
+
`jit-pdf` 是一套面向业务系统的 PDF 预览与编辑 SDK,支持:
|
|
14
|
+
|
|
15
|
+
- Vue 组件接入
|
|
16
|
+
- 浏览器挂载式接入
|
|
17
|
+
- UMD `<script>` 直引
|
|
18
|
+
- 本地 `IndexedDB` 模式
|
|
19
|
+
- HTTP 文件服务模式
|
|
20
|
+
- 中文界面、蓝色主题、批注与脱敏
|
|
21
|
+
|
|
22
|
+
## 安装
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
npm install jit-pdf vue
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
## CDN
|
|
29
|
+
|
|
30
|
+
jsDelivr:
|
|
31
|
+
|
|
32
|
+
```html
|
|
33
|
+
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/jit-pdf/dist/style.css" />
|
|
34
|
+
<script src="https://cdn.jsdelivr.net/npm/jit-pdf/dist/jit-pdf.umd.js"></script>
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
UNPKG:
|
|
38
|
+
|
|
39
|
+
```html
|
|
40
|
+
<link rel="stylesheet" href="https://unpkg.com/jit-pdf/dist/style.css" />
|
|
41
|
+
<script src="https://unpkg.com/jit-pdf/dist/jit-pdf.umd.js"></script>
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
## 仓库地址
|
|
45
|
+
|
|
46
|
+
- https://github.com/jitOffice/jit-pdf-sdk
|