Node.js SDK for Document Assembly & Report Generation

Integrate powerful document assembly capabilities into your Node applications using GroupDocs.Assembly Cloud REST API.

  • GroupDocs.Assembly Cloud SDK for cURL
  • GroupDocs.Assembly Cloud SDK for .NET
  • GroupDocs.Assembly Cloud SDK for Java
  • GroupDocs.Assembly Cloud SDK for PHP
  • GroupDocs.Assembly Cloud SDK for Python
  • GroupDocs.Assembly Cloud SDK for Ruby
  • GroupDocs.Assembly Cloud SDK for Go
  • GroupDocs.Assembly Cloud SDK for C++
  • GroupDocs.Assembly Cloud SDK for Swift
Start Free Trial

GroupDocs.Assembly Cloud is a fully managed, REST‑based service that enables developers to create richly formatted, print‑ready documents from reusable templates and external data sources.

The platform supports a wide variety of source and target formats – from classic Microsoft Office files (DOCX, XLSX, PPTX) to PDF, HTML, OpenDocument, and many graphic formats – allowing you to generate contracts, invoices, reports, marketing brochures, or any custom document without installing any third‑party software on your own servers. All heavy lifting – template parsing, data binding, image rendering, barcode generation, formula evaluation, and file conversion – is performed in the cloud, which ensures consistent results across operating systems and reduces infrastructure costs.

Why use the Node.js SDK?

  • Zero‑install runtime – the SDK is a thin wrapper around the Assembly Cloud REST API, so you only need Node 12+ and an npm package.
  • Cross‑platform – works the same on Windows, macOS, Linux, or inside containers.
  • Secure – all communication is encrypted via TLS, and authentication is performed with your personal App SID and App Key.
  • Scalable – the cloud service can handle single‑document requests as well as high‑volume batch Mail‑Merge jobs.
  • Extensible – the same API can be used from any language that can call REST endpoints; the Node.js SDK simply simplifies request construction and response handling.

Typical workflow in a Node.js application

  1. Prepare a template (DOCX, PPTX, etc.) that contains placeholder fields and optional programming constructs such as conditional blocks, loops, or barcode tags.
  2. Create a data source in XML or JSON that provides the values to be merged into the template.
  3. Upload the template to GroupDocs Cloud Storage using the SDK’s uploadFile method.
  4. Configure AssembleOptions – specify the template path, the data source, the desired output format (PDF, DOCX, HTML, …) and any additional settings (e.g., barcode generation, background color).
  5. Call assembleDocument – the SDK sends a single HTTP request that triggers the assembly process on the server.
  6. Receive the assembled file as a byte array, save it locally or stream it directly to the client.

The following example (shown in the More Feature section) demonstrates each of these steps in a compact, production‑ready code snippet.

GroupDocs.Assembly Cloud API Features

Generate documents from templates using cloud REST API

LINQ‑style data binding for XML and JSON sources

Insert images, charts and external document content

Dynamic tables and lists from array data

Add hyperlinks, bookmarks and email attachments

Apply formulas and sequential data operations

Conditional content blocks (IF‑ELSE) in templates

Generate barcodes (QR, Code128, etc.)

Set background colors for HTML output

Mail‑Merge for batch personalized letters

Generate a report in Node.js

The snippet below demonstrates a complete flow: upload a template, read a JSON data file, configure the assembly request and receive the assembled document.

Steps

  1. Upload the DOCX template to GroupDocs Cloud Storage.
  2. Read the JSON data file that contains the values to be merged.
  3. Configure AssembleOptions – choose the output format and bind the data.
  4. Call assembleDocument to generate the report.
  5. Save the returned byte array as a PDF (or any supported format).
// Replace with your App SID and App Key
const { AssemblyApi, AssembleDocumentRequest, AssembleOptions, TemplateFileInfo, model } = require("groupdocs-assembly-cloud");
const fs = require("fs");
const path = require("path");

// Authorization placeholder
const assemblyApi = new AssemblyApi("####-####-####-####-####", "##################");

// 1️⃣ Upload the template file
const templatePath = "Input1.docx";
const uploadRequest = new model.UploadFileRequest({
    fileContent: fs.createReadStream(templatePath),
    path: templatePath
});
await assemblyApi.uploadFile(uploadRequest);

// 2️⃣ Read the data source (JSON)
const dataPath = "Input2.docx";
const reportData = fs.readFileSync(dataPath, "utf8");

// 3️⃣ Set assembly options
const assembleOptions = new AssembleOptions({
    saveFormat: "pdf",
    reportData: reportData,
    templateFileInfo: new TemplateFileInfo({ filePath: templatePath })
});

// 4️⃣ Create and send the assemble request
const request = new AssembleDocumentRequest({ assembleOptions });
const result = await assemblyApi.assembleDocument(request);

// 5️⃣ Save the resulting document
const outputPath = path.join(__dirname, "GeneratedReport.pdf");
fs.writeFileSync(outputPath, result.body);

console.log("Report generated successfully:", outputPath);

Support and Learning Resources

GroupDocs.Assembly Cloud also offers SDKs for other languages:

  English
a9faf15