Repository navigation
Expand file tree
/
Copy pathturbosign-basic.ts
More file actions
123 lines (114 loc) · 3.47 KB
/
Copy pathturbosign-basic.ts
File metadata and controls
123 lines (114 loc) · 3.47 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
/**
* Example 2: Review Link - Template Anchors
*
* This example creates a review link first, then sends manually.
* Uses template anchors like {signature1} and {date1} in your PDF.
*
* Use this when: You want to review the document before sending
*/
import { TurboSign } from '@turbodocx/sdk';
import * as fs from 'fs';
async function reviewLinkExample() {
TurboSign.configure({
apiKey: process.env.TURBODOCX_API_KEY || 'your-api-key-here',
orgId: process.env.TURBODOCX_ORG_ID || 'your-org-id-here',
senderEmail: process.env.TURBODOCX_SENDER_EMAIL || 'support@yourcompany.com',
senderName: process.env.TURBODOCX_SENDER_NAME || 'Your Company Name'
});
try {
const pdfFile = fs.readFileSync('../../ExampleAssets/sample-contract.pdf');
console.log('Creating review link with template anchors...\n');
const result = await TurboSign.createSignatureReviewLink({
file: pdfFile,
documentName: 'Contract Agreement',
documentDescription: 'This document requires electronic signatures from both parties.',
recipients: [
{
name: 'John Doe',
email: 'john@example.com',
signingOrder: 1
},
{
name: 'Jane Smith',
email: 'jane@example.com',
signingOrder: 2
}
],
fields: [
// First recipient - using template anchors
{
type: 'full_name',
recipientEmail: 'john@example.com',
template: {
anchor: '{name1}',
placement: 'replace',
size: { width: 100, height: 30 }
}
},
{
type: 'signature',
recipientEmail: 'john@example.com',
template: {
anchor: '{signature1}',
placement: 'replace',
size: { width: 100, height: 30 }
}
},
{
type: 'date',
recipientEmail: 'john@example.com',
template: {
anchor: '{date1}',
placement: 'replace',
size: { width: 75, height: 30 }
}
},
// Second recipient
{
type: 'full_name',
recipientEmail: 'jane@example.com',
template: {
anchor: '{name2}',
placement: 'replace',
size: { width: 100, height: 30 }
}
},
{
type: 'signature',
recipientEmail: 'jane@example.com',
template: {
anchor: '{signature2}',
placement: 'replace',
size: { width: 100, height: 30 }
}
},
{
type: 'date',
recipientEmail: 'jane@example.com',
template: {
anchor: '{date2}',
placement: 'replace',
size: { width: 75, height: 30 }
}
}
]
});
console.log('\n✅ Review link created!');
console.log('Document ID:', result.documentId);
console.log('Status:', result.status);
console.log('Preview URL:', result.previewUrl);
if (result.recipients) {
console.log('\nRecipients:');
result.recipients.forEach(recipient => {
console.log(` ${recipient.name} (${recipient.email}) - ${recipient.status}`);
});
}
console.log('\nYou can now:');
console.log('1. Review the document at the preview URL');
console.log('2. Send to recipients using: await TurboSign.send(documentId);');
} catch (error) {
console.error('Error:', error);
}
}
// Run the example
reviewLinkExample();