@shznet/pdf-sign-control 0.2.0 → 0.2.2

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 CHANGED
@@ -15,44 +15,52 @@ 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
+
60
+ ### `print(options?: { withSignatures?: boolean }): Promise<void>`
61
+ Prints the current document.
62
+ - `withSignatures`: If `true`, prints with signature fields overlay. Defaults to `false`.
63
+
56
64
  ## License
57
65
 
58
66
  MIT