createDocFromBase64Async
Create a document via a base64 PDF Asynchronously
Overview
Parameters:
Return:
DocAsyncResponse - In case of success
Exception - In case of failure
To create this document we will need:
set your apiToken;
build your signers;
build the document;
call the method;
How to use:
Save your apiToken:
const apiToken: string = "YOUR TOKEN";
Set your base64:
const base64: string = "JVBERi0xLjYKJcOkw7zDtsOfCjIgMCBvYmoKPDwvTG..."
Build your signers with the Signer class:
const signer1: Signer = new SignerBuilder()
.withName("My First Signer")
.build();
const signer2: Signer = new SignerBuilder()
.withName("My Second Signer")
.withEmail("[email protected]")
.withLockEmail(true)
.withLockPhone(true)
.withPhoneCountry("55")
.withPhoneNumber("99999999999")
.withAuthMode("assinaturaTela") // draw on screen
.withSendAutomaticEmail(false)
.withSendAutomaticWhatsapp(false)
.build();
let signers: Signer[] = [];
signers.push(signer1, signer2);
Build your document with the DocFromPdfBase64 class:
const docFromPdfBase64 = DocFromPdfBase64Builder()
.withSandbox(false)
.withName("My Contract")
.withBrandPrimaryColor("#000000")
.withBase64Pdf(base64)
.build();
Finally, call the createDocFromPdfBase64 method to get the DocResponse or an error message:
try {
docResponse = new DocRequests(apiToken).createDocFromPdfBase64(docFromPdfBase64);
jsonDocResponse: string = new JsonConverter().docResponseToJson(docResponse);
console.log(jsonDocResponse);
} catch {
console.log(Err);
}
Example:
import DocRequests from "sdk-node-typescript-zapsign/src/docs/DocRequests";
import { JsonConverter } from "sdk-node-typescript-zapsign/src/services/JsonConverter";
const apiToken: string = "YOUR TOKEN";
const base64: string = "JVBERi0xLjYKJcOkw7zDtsOfCjIgMCBvYmoKP...";
const signer1: Signer = new SignerBuilder()
.withName("My First Signer")
.build();
const signer2: Signer = new SignerBuilder()
.withName("My Second Signer")
.withEmail("[email protected]")
.withLockEmail(true)
.withLockPhone(true)
.withPhoneCountry("55")
.withPhoneNumber("99999999999")
.withAuthMode("assinaturaTela") // draw on screen
.withSendAutomaticEmail(false)
.withSendAutomaticWhatsapp(false)
.build();
let signers: Signer[] = [];
signers.push(signer1, signer2);
const docFromPdfBase64 = DocFromPdfBase64Builder()
.withSandbox(false)
.withName("My Contract")
.withBrandPrimaryColor("#000000")
.build();
async function exempleDocFRomPdfBase64Async() {
try {
docResponse: DocResponse = await new DocRequests(apiToken).createDocFromPdfBase64Async(docFromPdfBase64);
jsonDocResponse: string = new JsonConverter().docResponseToJson(docResponse);
console.log(jsonDocResponse);
} catch(Err) {
console.log(Err);
}
}
}
Last updated
Was this helpful?