Here's an example of using Adobe's JavaScript SDK to initiate an e-signature workflow using their API:
// Load the Adobe Sign SDK script
var sdkUrl = 'https://secure.echosign.com/public/docs/1.0/AdobeSign.js';
$.getScript(sdkUrl, function() {
// Initialize the Adobe Sign API with your API credentials
adobeSign.init({
clientId: 'YOUR_CLIENT_ID',
redirectUri: 'YOUR_REDIRECT_URI',
scope: 'user_login:self+agreement_send:self',
accessToken: 'YOUR_ACCESS_TOKEN'
});
// Create a new agreement
var agreement = adobeSign.createAgreement({
documentURL: 'https://example.com/my-document.pdf',
recipientEmail: 'john.doe@example.com',
recipientName: 'John Doe'
});
// Send the agreement for signature
agreement.send().then(function() {
console.log('Agreement sent successfully!');
}).catch(function(err) {
console.error('Error sending agreement:', err);
});
});
Note that you'll need to replace YOUR_CLIENT_ID
, YOUR_REDIRECT_URI
, YOUR_ACCESS_TOKEN
, https://example.com/my-document.pdf
, john.doe@example.com
, and John Doe
with your own values. You'll also need to make sure that you've obtained an access token with the necessary permissions to send agreements.
Integrate adobe api e signature in own web form
To get an e-signature from a user in your own form using the Adobe Sign API, you can follow these general steps:
Here's some sample code to get you started:
<form id="myForm">
<label for="name">Name:</label>
<input type="text" id="name" name="name"><br>
<label for="email">Email:</label>
<input type="email" id="email" name="email"><br>
<label for="document">Document:</label>
<input type="file" id="document" name="document"><br>
<button type="submit" id="submitBtn">Submit</button>
</form>
JavaScript code to handle form submission:
// Load the Adobe Sign SDK script
var sdkUrl = 'https://secure.echosign.com/public/docs/1.0/AdobeSign.js';
$.getScript(sdkUrl, function() {
// Initialize the Adobe Sign API with your API credentials and access token
adobeSign.init({
clientId: 'YOUR_CLIENT_ID',
redirectUri: 'YOUR_REDIRECT_URI',
scope: 'user_login:self+agreement_send:self',
accessToken: 'YOUR_ACCESS_TOKEN'
});
// Handle form submission
$('#myForm').on('submit', function(e) {
e.preventDefault();
// Get form data
var formData = new FormData(this);
var name = formData.get('name');
var email = formData.get('email');
var document = formData.get('document');
// Create a new agreement
var agreement = adobeSign.createAgreement({
documentURL: document,
recipientEmail: email,
recipientName: name,
signatureType: 'ESIGN',
signatureFlow: 'SENDER_SIGNATURE_NOT_REQUIRED',
name: 'My Agreement',
message: 'Please sign this agreement.'
});
// Generate a signing URL for the agreement
agreement.getSigningUrl().then(function(url) {
// Redirect the user to the signing URL
window.location.href = url;
}).catch(function(err) {
console.error('Error generating signing URL:', err);
alert('Error generating signing URL: ' + err.message);
});
});
});
Note that you'll need to replace YOUR_CLIENT_ID, YOUR_REDIRECT_URI
, and YOUR_ACCESS_TOKEN
with your own values. You'll also need to adjust the document
variable to reference the uploaded file correctly, depending on how your form is set up. Additionally, you may need to adjust the options passed to the createAgreement()
method to fit your specific use case.