@shznet/pdf-sign-control 0.2.0 → 0.2.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.
Files changed (2) hide show
  1. package/README.md +22 -18
  2. package/package.json +12 -1
package/README.md CHANGED
@@ -15,44 +15,48 @@ import { PdfSignControl } from '@shznet/pdf-sign-control';
15
15
 
16
16
  // 1. Initialize the control
17
17
  const container = document.getElementById('pdf-wrapper');
18
- const pdfControl = new PdfSignControl(container, {
19
- allowEdit specific: true,
20
- primaryColor: '#007bff'
18
+ const pdfControl = new PdfSignControl({
19
+ container: container,
20
+ viewMode: 'scroll', // 'single' or 'scroll'
21
+ // pdfLoaderOptions: { ... }
21
22
  });
22
23
 
23
24
  // 2. Load a PDF
24
- await pdfControl.init('https://example.com/sample.pdf');
25
+ await pdfControl.load('https://example.com/sample.pdf');
25
26
 
26
27
  // 3. Add a signature field
27
- pdfControl.addField({
28
- page: 1,
29
- x: 100,
30
- y: 100,
31
- width: 150,
32
- height: 50,
33
- id: 'sign_1'
28
+ await pdfControl.addField({
29
+ pageIndex: 0, // 0-based index
30
+ rect: { x: 100, y: 100, width: 150, height: 50 },
31
+ id: 'sign_1',
32
+ type: 'signature', // or 'text', 'image', 'html'
33
+ draggable: true,
34
+ resizable: true
34
35
  });
35
36
 
36
37
  // 4. Listen to events
37
- container.addEventListener('field:change', (e) => {
38
- console.log('Field updated:', e.detail);
38
+ pdfControl.on('fields:change', (fields) => {
39
+ console.log('Fields updated:', fields);
39
40
  });
40
41
  ```
41
42
 
42
43
  ## API
43
44
 
44
- ### `init(url: string): Promise<void>`
45
- Loads and renders the PDF from the given URL.
45
+ ### `load(source: string | Uint8Array | ArrayBuffer): Promise<void>`
46
+ Loads and renders the PDF from the given URL or buffer.
46
47
 
47
- ### `addField(field: SignatureField): void`
48
+ ### `addField(field: SignatureField): Promise<void>`
48
49
  Adds a new signature field to the document.
49
50
 
50
- ### `setMode(mode: 'single-page' | 'scroll'): void`
51
+ ### `setViewMode(mode: 'single' | 'scroll'): Promise<void>`
51
52
  Switches between single page view and continuous scroll view.
52
53
 
53
- ### `zoomIn() / zoomOut() / setScale(scale: number)`
54
+ ### `setScale(scale: number)`
54
55
  Controls the zoom level of the document.
55
56
 
57
+ ### `getFields(): SignatureField[]`
58
+ Returns the current list of fields.
59
+
56
60
  ## License
57
61
 
58
62
  MIT
package/package.json CHANGED
@@ -1,6 +1,17 @@
1
1
  {
2
2
  "name": "@shznet/pdf-sign-control",
3
- "version": "0.2.0",
3
+ "version": "0.2.1",
4
+ "description": "Core PDF signing logic for @shznet/pdf-sign",
5
+ "license": "MIT",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "https://github.com/ShzNet/pdf-signature-control.git"
9
+ },
10
+ "author": "Chien Tran <chientranit@gmail.com>",
11
+ "bugs": {
12
+ "url": "https://github.com/ShzNet/pdf-signature-control/issues"
13
+ },
14
+ "homepage": "https://github.com/ShzNet/pdf-signature-control#readme",
4
15
  "type": "module",
5
16
  "main": "./dist/index.js",
6
17
  "module": "./dist/index.js",