Word 문서에 직접 빠른 주석을 추가하는 것은 협업 검토 워크플로우에서 일반적인 요구 사항입니다. GroupDocs.Annotation Cloud SDK for Node.JS를 사용하면 서버 환경을 떠나지 않고도 프로그래밍 방식으로 풍부한 주석을 추가할 수 있습니다. 이 가이드에서는 Node.JS에서 Word 페이지에 스티키 노트를 만드는 방법을 보여드리며, 설정, 자세한 단계별 안내, 전체 코드 예제 및 동등한 cURL 호출을 다룹니다.
GroupDocs.Annotation Cloud SDK for Node.JS 설정
시작하기 전에, 다음이 준비되어 있는지 확인하십시오:
- Node.js 14+ 및 npm이 설치되어 있어야 합니다.
- clientId 및 clientSecret가 포함된 GroupDocs 클라우드 계정
- 주석을 달고자 하는 원본 DOCX 파일에 대한 액세스
npm을 통해 SDK를 설치합니다:
npm install groupdocs-annotation-cloud
수동 설치를 선호하는 경우 공식 릴리스 페이지에서 최신 패키지를 다운로드하십시오: GroupDocs.Annotation Cloud SDK for Node.JS 다운로드.
자격 증명을 사용하여 구성 객체를 생성합니다 (전체 예제에서 발췌):
const { Configuration } = require("@groupdocs.annotation-cloud");
const config = new Configuration({
clientId: "YOUR_CLIENT_ID",
clientSecret: "YOUR_CLIENT_SECRET"
});
SDK를 설치하고 자격 증명이 준비되면 구현 단계로 넘어갈 수 있습니다.
Node.JS에서 Word 페이지에 스티키 노트 만들기: 단계별 워크스루
이 단계별 가이드에서는 SDK의 주석 클래스를 사용하여 Node.JS에서 Word 페이지에 스티키 노트를 생성합니다.
단계 1: 주석 API 초기화
먼저, 필요한 클래스를 가져오고 AnnotateApi의 인스턴스를 생성합니다.
const { AnnotateApi, models } = require("@groupdocs.annotation-cloud");
const annotateApi = new AnnotateApi(config);
2단계: 소스 및 대상 파일 정의
입력 DOCX와 주석이 달린 출력 파일의 경로를 지정합니다.
const inputFilePath = "sample.docx";
const outputFilePath = "sample_annotated.docx";
const fileInfo = new models.FileInfo();
fileInfo.filePath = inputFilePath;
3단계: 스티키 노트 위치 설정
스티키 노트가 페이지 1에 표시될 위치를 결정하는 Rectangle를 생성합니다.
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
4단계: 스티키 노트 주석 객체 만들기
주석 유형, 페이지 번호, 사각형, 텍스트 및 배경 색을 구성합니다.
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
5단계: 주석 요청 실행
요청 옵션을 조합하고 annotate 메서드를 호출합니다.
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);
}
})();
Node.JS에서 Word 페이지에 스티키 노트를 만드는 전체 작업 예제
다음 예제는 Node.JS에서 GroupDocs.Annotation Cloud SDK를 사용하여 Word 페이지에 스티키 노트를 생성하는 전체 구현을 보여줍니다.
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);
}
})();
참고: 이 코드 예제는 핵심 기능을 보여줍니다. 프로젝트에 사용하기 전에 파일 경로와 구성 값을 실제 환경에 맞게 업데이트하고, 모든 필수 종속성이 올바르게 설치되었는지 확인한 뒤 개발 환경에서 충분히 테스트하십시오. 문제가 발생하면 공식 문서를 참조하거나 지원 팀에게 문의하십시오.
cURL 및 REST API를 사용한 스티키 노트 주석 추가
REST API는 코드를 작성하지 않고도 동일한 기능을 제공합니다. 아래는 필요한 cURL 호출입니다.
먼저 액세스 토큰을 얻으세요:
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"}'
소스 DOCX 파일을 업로드하십시오 (이전 단계에서 얻은 토큰으로 YOUR_ACCESS_TOKEN을 교체하십시오):
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
스티키 노트 주석 만들기:
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"
}'
주석이 달린 문서를 다운로드하십시오:
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
요청 페이로드에 대한 자세한 내용은 API 참조를 참조하십시오.
스티키 노트에 대한 주석 옵션 구성
SDK는 스티키 노트의 모양과 동작을 세밀하게 조정할 수 있는 여러 속성을 제공합니다:
- annotationType -
"StickyNote"(필수) 로 설정해야 합니다. - pageNumber - 메모가 표시될 페이지.
- rect - 위치(
x,y)와 크기(width,height)를 정의합니다. 배치를 제어하려면 이 값을 조정하십시오. - text - 메모 내용.
- color - HEX 형식의 배경 색상(예: 노란색은
"FFFF00").
또한 author, fontFamily, 또는 opacity와 같은 선택적 필드를 AnnotationInfo 모델을 통해 설정할 수 있습니다. 구성 가능한 속성의 전체 목록은 API 참조를 참조하십시오.
결론
위 단계들을 따라 하면 이제 Node.JS에서 GroupDocs.Annotation Cloud SDK를 사용하여 Word 페이지에 스티키 노트를 만드는 방법을 알게 되었습니다. 네이티브 Node.js 구현을 선호하든 REST‑기반 cURL 워크플로를 선호하든, SDK는 DOCX 파일을 프로그래밍 방식으로 주석 달기 위한 일관되고 신뢰할 수 있는 방법을 제공합니다. 프로덕션 사용을 위해 유효한 라이선스를 적용하는 것을 기억하세요; 임시 라이선스는 라이선스 페이지에서 얻을 수 있으며 제품 페이지에서 가격 옵션을 검토할 수 있습니다. 주석 달기를 즐기세요!
FAQs
Node.JS에서 GroupDocs.Annotation Cloud SDK를 사용하여 Word 페이지에 스티키 노트를 만들려면 어떻게 해야 하나요?
코드 예제에 표시된 AnnotateApi를 사용하십시오. SDK는 파일 액세스, 주석 생성 및 출력 생성을 자동으로 처리합니다.SDK로 주석을 달 수 있는 파일 형식은 무엇인가요?
SDK는 DOCX, PDF, PPTX, XLSX, 및 기타 많은 인기 형식을 지원합니다. 전체 목록은 공식 문서에서 확인하세요.REST API를 사용하여 스티키 노트를 사용할 때 인증은 어떻게 하나요?
클라이언트 자격 증명을 사용하여/auth/token엔드포인트를 통해 액세스 토큰을 얻은 다음, 이후 모든 호출에Authorization: Bearer헤더에 토큰을 포함합니다. 자세한 단계는 API 참조에 있습니다.스티키 노트 색상이나 크기를 사용자 지정할 수 있나요?
예.color속성을 HEX 값으로 설정하고rect차원(width,height)을 조정하여 노트의 크기와 위치를 제어합니다.
