@shznet/pdf-sign-control 0.2.1 → 0.2.3
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 +76 -6
- package/dist/index.js +432 -305
- package/dist/lib/PdfSignControl.d.ts +7 -0
- package/dist/lib/PdfSignControl.d.ts.map +1 -1
- package/dist/lib/engine/PdfViewer.d.ts +12 -0
- package/dist/lib/engine/PdfViewer.d.ts.map +1 -1
- package/dist/lib/types.d.ts +7 -0
- package/dist/lib/types.d.ts.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -42,21 +42,91 @@ pdfControl.on('fields:change', (fields) => {
|
|
|
42
42
|
|
|
43
43
|
## API
|
|
44
44
|
|
|
45
|
-
###
|
|
45
|
+
### Document Loading
|
|
46
|
+
|
|
47
|
+
#### `load(source: string | Uint8Array | ArrayBuffer): Promise<void>`
|
|
46
48
|
Loads and renders the PDF from the given URL or buffer.
|
|
47
49
|
|
|
48
|
-
###
|
|
49
|
-
Adds a new signature field to the document.
|
|
50
|
+
### View Mode
|
|
50
51
|
|
|
51
|
-
|
|
52
|
+
#### `setViewMode(mode: 'single' | 'scroll'): Promise<void>`
|
|
52
53
|
Switches between single page view and continuous scroll view.
|
|
53
54
|
|
|
54
|
-
|
|
55
|
+
#### `getViewMode(): ViewMode`
|
|
56
|
+
Returns the current view mode.
|
|
57
|
+
|
|
58
|
+
### Page Navigation
|
|
59
|
+
|
|
60
|
+
#### `goToPage(page: number): void`
|
|
61
|
+
Navigate to a specific page (1-based index).
|
|
62
|
+
|
|
63
|
+
#### `getCurrentPage(): number`
|
|
64
|
+
Get the current page number (1-based).
|
|
65
|
+
|
|
66
|
+
#### `getTotalPages(): number`
|
|
67
|
+
Get total number of pages in the document.
|
|
68
|
+
|
|
69
|
+
#### `nextPage(): void`
|
|
70
|
+
Navigate to the next page.
|
|
71
|
+
|
|
72
|
+
#### `previousPage(): void`
|
|
73
|
+
Navigate to the previous page.
|
|
74
|
+
|
|
75
|
+
#### `getPageDimensions(pageIndex: number): Promise<{ width: number; height: number } | null>`
|
|
76
|
+
Get dimensions of a specific page in PDF points (unscaled).
|
|
77
|
+
|
|
78
|
+
**Parameters:**
|
|
79
|
+
- `pageIndex`: Zero-based page index
|
|
80
|
+
|
|
81
|
+
**Returns:** Page dimensions `{ width, height }` in PDF points, or `null` if the page doesn't exist.
|
|
82
|
+
|
|
83
|
+
**Example:**
|
|
84
|
+
```typescript
|
|
85
|
+
const dims = await pdfControl.getPageDimensions(0); // First page
|
|
86
|
+
console.log(`Page dimensions: ${dims.width} x ${dims.height} points`);
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
### Zoom
|
|
90
|
+
|
|
91
|
+
#### `setScale(scale: number): void`
|
|
55
92
|
Controls the zoom level of the document.
|
|
56
93
|
|
|
57
|
-
|
|
94
|
+
#### `getScale(): number`
|
|
95
|
+
Get the current zoom scale.
|
|
96
|
+
|
|
97
|
+
### Field Management
|
|
98
|
+
|
|
99
|
+
#### `addField(field: SignatureField): Promise<void>`
|
|
100
|
+
Adds a new signature field to the document.
|
|
101
|
+
|
|
102
|
+
#### `removeField(fieldId: string): void`
|
|
103
|
+
Removes a field by its ID.
|
|
104
|
+
|
|
105
|
+
#### `updateField(fieldId: string, updates: Partial<SignatureField>): void`
|
|
106
|
+
Updates a field's properties.
|
|
107
|
+
|
|
108
|
+
#### `getFields(): SignatureField[]`
|
|
58
109
|
Returns the current list of fields.
|
|
59
110
|
|
|
111
|
+
#### `setFields(fields: SignatureField[]): void`
|
|
112
|
+
Replace all fields with a new set.
|
|
113
|
+
|
|
114
|
+
### Events
|
|
115
|
+
|
|
116
|
+
#### `on(event: string, handler: Function): void`
|
|
117
|
+
Subscribe to events:
|
|
118
|
+
- `page:change`: Fired when page changes - `(data: { page: number, total: number }) => void`
|
|
119
|
+
- `scale:change`: Fired when zoom changes - `(data: { scale: number }) => void`
|
|
120
|
+
- `field:add`: Fired when a field is added - `(field: SignatureField) => void`
|
|
121
|
+
- `field:remove`: Fired when a field is removed - `(data: { fieldId: string }) => void`
|
|
122
|
+
- `field:update`: Fired when a field is updated - `(data: { fieldId: string, updates: Partial<SignatureField> }) => void`
|
|
123
|
+
- `fields:change`: Fired when any field changes - `(fields: SignatureField[]) => void`
|
|
124
|
+
|
|
125
|
+
### Printing
|
|
126
|
+
|
|
127
|
+
#### `print(options?: { withSignatures?: boolean }): Promise<void>`
|
|
128
|
+
Prints the current document. Default is printing without signatures.
|
|
129
|
+
|
|
60
130
|
## License
|
|
61
131
|
|
|
62
132
|
MIT
|