@rajeev02/document 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/README.md +148 -0
- package/package.json +1 -1
package/README.md
ADDED
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
# @rajeev02/document
|
|
2
|
+
|
|
3
|
+
[](https://www.npmjs.com/package/@rajeev02/document)
|
|
4
|
+
[](https://github.com/Rajeev02/rajeev-sdk/blob/main/LICENSE)
|
|
5
|
+
|
|
6
|
+
**Document picker, PDF annotation & editor, and digital signature management** with multi-source file selection, stamps, form filling, and legally-valid signing records.
|
|
7
|
+
|
|
8
|
+
Part of [Rajeev SDK](https://github.com/Rajeev02/rajeev-sdk) — cross-platform infrastructure libraries for building apps that work everywhere.
|
|
9
|
+
|
|
10
|
+
## Why use this?
|
|
11
|
+
|
|
12
|
+
- **Document picker** — Select files from camera, gallery, file system with preset configs (KYC, invoice, medical)
|
|
13
|
+
- **PDF editor** — Navigate, zoom, highlight, underline, strikethrough, stamp, freehand draw, add text
|
|
14
|
+
- **Form filling** — Set form field values programmatically for PDF forms
|
|
15
|
+
- **Digital signatures** — Type, draw, or upload signatures. Place on any page with position/size control.
|
|
16
|
+
- **Signing records** — Generate legally-valid signing records with timestamp, IP, reason, and document hash
|
|
17
|
+
- **File utilities** — Categorize files by MIME type, format file sizes, get picker presets
|
|
18
|
+
|
|
19
|
+
## Platform Support
|
|
20
|
+
|
|
21
|
+
| Platform | Engine | Status |
|
|
22
|
+
| ---------- | ---------- | ------ |
|
|
23
|
+
| iOS 16+ | TypeScript | ✅ |
|
|
24
|
+
| Android 7+ | TypeScript | ✅ |
|
|
25
|
+
|
|
26
|
+
## Installation
|
|
27
|
+
|
|
28
|
+
```bash
|
|
29
|
+
npm install @rajeev02/document
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
### Peer Dependencies
|
|
33
|
+
|
|
34
|
+
- `react` >= 18.3.0
|
|
35
|
+
- `react-native` >= 0.84.0 _(optional)_
|
|
36
|
+
|
|
37
|
+
## Quick Start
|
|
38
|
+
|
|
39
|
+
### Document Picker
|
|
40
|
+
|
|
41
|
+
```typescript
|
|
42
|
+
import {
|
|
43
|
+
getPickerPreset,
|
|
44
|
+
categorizeFile,
|
|
45
|
+
formatFileSize,
|
|
46
|
+
} from "@rajeev02/document";
|
|
47
|
+
|
|
48
|
+
// Pre-configured picker for KYC documents
|
|
49
|
+
const kycPreset = getPickerPreset("kyc_document");
|
|
50
|
+
// → { sources: ["camera", "gallery", "files"], categories: ["image", "pdf"], maxSizeMB: 10, ... }
|
|
51
|
+
|
|
52
|
+
// File utilities
|
|
53
|
+
categorizeFile("application/pdf"); // → "pdf"
|
|
54
|
+
categorizeFile("image/jpeg"); // → "image"
|
|
55
|
+
formatFileSize(2_457_600); // → "2.3 MB"
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
### PDF Editor
|
|
59
|
+
|
|
60
|
+
```typescript
|
|
61
|
+
import { DocumentEditorController } from "@rajeev02/document";
|
|
62
|
+
|
|
63
|
+
const editor = new DocumentEditorController("file://contract.pdf", 10);
|
|
64
|
+
|
|
65
|
+
// Navigation
|
|
66
|
+
editor.goToPage(3);
|
|
67
|
+
editor.setZoom(1.5);
|
|
68
|
+
|
|
69
|
+
// Annotations
|
|
70
|
+
editor.addHighlight(0.1, 0.2, 0.5, 0.03);
|
|
71
|
+
editor.addStamp(0.7, 0.9, "approved");
|
|
72
|
+
editor.setActiveTool("freehand");
|
|
73
|
+
editor.setActiveColor("#FF0000");
|
|
74
|
+
|
|
75
|
+
// Form filling
|
|
76
|
+
editor.setFormFieldValue("name", "Rajeev Kumar Joshi");
|
|
77
|
+
editor.setFormFieldValue("date", "2026-02-08");
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
### Digital Signatures
|
|
81
|
+
|
|
82
|
+
```typescript
|
|
83
|
+
import { SignatureManager } from "@rajeev02/document";
|
|
84
|
+
|
|
85
|
+
const sigMgr = new SignatureManager();
|
|
86
|
+
|
|
87
|
+
// Create a typed signature
|
|
88
|
+
const sigId = sigMgr.saveTypedSignature("Rajeev Kumar Joshi", "Dancing Script");
|
|
89
|
+
|
|
90
|
+
// Place on document
|
|
91
|
+
sigMgr.placeSignature({
|
|
92
|
+
signatureId: sigId,
|
|
93
|
+
pageNumber: 10,
|
|
94
|
+
position: { x: 0.6, y: 0.9 },
|
|
95
|
+
size: { width: 0.25, height: 0.06 },
|
|
96
|
+
rotation: 0,
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
// Generate legally-valid signing record
|
|
100
|
+
const record = sigMgr.generateSigningRecord(
|
|
101
|
+
"Rajeev Kumar Joshi",
|
|
102
|
+
"rajeev@example.com",
|
|
103
|
+
"Contract acceptance",
|
|
104
|
+
"sha256:abc123...",
|
|
105
|
+
);
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
## Picker Presets
|
|
109
|
+
|
|
110
|
+
| Preset | Sources | Categories | Max Size |
|
|
111
|
+
| ---------------- | ---------------------- | ---------- | -------- |
|
|
112
|
+
| `kyc_document` | camera, gallery, files | image, pdf | 10 MB |
|
|
113
|
+
| `invoice` | camera, files | image, pdf | 25 MB |
|
|
114
|
+
| `medical_report` | camera, gallery, files | image, pdf | 50 MB |
|
|
115
|
+
| `profile_photo` | camera, gallery | image | 5 MB |
|
|
116
|
+
| `general` | camera, gallery, files | all | 100 MB |
|
|
117
|
+
|
|
118
|
+
## API Reference
|
|
119
|
+
|
|
120
|
+
### `DocumentEditorController`
|
|
121
|
+
|
|
122
|
+
| Method | Description |
|
|
123
|
+
| --------------------------------- | ----------------------------------- |
|
|
124
|
+
| `goToPage(page)` | Navigate to page |
|
|
125
|
+
| `setZoom(level)` | Set zoom (0.5–5.0) |
|
|
126
|
+
| `addHighlight(x, y, w, h)` | Add highlight annotation |
|
|
127
|
+
| `addStamp(x, y, type)` | Add stamp (approved/rejected/draft) |
|
|
128
|
+
| `setActiveTool(tool)` | Set annotation tool |
|
|
129
|
+
| `setFormFieldValue(field, value)` | Fill form field |
|
|
130
|
+
| `undo()` / `redo()` | Undo/redo |
|
|
131
|
+
|
|
132
|
+
### `SignatureManager`
|
|
133
|
+
|
|
134
|
+
| Method | Description |
|
|
135
|
+
| -------------------------------- | ----------------------------- |
|
|
136
|
+
| `saveTypedSignature(name, font)` | Create typed signature |
|
|
137
|
+
| `saveDrawnSignature(paths)` | Save hand-drawn signature |
|
|
138
|
+
| `placeSignature(config)` | Place signature on document |
|
|
139
|
+
| `generateSigningRecord(...)` | Generate legal signing record |
|
|
140
|
+
| `getSavedSignatures()` | List all saved signatures |
|
|
141
|
+
|
|
142
|
+
## Full Documentation
|
|
143
|
+
|
|
144
|
+
📖 [Complete API docs with all annotation types](https://github.com/Rajeev02/rajeev-sdk/blob/main/docs/usage/DOCUMENT.md)
|
|
145
|
+
|
|
146
|
+
## License
|
|
147
|
+
|
|
148
|
+
MIT © 2026 [Rajeev Kumar Joshi](https://rajeev02.github.io)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rajeev02/document",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "Document picker, PDF viewer/editor, annotation, digital signature, form filling, document scanner",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"author": "Rajeev Kumar Joshi <rajeevjoshi91@gmail.com> (https://rajeev02.github.io)",
|