Skip to main content

Quickstart

The full details of the Javascript SDK are available on GitHub here: exportsdk-js. To make things easy, a condensed overview of how to get started is below.

Install the package#

npm install @exportsdk/client

Import the client#

Import the client class and instantiate it with an API key. Both the ES module syntax and CommonJS module syntax are supported.

// ES Moduleimport { ExportSdkClient } from '@exportsdk/client';
// CommonJS moduleconst { ExportSdkClient } = require('@exportsdk/client');
const client = new ExportSdkClient(process.env.EXPORTSDK_API_KEY);

Render PDFs#

Begin rendering PDFs by providing a template ID (obtained from the ExportSDK dashboard) and the data required for that template. PDFs can be generated as NodeJS readable streams (convenient for sending as HTTP responses) or binary data.

const templateId = 'eea2644c-9110-453f-a558-b0541664fb52';const templateData = {  firstName: 'Jon',  middleName: 'Bon',  lastName: 'Jovi',};
const binary = await client.renderPdf(templateId, templateData);const stream = await client.renderPdfToStream(templateId, templateData);