Adding quick comments directly onto Word documents is a common requirement for collaborative review workflows. GroupDocs.Annotation Cloud SDK for Node.JS lets you programmatically add rich annotations without leaving your server environment. In this guide we will show you how to create Sticky Notes on Word pages in Node.JS, covering setup, a detailed walkthrough, a complete code example, and equivalent cURL calls.

Setting Up GroupDocs.Annotation Cloud SDK for Node.JS

Before you start, make sure you have:

  • Node.js 14+ and npm installed
  • A GroupDocs cloud account with clientId and clientSecret
  • Access to the source DOCX file you want to annotate

Install the SDK via npm:

npm install groupdocs-annotation-cloud

Download the latest package from the official release page if you prefer a manual install: GroupDocs.Annotation Cloud SDK for Node.JS Download.

Create a configuration object with your credentials (excerpt from the full example):

const { Configuration } = require("@groupdocs.annotation-cloud");

const config = new Configuration({
    clientId: "YOUR_CLIENT_ID",
    clientSecret: "YOUR_CLIENT_SECRET"
});

With the SDK installed and credentials ready, we can move on to the implementation.

Create Sticky Notes on Word Pages in Node.JS: Step-by-Step Walkthrough

In this walkthrough we will create Sticky Notes on Word pages in Node.JS using the SDK’s annotation classes.

Step 1: Initialize the Annotation API

First, import the required classes and create an instance of AnnotateApi.

const { AnnotateApi, models } = require("@groupdocs.annotation-cloud");
const annotateApi = new AnnotateApi(config);

Step 2: Define Source and Destination Files

Specify the input DOCX and the path for the annotated output.

const inputFilePath = "sample.docx";
const outputFilePath = "sample_annotated.docx";

const fileInfo = new models.FileInfo();
fileInfo.filePath = inputFilePath;

Step 3: Set Up the Sticky Note Position

Create a Rectangle that determines where the sticky note will appear on page 1.

const rect = new models.Rectangle();
rect.x = 100;      // distance from left edge (points)
rect.y = 100;      // distance from top edge (points)
rect.width = 200;  // width of the sticky note
rect.height = 100; // height of the sticky note

Step 4: Build the Sticky Note Annotation Object

Configure the annotation type, page number, rectangle, text, and background color.

const stickyNote = new models.AnnotationInfo();
stickyNote.annotationType = "StickyNote";
stickyNote.pageNumber = 1;
stickyNote.rect = rect;
stickyNote.text = "This is a sticky note added via GroupDocs.Annotation Cloud SDK.";
stickyNote.color = "FFFF00"; // Yellow background

Step 5: Execute the Annotation Request

Assemble the request options and call the annotate method.

const annotateOptions = new models.AnnotateOptions();
annotateOptions.fileInfo = fileInfo;
annotateOptions.annotations = [stickyNote];
annotateOptions.outputPath = outputFilePath;

(async () => {
    try {
        const request = new models.AnnotateRequest(annotateOptions);
        const response = await annotateApi.annotate(request);
        console.log("Sticky note created successfully. Output saved to:", response.path);
    } catch (err) {
        console.error("Failed to create sticky note:", err);
    }
})();

Full Working Example for Create Sticky Notes on Word Pages in Node.JS

The following example demonstrates the complete implementation for creating Sticky Notes on Word pages in Node.JS using GroupDocs.Annotation Cloud SDK.

const { AnnotateApi, Configuration, models } = require("@groupdocs.annotation-cloud");

// -----------------------------------------------------------------------------
// Configuration – replace with your actual GroupDocs credentials
// -----------------------------------------------------------------------------
const config = new Configuration({
    clientId: "YOUR_CLIENT_ID",
    clientSecret: "YOUR_CLIENT_SECRET"
});

const annotateApi = new AnnotateApi(config);

// -----------------------------------------------------------------------------
// Define input and output files
// -----------------------------------------------------------------------------
const inputFilePath = "sample.docx";
const outputFilePath = "sample_annotated.docx";

// -----------------------------------------------------------------------------
// Build FileInfo object for the source document
// -----------------------------------------------------------------------------
const fileInfo = new models.FileInfo();
fileInfo.filePath = inputFilePath;

// -----------------------------------------------------------------------------
// Define rectangle (position & size) for the sticky note on page 1
// -----------------------------------------------------------------------------
const rect = new models.Rectangle();
rect.x = 100;      // distance from left edge (points)
rect.y = 100;      // distance from top edge (points)
rect.width = 200;  // width of the sticky note
rect.height = 100; // height of the sticky note

// -----------------------------------------------------------------------------
// Create the sticky‑note annotation
// -----------------------------------------------------------------------------
const stickyNote = new models.AnnotationInfo();
stickyNote.annotationType = "StickyNote";
stickyNote.pageNumber = 1;
stickyNote.rect = rect;
stickyNote.text = "This is a sticky note added via GroupDocs.Annotation Cloud SDK.";
stickyNote.color = "FFFF00"; // Yellow background

// -----------------------------------------------------------------------------
// Assemble the annotate request options
// -----------------------------------------------------------------------------
const annotateOptions = new models.AnnotateOptions();
annotateOptions.fileInfo = fileInfo;
annotateOptions.annotations = [stickyNote];
annotateOptions.outputPath = outputFilePath;

// -----------------------------------------------------------------------------
// Execute the request
// -----------------------------------------------------------------------------
(async () => {
    try {
        const request = new models.AnnotateRequest(annotateOptions);
        const response = await annotateApi.annotate(request);
        console.log("Sticky note created successfully. Output saved to:", response.path);
    } catch (err) {
        console.error("Failed to create sticky note:", err);
    }
})();

Note: This code example demonstrates the core functionality. Before using it in your project, make sure to update any file paths and configuration values to match your actual environment, verify that all required dependencies are properly installed, and test thoroughly in your development environment. If you encounter any issues, please refer to the official documentation or reach out to the support team for assistance.

Adding Sticky Note Annotations with cURL and the REST API

The REST API offers the same capability without writing code. Below are the required cURL calls.

First, obtain an access token:

curl -X POST "https://api.groupdocs.cloud/v2.0.0/auth/token" \
     -H "Content-Type: application/json" \
     -d '{"client_id":"YOUR_CLIENT_ID","client_secret":"YOUR_CLIENT_SECRET"}'

Upload the source DOCX file (replace YOUR_ACCESS_TOKEN with the token from the previous step):

curl -X PUT "https://api.groupdocs.cloud/v2.0.0/storage/file/sample.docx" \
     -H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
     -H "Content-Type: application/octet-stream" \
     --data-binary @sample.docx

Create the sticky note annotation:

curl -X POST "https://api.groupdocs.cloud/v2.0.0/annotation/annotate" \
     -H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
     -H "Content-Type: application/json" \
     -d '{
           "fileInfo": { "filePath": "sample.docx" },
           "annotations": [
               {
                   "annotationType": "StickyNote",
                   "pageNumber": 1,
                   "rect": { "x": 100, "y": 100, "width": 200, "height": 100 },
                   "text": "This is a sticky note added via GroupDocs.Annotation Cloud SDK.",
                   "color": "FFFF00"
               }
           ],
           "outputPath": "sample_annotated.docx"
         }'

Download the annotated document:

curl -X GET "https://api.groupdocs.cloud/v2.0.0/storage/file/sample_annotated.docx?download=true" \
     -H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
     -o sample_annotated.docx

For more details on request payloads, see the API reference.

Configuring Annotation Options for Sticky Notes

The SDK exposes several properties that let you fine‑tune the sticky note appearance and behavior:

  • annotationType - must be set to "StickyNote" (required).
  • pageNumber - the page where the note will appear.
  • rect - defines position (x, y) and size (width, height). Adjust these values to control placement.
  • text - the note content.
  • color - background color in HEX (e.g., "FFFF00" for yellow).

You can also set optional fields such as author, fontFamily, or opacity via the AnnotationInfo model. Refer to the API reference for the complete list of configurable properties.

Conclusion

By following the steps above you now know how to create Sticky Notes on Word pages in Node.JS using GroupDocs.Annotation Cloud SDK. Whether you prefer a native Node.js implementation or a REST‑based cURL workflow, the SDK provides a consistent and reliable way to annotate DOCX files programmatically. Remember to apply a valid license for production use; you can obtain a temporary license from the license page or review pricing options on the product page. Happy annotating!

FAQs

  • How can I create Sticky Notes on Word pages in Node.JS using GroupDocs.Annotation Cloud SDK?
    Use the AnnotateApi as demonstrated in the code example. The SDK handles file access, annotation creation, and output generation automatically.

  • What file formats are supported for annotation with the SDK?
    The SDK works with DOCX, PDF, PPTX, XLSX, and many other popular formats. See the full list in the official documentation.

  • How do I authenticate when using the REST API for sticky notes?
    Obtain an access token via the /auth/token endpoint using your client credentials, then include the token in the Authorization: Bearer header for all subsequent calls. Detailed steps are in the API reference.

  • Can I customize the sticky note color or size?
    Yes. Set the color property to a HEX value and adjust the rect dimensions (width, height) to control the note’s size and placement.

Read More