Integrate powerful document assembly capabilities into your Node applications using GroupDocs.Assembly Cloud REST API.
Start Free TrialGroupDocs.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?
Typical workflow in a Node.js application
uploadFile method.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).assembleDocument – the SDK sends a single HTTP request that triggers the assembly process on the server.The following example (shown in the More Feature section) demonstrates each of these steps in a compact, production‑ready code snippet.
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
AssembleOptions – choose the output format and bind the data.assembleDocument to generate the report.// 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);