Skip to content

Instantly share code, notes, and snippets.

@groupdocscloud
Last active October 23, 2019 11:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save groupdocscloud/18dbfb11660d5c7555df9b7886856763 to your computer and use it in GitHub Desktop.
Save groupdocscloud/18dbfb11660d5c7555df9b7886856763 to your computer and use it in GitHub Desktop.
Annotation-Node-v2
"use strict";
class Annotation_Node_Add_Annotation {
static Run() {
var annotation = new groupdocs_annotation_cloud_1.AnnotationInfo();
annotation.annotationPosition = new groupdocs_annotation_cloud_1.Point();
annotation.annotationPosition.x = 852;
annotation.annotationPosition.y = 59.388262910798119;
annotation.box = new groupdocs_annotation_cloud_1.Rectangle();
annotation.box.x = 375.89276123046875;
annotation.box.y = 59.388263702392578;
annotation.box.width = 88.7330551147461;
annotation.box.height = 37.7290153503418;
annotation.pageNumber = 0;
annotation.penColor = 1201033;
annotation.penStyle = 0;
annotation.penWidth = 1;
annotation.type = groupdocs_annotation_cloud_1.AnnotationInfo.TypeEnum.Area;
annotation.creatorName = "Anonym annotation.";
var request = new groupdocs_annotation_cloud_1.PostAnnotationsRequest("annotations\\one-page.docx", [annotation]);
annotateApi.postAnnotations(request)
.then(function (response) {
console.log("Expected response type is void: Annotation added.");
})
.catch(function (error) {
console.log("Error: " + error.message);
});
}
}
module.exports = Annotation_Node_Add_Annotation;
"use strict";
class Annotation_Node_Add_Area_Annotation {
static Run() {
let a1 = new groupdocs_annotation_cloud_1.AnnotationInfo();
a1.annotationPosition = new groupdocs_annotation_cloud_1.Point();
a1.annotationPosition.x = 852;
a1.annotationPosition.y = 59.388262910798119;
a1.box = new groupdocs_annotation_cloud_1.Rectangle();
a1.box.x = 375.89276123046875;
a1.box.y = 59.388263702392578;
a1.box.width = 88.7330551147461;
a1.box.height = 37.7290153503418;
a1.pageNumber = 2;
a1.penColor = 1201033;
a1.penStyle = 0;
a1.penWidth = 1;
a1.type = groupdocs_annotation_cloud_1.AnnotationInfo.TypeEnum.Area;
a1.text = "This is area annotation";
a1.creatorName = "Anonym A.";
var request = new groupdocs_annotation_cloud_1.PostAnnotationsRequest("Annotationdocs\\ten-pages.pdf", [a1]);
annotateApi.postAnnotations(request)
.then(function (response) {
console.log("Expected response type is void: Area Annotation added.");
})
.catch(function (error) {
console.log("Error: " + error.message);
});
}
}
module.exports = Annotation_Node_Add_Area_Annotation;
"use strict";
class Annotation_Node_Add_Distance_Annotation {
static Run() {
let a1 = new groupdocs_annotation_cloud_1.AnnotationInfo();
a1.annotationPosition = new groupdocs_annotation_cloud_1.Point();
a1.annotationPosition.x = 852;
a1.annotationPosition.y = 59.388262910798119;
a1.box = new groupdocs_annotation_cloud_1.Rectangle();
a1.box.x = 375.89276123046875;
a1.box.y = 59.388263702392578;
a1.box.width = 88.7330551147461;
a1.box.height = 37.7290153503418;
a1.pageNumber = 0;
a1.penColor = 1201033;
a1.penStyle = 0;
a1.penWidth = 1;
a1.type = groupdocs_annotation_cloud_1.AnnotationInfo.TypeEnum.Distance;
a1.text = "This is distance annotation";
a1.creatorName = "Anonym A.";
var request = new groupdocs_annotation_cloud_1.PostAnnotationsRequest("Annotationdocs\\ten-pages.pdf", [a1]);
annotateApi.postAnnotations(request)
.then(function (response) {
console.log("Expected response type is void: Distance Annotation added.");
})
.catch(function (error) {
console.log("Error: " + error.message);
});
}
}
module.exports = Annotation_Node_Add_Distance_Annotation;
"use strict";
class Annotation_Node_Add_Multiple_Annotations {
static Run() {
let a1 = new groupdocs_annotation_cloud_1.AnnotationInfo();
a1.annotationPosition = new groupdocs_annotation_cloud_1.Point();
a1.annotationPosition.x = 852;
a1.annotationPosition.y = 59.388262910798119;
a1.box = new groupdocs_annotation_cloud_1.Rectangle();
a1.box.x = 375.89276123046875;
a1.box.y = 59.388263702392578;
a1.box.width = 88.7330551147461;
a1.box.height = 37.7290153503418;
a1.pageNumber = 0;
a1.penColor = 1201033;
a1.penStyle = 0;
a1.penWidth = 1;
a1.type = groupdocs_annotation_cloud_1.AnnotationInfo.TypeEnum.Distance;
a1.text = "This is distance annotation";
a1.creatorName = "Anonym A.";
let a2 = new groupdocs_annotation_cloud_1.AnnotationInfo();
a2.annotationPosition = new groupdocs_annotation_cloud_1.Point();
a2.annotationPosition.x = 852;
a2.annotationPosition.y = 59.388262910798119;
a2.box = new groupdocs_annotation_cloud_1.Rectangle();
a2.box.x = 375.89276123046875;
a2.box.y = 59.388263702392578;
a2.box.width = 88.7330551147461;
a2.box.height = 37.7290153503418;
a2.pageNumber = 2;
a2.penColor = 1201033;
a2.penStyle = 0;
a2.penWidth = 1;
a2.type = groupdocs_annotation_cloud_1.AnnotationInfo.TypeEnum.Area;
a1.text = "This is area annotation";
a2.creatorName = "Anonym A.";
let a3 = new groupdocs_annotation_cloud_1.AnnotationInfo();
a3.annotationPosition = new groupdocs_annotation_cloud_1.Point();
a3.annotationPosition.x = 852;
a3.annotationPosition.y = 59.388262910798119;
a3.box = new groupdocs_annotation_cloud_1.Rectangle();
a3.box.x = 375.89276123046875;
a3.box.y = 59.388263702392578;
a3.box.width = 88.7330551147461;
a3.box.height = 37.7290153503418;
a3.pageNumber = 4;
a3.type = groupdocs_annotation_cloud_1.AnnotationInfo.TypeEnum.Point;
a1.text = "This is point annotation";
a3.creatorName = "Anonym A.";
let a4 = new groupdocs_annotation_cloud_1.AnnotationInfo();
a4.annotationPosition = new groupdocs_annotation_cloud_1.Point();
a4.annotationPosition.x = 852;
a4.annotationPosition.y = 59.388262910798119;
a4.box = new groupdocs_annotation_cloud_1.Rectangle();
a4.box.x = 375.89276123046875;
a4.box.y = 59.388263702392578;
a4.box.width = 88.7330551147461;
a4.box.height = 37.7290153503418;
a4.pageNumber = 5;
a4.penColor = 1201033;
a4.penStyle = 0;
a4.penWidth = 1;
a4.type = groupdocs_annotation_cloud_1.AnnotationInfo.TypeEnum.Arrow;
a1.text = "This is arrow annotation";
a4.creatorName = "Anonym A.";
var request = new groupdocs_annotation_cloud_1.PostAnnotationsRequest("Annotationdocs\\ten-pages.pdf", [a1, a2, a3, a4]);
annotateApi.postAnnotations(request)
.then(function (response) {
console.log("Expected response type is void: Multiple Annotations added.");
})
.catch(function (error) {
console.log("Error: " + error.message);
});
}
}
module.exports = Annotation_Node_Add_Multiple_Annotations;
"use strict";
class Annotation_Node_Add_Point_Annotation {
static Run() {
let a1 = new groupdocs_annotation_cloud_1.AnnotationInfo();
a1.annotationPosition = new groupdocs_annotation_cloud_1.Point();
a1.annotationPosition.x = 852;
a1.annotationPosition.y = 59.388262910798119;
a1.box = new groupdocs_annotation_cloud_1.Rectangle();
a1.box.x = 375.89276123046875;
a1.box.y = 59.388263702392578;
a1.box.width = 88.7330551147461;
a1.box.height = 37.7290153503418;
a1.pageNumber = 2;
a1.type = groupdocs_annotation_cloud_1.AnnotationInfo.TypeEnum.Point;
a1.text = "This is point annotation";
a1.creatorName = "Anonym A.";
var request = new groupdocs_annotation_cloud_1.PostAnnotationsRequest("Annotationdocs\\ten-pages.pdf", [a1]);
annotateApi.postAnnotations(request)
.then(function (response) {
console.log("Expected response type is void: Point Annotation added.");
})
.catch(function (error) {
console.log("Error: " + error.message);
});
}
}
module.exports = Annotation_Node_Add_Point_Annotation;
"use strict";
class Annotation_Node_Add_Polyline_Annotation {
static Run() {
let a1 = new groupdocs_annotation_cloud_1.AnnotationInfo();
a1.annotationPosition = new groupdocs_annotation_cloud_1.Point();
a1.annotationPosition.x = 852;
a1.annotationPosition.y = 59.388262910798119;
a1.box = new groupdocs_annotation_cloud_1.Rectangle();
a1.box.x = 375.89276123046875;
a1.box.y = 59.388263702392578;
a1.box.width = 88.7330551147461;
a1.box.height = 37.7290153503418;
a1.pageNumber = 0;
a1.penColor = 1201033;
a1.penStyle = 0;
a1.penWidth = 1;
a1.type = groupdocs_annotation_cloud_1.AnnotationInfo.TypeEnum.Polyline;
a1.text = "This is polyline annotation";
a1.creatorName = "Anonym A.";
var request = new groupdocs_annotation_cloud_1.PostAnnotationsRequest("Annotationdocs\\ten-pages.pdf", [a1]);
annotateApi.postAnnotations(request)
.then(function (response) {
console.log("Expected response type is void: Polyline Annotation added.");
})
.catch(function (error) {
console.log("Error: " + error.message);
});
}
}
module.exports = Annotation_Node_Add_Polyline_Annotation;
"use strict";
class Annotation_Node_Add_Text_Annotation {
static Run() {
let a1 = new groupdocs_annotation_cloud_1.AnnotationInfo();
a1.annotationPosition = new groupdocs_annotation_cloud_1.Point();
a1.annotationPosition.x = 852;
a1.annotationPosition.y = 59.388262910798119;
a1.box = new groupdocs_annotation_cloud_1.Rectangle();
a1.box.x = 375.89276123046875;
a1.box.y = 59.388263702392578;
a1.box.width = 88.7330551147461;
a1.box.height = 37.7290153503418;
a1.pageNumber = 2;
a1.fontColor = 65535;
a1.fontSize = 12;
a1.type = groupdocs_annotation_cloud_1.AnnotationInfo.TypeEnum.Text;
a1.text = "This is text annotation";
a1.creatorName = "Anonym A.";
var request = new groupdocs_annotation_cloud_1.PostAnnotationsRequest("Annotationdocs\\ten-pages.pdf", [a1]);
annotateApi.postAnnotations(request)
.then(function (response) {
console.log("Expected response type is void: Text Annotation added.");
})
.catch(function (error) {
console.log("Error: " + error.message);
});
}
}
module.exports = Annotation_Node_Add_Text_Annotation;
"use strict";
class Annotation_Node_Add_TextField_Annotation {
static Run() {
let a1 = new groupdocs_annotation_cloud_1.AnnotationInfo();
a1.annotationPosition = new groupdocs_annotation_cloud_1.Point();
a1.annotationPosition.x = 852;
a1.annotationPosition.y = 59.388262910798119;
a1.box = new groupdocs_annotation_cloud_1.Rectangle();
a1.box.x = 375.89276123046875;
a1.box.y = 59.388263702392578;
a1.box.width = 88.7330551147461;
a1.box.height = 37.7290153503418;
a1.pageNumber = 2;
a1.fontColor = 65535;
a1.fontSize = 12;
a1.type = groupdocs_annotation_cloud_1.AnnotationInfo.TypeEnum.TextField;
a1.text = "This is text annotation";
a1.fieldText = "Text field text";
a1.creatorName = "Anonym A.";
var request = new groupdocs_annotation_cloud_1.PostAnnotationsRequest("Annotationdocs\\ten-pages.pdf", [a1]);
annotateApi.postAnnotations(request)
.then(function (response) {
console.log("Expected response type is void: Text Field Annotation added.");
})
.catch(function (error) {
console.log("Error: " + error.message);
});
}
}
module.exports = Annotation_Node_Add_TextField_Annotation;
"use strict";
class Annotation_Node_Add_TextRedaction_Annotation {
static Run() {
let a1 = new groupdocs_annotation_cloud_1.AnnotationInfo();
a1.annotationPosition = new groupdocs_annotation_cloud_1.Point();
a1.annotationPosition.x = 852;
a1.annotationPosition.y = 59.388262910798119;
a1.box = new groupdocs_annotation_cloud_1.Rectangle();
a1.box.x = 375.89276123046875;
a1.box.y = 59.388263702392578;
a1.box.width = 88.7330551147461;
a1.box.height = 37.7290153503418;
a1.pageNumber = 2;
a1.fontColor = 65535;
a1.fontSize = 12;
a1.type = groupdocs_annotation_cloud_1.AnnotationInfo.TypeEnum.TextRedaction;
a1.text = "This is text redaction annotation";
a1.creatorName = "Anonym A.";
var request = new groupdocs_annotation_cloud_1.PostAnnotationsRequest("Annotationdocs\\ten-pages.pdf", [a1]);
annotateApi.postAnnotations(request)
.then(function (response) {
console.log("Expected response type is void: Text Redaction Annotation added.");
})
.catch(function (error) {
console.log("Error: " + error.message);
});
}
}
module.exports = Annotation_Node_Add_TextRedaction_Annotation;
"use strict";
class Annotation_Node_Add_TextReplacement_Annotation {
static Run() {
let a1 = new groupdocs_annotation_cloud_1.AnnotationInfo();
a1.annotationPosition = new groupdocs_annotation_cloud_1.Point();
a1.annotationPosition.x = 852;
a1.annotationPosition.y = 59.388262910798119;
a1.box = new groupdocs_annotation_cloud_1.Rectangle();
a1.box.x = 375.89276123046875;
a1.box.y = 59.388263702392578;
a1.box.width = 88.7330551147461;
a1.box.height = 37.7290153503418;
a1.pageNumber = 2;
a1.fontColor = 65535;
a1.fontSize = 12;
a1.type = groupdocs_annotation_cloud_1.AnnotationInfo.TypeEnum.TextReplacement;
a1.text = "This is text replacement annotation";
a1.fieldText = "Text to replace";
a1.creatorName = "Anonym A.";
var request = new groupdocs_annotation_cloud_1.PostAnnotationsRequest("Annotationdocs\\ten-pages.pdf", [a1]);
annotateApi.postAnnotations(request)
.then(function (response) {
console.log("Expected response type is void: Text Replacement Annotation added.");
})
.catch(function (error) {
console.log("Error: " + error.message);
});
}
}
module.exports = Annotation_Node_Add_TextField_Annotation;
"use strict";
class Annotation_Node_Add_TextStrikeout_Annotation {
static Run() {
let a1 = new groupdocs_annotation_cloud_1.AnnotationInfo();
a1.annotationPosition = new groupdocs_annotation_cloud_1.Point();
a1.annotationPosition.x = 852;
a1.annotationPosition.y = 59.388262910798119;
a1.box = new groupdocs_annotation_cloud_1.Rectangle();
a1.box.x = 375.89276123046875;
a1.box.y = 59.388263702392578;
a1.box.width = 88.7330551147461;
a1.box.height = 37.7290153503418;
a1.pageNumber = 2;
a1.fontColor = 65535;
a1.fontSize = 12;
a1.type = groupdocs_annotation_cloud_1.AnnotationInfo.TypeEnum.Text;
a1.text = "This is text strikeout annotation";
a1.creatorName = "Anonym A.";
var request = new groupdocs_annotation_cloud_1.PostAnnotationsRequest("Annotationdocs\\ten-pages.pdf", [a1]);
annotateApi.postAnnotations(request)
.then(function (response) {
console.log("Expected response type is void: Text Strikeout Annotation added.");
})
.catch(function (error) {
console.log("Error: " + error.message);
});
}
}
module.exports = Annotation_Node_Add_TextStrikeout_Annotation;
"use strict";
class Annotation_Node_Add_TextUnderline_Annotation {
static Run() {
let a1 = new groupdocs_annotation_cloud_1.AnnotationInfo();
a1.annotationPosition = new groupdocs_annotation_cloud_1.Point();
a1.annotationPosition.x = 852;
a1.annotationPosition.y = 59.388262910798119;
a1.pageNumber = 2;
a1.fontColor = 65535;
a1.type = groupdocs_annotation_cloud_1.AnnotationInfo.TypeEnum.TextUnderline;
a1.text = "This is text underline annotation";
a1.creatorName = "Anonym A.";
var request = new groupdocs_annotation_cloud_1.PostAnnotationsRequest("Annotationdocs\\ten-pages.pdf", [a1]);
annotateApi.postAnnotations(request)
.then(function (response) {
console.log("Expected response type is void: Text Underline Annotation added.");
})
.catch(function (error) {
console.log("Error: " + error.message);
});
}
}
module.exports = Annotation_Node_Add_TextUnderline_Annotation;
"use strict";
class Annotation_Node_Add_Watermark_Annotation {
static Run() {
let a1 = new groupdocs_annotation_cloud_1.AnnotationInfo();
a1.annotationPosition = new groupdocs_annotation_cloud_1.Point();
a1.annotationPosition.x = 852;
a1.annotationPosition.y = 59.388262910798119;
a1.box = new groupdocs_annotation_cloud_1.Rectangle();
a1.box.x = 375.89276123046875;
a1.box.y = 59.388263702392578;
a1.box.width = 88.7330551147461;
a1.box.height = 37.7290153503418;
a1.pageNumber = 2;
a1.penColor = 1201033;
a1.penStyle = 0;
a1.penWidth = 1;
a1.type = groupdocs_annotation_cloud_1.AnnotationInfo.TypeEnum.Watermark;
a1.text = "This is watermark annotation";
a1.angle = 75;
a1.creatorName = "Anonym A.";
var request = new groupdocs_annotation_cloud_1.PostAnnotationsRequest("Annotationdocs\\ten-pages.pdf", [a1]);
annotateApi.postAnnotations(request)
.then(function (response) {
console.log("Expected response type is void: Watermark Annotation added.");
})
.catch(function (error) {
console.log("Error: " + error.message);
});
}
}
module.exports = Annotation_Node_Add_Watermark_Annotation;
"use strict";
class Annotation_Node_Copy_File {
static Run() {
var request = new groupdocs_annotation_cloud_1.CopyFileRequest("Annotationdocs/one-page1.docx", "Annotationdocs/one-page-copied.docx", myStorage, myStorage);
fileApi.copyFile(request)
.then(function (response) {
console.log("Expected response type is Void: 'Annotationdocs/one-page1.docx' file copied as 'Annotationdocs/one-page-copied.docx'.");
})
.catch(function (error) {
console.log("Error: " + error.message);
});
}
}
module.exports = Annotation_Node_Copy_File;
"use strict";
class Annotation_Node_Copy_Folder {
static Run() {
// retrieve supported file-formats
var request = new groupdocs_annotation_cloud_1.CopyFolderRequest("annotations", "annotations1", myStorage, myStorage);
folderApi.copyFolder(request)
.then(function () {
console.log("Expected response type is Void: 'Annotationdocs' folder copied as 'Annotationdocs1'.");
})
.catch(function (error) {
console.log("Error: " + error.message);
});
}
}
module.exports = Annotation_Node_Copy_Folder;
"use strict";
class Annotation_Node_Create_Folder {
static Run() {
// retrieve supported file-formats
var request = new groupdocs_annotation_cloud_1.CreateFolderRequest("annotations", myStorage);
folderApi.createFolder(request)
.then(function () {
console.log("Expected response type is Void: 'Annotationdocs' folder created.");
})
.catch(function (error) {
console.log("Error: " + error.message);
});
}
}
module.exports = Annotation_Node_Create_Folder;
"use strict";
class Annotation_Node_Delete_Annotation {
static Run() {
var request = new groupdocs_annotation_cloud_1.DeleteAnnotationsRequest("Annotationdocs\\ten-pages.docx");
annotateApi.deleteAnnotations(request)
.then(function (response) {
console.log("Expected response type is Void: Annotation deleted from document.");
})
.catch(function (error) {
console.log("Error: " + error.message);
});
}
}
module.exports = Annotation_Node_Delete_Annotation;
"use strict";
class Annotation_Node_Delete_File {
static Run() {
var request = new groupdocs_annotation_cloud_1.DeleteFileRequest("annotations1/one-page1.docx", myStorage);
fileApi.deleteFile(request)
.then(function (response) {
console.log("Expected response type is Void: 'Annotationdocs1/one-page1.docx' deleted.");
})
.catch(function (error) {
console.log("Error: " + error.message);
});
}
}
module.exports = Annotation_Node_Delete_File;
"use strict";
class Annotation_Node_Delete_Folder {
static Run() {
// retrieve supported file-formats
var request = new groupdocs_annotation_cloud_1.DeleteFolderRequest("Annotationdocs/annotations1", myStorage, true);
folderApi.deleteFolder(request)
.then(function () {
console.log("Expected response type is Void: 'Annotationdocs/annotations1' folder deleted recursively.");
})
.catch(function (error) {
console.log("Error: " + error.message);
});
}
}
module.exports = Annotation_Node_Delete_Folder;
"use strict";
class Annotation_Node_Delete_Pages {
static Run() {
var request = new groupdocs_annotation_cloud_1.DeletePagesRequest("Annotationdocs\\ten-pages.docx");
previewApi.deletePages(request)
.then(function (response) {
console.log("Expected response type is Void: pages deleted.");
})
.catch(function (error) {
console.log("Error: " + error.message);
});
}
}
module.exports = Annotation_Node_Delete_Pages;
"use strict";
class Annotation_Node_Download_File {
static Run() {
var request = new groupdocs_annotation_cloud_1.DownloadFileRequest("Annotationdocs/one-page.docx", myStorage);
fileApi.downloadFile(request)
.then(function (response) {
console.log("Expected response type is Stream: " + response.length);
})
.catch(function (error) {
console.log("Error: " + error.message);
});
}
}
module.exports = Annotation_Node_Download_File;
"use strict";
class Annotation_Node_Get_All_Supported_Formats {
static Run() {
// retrieve supported file-formats
infoApi.getSupportedFileFormats()
.then(function (response) {
console.log("Supported file-formats:");
response.formats.forEach(function (format) {
console.log(format.fileFormat + "(" + format.extension + ")" + "\n");
});
})
.catch(function (error) {
console.log("Error: " + error.message);
});
}
}
module.exports = Annotation_Node_Get_All_Supported_Formats;
"use strict";
class Annotation_Node_Get_Annotation {
static Run() {
var request = new groupdocs_annotation_cloud_1.GetExportRequest("Annotationdocs\\one-page-annotated.docx", undefined, undefined, undefined, undefined, undefined);
annotateApi.getExport(request)
.then(function (response) {
console.log("Expected response type is File: " + response.length);
})
.catch(function (error) {
console.log("Error: " + error.message);
});
}
}
module.exports = Annotation_Node_Get_Annotation;
"use strict";
class Annotation_Node_Get_Disc_Usage {
static Run() {
// retrieve supported file-formats
var request = new groupdocs_annotation_cloud_1.GetDiscUsageRequest(myStorage);
storageApi.getDiscUsage(request)
.then(function (response) {
console.log("Expected response type is DiscUsage: " + response.usedSize);
})
.catch(function (error) {
console.log("Error: " + error.message);
});
}
}
module.exports = Annotation_Node_Get_Disc_Usage;
"use strict";
class Annotation_Node_Get_Document_Information {
static Run() {
var request = new groupdocs_annotation_cloud_1.GetInfoRequest("Annotationdocs\\one-page.docx", "");
infoApi.getInfo(request)
.then(function (response) {
console.log("Expected response type is DocumentInfo: " + response.getPath());
})
.catch(function (error) {
console.log("Error: " + error.message);
});
}
}
module.exports = Annotation_Node_Get_Document_Information;
"use strict";
class Annotation_Node_Get_Export_Document {
static Run() {
var request = new groupdocs_annotation_cloud_1.GetExportRequest("Annotationdocs\\one-page-annotated.pdf", undefined, undefined, undefined, undefined, undefined);
annotateApi.getExport(request)
.then(function (response) {
console.log("Expected response type is File: " + response.length);
})
.catch(function (error) {
console.log("Error: " + error.message);
});
}
}
module.exports = Annotation_Node_Get_Export_Document;
"use strict";
class Annotation_Node_Get_File_Versions {
static Run() {
// retrieve supported file-formats
var request = new groupdocs_annotation_cloud_1.GetFileVersionsRequest("Annotationdocs/one-page.docx", myStorage);
storageApi.getFileVersions(request)
.then(function (response) {
console.log("Expected response type is FileVersions: " + response.value.length);
})
.catch(function (error) {
console.log("Error: " + error.message);
});
}
}
module.exports = Annotation_Node_Get_File_Versions;
"use strict";
class Annotation_Node_Get_Files_List {
static Run() {
// retrieve supported file-formats
var request = new groupdocs_annotation_cloud_1.GetFilesListRequest("Annotationdocs/sample.docx", myStorage);
folderApi.getFilesList(request)
.then(function (response) {
console.log("Expected response type is FilesList: " + response.value.length);
})
.catch(function (error) {
console.log("Error: " + error.message);
});
}
}
module.exports = Annotation_Node_Get_Files_List;
"use strict";
class Annotation_Node_Get_Pages {
static Run() {
var request = new groupdocs_annotation_cloud_1.GetPagesRequest("Annotationdocs\\ten-pages.docx", 1, 1, 1, undefined, undefined, undefined, "");
previewApi.getPages(request)
.then(function (response) {
console.log("Expected response type is PageImages: " + response);
})
.catch(function (error) {
console.log("Error: " + error.message);
});
}
}
module.exports = Annotation_Node_Get_Pages;
"use strict";
class Annotation_Node_Get_PDF {
static Run() {
var request = new groupdocs_annotation_cloud_1.GetPdfRequest("Annotationdocs\\ten-pages.docx");
annotateApi.getPdf(request)
.then(function (response) {
console.log("Expected response type is File: " + response.length);
})
.catch(function (error) {
console.log("Error: " + error.message);
});
}
}
module.exports = Annotation_Node_Get_PDF;
"use strict";
class Annotation_Node_Move_File {
static Run() {
var request = new groupdocs_annotation_cloud_1.MoveFileRequest("Annotationdocs/one-page1.docx", "annotations1/one-page1.docx", myStorage, myStorage);
fileApi.moveFile(request)
.then(function (response) {
console.log("Expected response type is Void: 'Annotationdocs/one-page1.docx' file moved to 'Annotationdocs1/one-page1.docx'.");
})
.catch(function (error) {
console.log("Error: " + error.message);
});
}
}
module.exports = Annotation_Node_Move_File;
"use strict";
class Annotation_Node_Move_Folder {
static Run() {
// retrieve supported file-formats
var request = new groupdocs_annotation_cloud_1.MoveFolderRequest("annotations1", "Annotationdocs/annotations1", myStorage, myStorage);
folderApi.moveFolder(request)
.then(function () {
console.log("Expected response type is Void: 'Annotationdocs1' folder moved to 'Annotationdocs/annotations1'.");
})
.catch(function (error) {
console.log("Error: " + error.message);
});
}
}
module.exports = Annotation_Node_Move_Folder;
"use strict";
class Annotation_Node_Object_Exists {
static Run() {
// retrieve supported file-formats
var request = new groupdocs_annotation_cloud_1.ObjectExistsRequest("Annotationdocs/one-page.docx", myStorage);
storageApi.objectExists(request)
.then(function (response) {
console.log("Expected response type is ObjectExist: " + response.exists);
})
.catch(function (error) {
console.log("Error: " + error.message);
});
}
}
module.exports = Annotation_Node_Object_Exists;
"use strict";
global.groupdocs_annotation_cloud_1 = require("groupdocs-annotation-cloud");
global.fs = require("fs");
global.serializer_1 = require("groupdocs-annotation-cloud/lib/serializer");
//// ***********************************************************
//// GroupDocs.Annotation Cloud API Examples
//// ***********************************************************
//TODO: Get your AppSID and AppKey at https://dashboard.groupdocs.cloud (free registration is required).
global.appSid = "XXXXX-XXXXX-XXXXX-XXXXX-XXXXX";
global.appKey = "XXXXXXXXXXXXXXX";
global.myStorage = "XXXXX";
// construct AnnotateApi
global.annotateApi = groupdocs_annotation_cloud_1.AnnotateApi.fromKeys(appSid, appKey);
// construct PreviewApi
global.previewApi = groupdocs_annotation_cloud_1.PreviewApi.fromKeys(appSid, appKey);
// construct InfoApi
global.infoApi = groupdocs_annotation_cloud_1.InfoApi.fromKeys(appSid, appKey);
// construct StorageApi
global.storageApi = groupdocs_annotation_cloud_1.StorageApi.fromKeys(appSid, appKey);
// construct FolderApi
global.folderApi = groupdocs_annotation_cloud_1.FolderApi.fromKeys(appSid, appKey);
// construct FileApi
global.fileApi = groupdocs_annotation_cloud_1.FileApi.fromKeys(appSid, appKey);
//// Uploading sample test files from local to storage under folder 'Annotationdocs'
//console.log("Executing Upload Test Files...");
//require('./Common_Utilities/Utils').Upload_Test_File();
// ******* Execute Examples *******
console.log("*** Executing examples...");
// ******* Execute Examples *******
//// ***********************************************************
//// ***** WORKING WITH STORAGE *****
//// ***********************************************************
// Is Storage Exist
//require('./Working_With_Storage/Annotation_Node_Storage_Exist').Run();
// Get Get Disc Usage
//require('./Working_With_Storage/Annotation_Node_Get_Disc_Usage').Run();
// Get File Versions
//require('./Working_With_Storage/Annotation_Node_Get_File_Versions').Run();
// Is Object Exists
//require('./Working_With_Storage/Annotation_Node_Object_Exists').Run();
//// ***********************************************************
//// ***** WORKING WITH FOLDER *****
//// ***********************************************************
// Create Folder
//require('./Working_With_Folder/Annotation_Node_Create_Folder').Run();
// Copy Folder
//require('./Working_With_Folder/Annotation_Node_Copy_Folder').Run();
// Move Folder
//require('./Working_With_Folder/Annotation_Node_Move_Folder').Run();
// Delete Folder
//require('./Working_With_Folder/Annotation_Node_Delete_Folder').Run();
// Get Files List
//require('./Working_With_Folder/Annotation_Node_Get_Files_List').Run();
//// ***********************************************************
//// ***** WORKING WITH FILES *****
//// ***********************************************************
// Upload File
//require('./Working_With_Files/Annotation_Node_Upload_File').Run();
// Copy File
//require('./Working_With_Files/Annotation_Node_Copy_File').Run();
// Move File
//require('./Working_With_Files/Annotation_Node_Move_File').Run();
// Delete File
//require('./Working_With_Files/Annotation_Node_Delete_File').Run();
// Download_File
//require('./Working_With_Files/Annotation_Node_Download_File').Run();
//// ***********************************************************
//// ***** WORKING WITH SUPPORTED FORMATS *****
//// ***********************************************************
// Get All Supported Formats
require('./Supported_File_Formats/Annotation_Node_Get_All_Supported_Formats').Run();
//// ***********************************************************
//// ***** WORKING WITH DOCUMENT INFORMATION *****
//// ***********************************************************
// Get document information/metadata.
//require('./Document_Information/Annotation_Node_Get_Document_Information').Run();
//// ***********************************************************
//// ***** WORKING WITH ANNOTATIONS *****
//// ***********************************************************
// Post/Add multiple annotations
//require('./Working_With_Annotations/Annotation_Node_Add_Multiple_Annotations').Run();
// Post/Add Area annotations
//require('./Working_With_Annotations/Annotation_Node_Add_Area_Annotation').Run();
// Post/Add Distance annotations
//require('./Working_With_Annotations/Annotation_Node_Add_Distance_Annotation').Run();
// Post/Add Polyline annotations
//require('./Working_With_Annotations/Annotation_Node_Add_Polyline_Annotation').Run();
// Post/Add Watermark annotations
//require('./Working_With_Annotations/Annotation_Node_Add_Watermark_Annotation').Run();
// Post/Add Point annotations
//require('./Working_With_Annotations/Annotation_Node_Add_Point_Annotation').Run();
// Post/Add Text annotations
//require('./Working_With_Annotations/Annotation_Node_Add_Text_Annotation').Run();
// Post/Add Text Field annotations
//require('./Working_With_Annotations/Annotation_Node_Add_TextField_Annotation').Run();
// Post/Add Text Redaction annotations
//require('./Working_With_Annotations/Annotation_Node_Add_TextRedaction_Annotation').Run();
// Post/Add Text Underline annotations
//require('./Working_With_Annotations/Annotation_Node_Add_TextUnderline_Annotation').Run();
// Post/Add Text Underline annotations
//require('./Working_With_Annotations/Annotation_Node_Add_TextUnderline_Annotation').Run();
// Post/Add Text Strikeout annotations
//require('./Working_With_Annotations/Annotation_Node_Add_TextStrikeout_Annotation').Run();
//Get annotations
//require('./Working_With_Annotations/Annotation_Node_Get_Annotation').Run();
//Export annotation with document
//require('./Working_With_Annotations/Annotation_Node_Get_Export_Document').Run();
//Get annotations file with PDF
//require('./Working_With_Annotations/Annotation_Node_Get_PDF').Run();
//Delete annotations
//require('./Working_With_Annotations/Annotation_Node_Delete_Annotation').Run();
//// ***********************************************************
//// ***** WORKING WITH PAGES *****
//// ***********************************************************
//Get pages
//require('./Working_With_Pages/Annotation_Node_Get_Pages').Run();
//Delete pages
//require('./Working_With_Pages/Annotation_Node_Delete_Pages').Run();
"use strict";
class Annotation_Node_Storage_Exist {
static Run() {
// retrieve supported file-formats
var request = new groupdocs_annotation_cloud_1.StorageExistsRequest(myStorage);
storageApi.storageExists(request)
.then(function (response) {
console.log("Expected response type is StorageExist: " + response.exists);
})
.catch(function (error) {
console.log("Error: " + error.message);
});
}
}
module.exports = Annotation_Node_Storage_Exist;
"use strict";
class Annotation_Node_Upload_File {
static Run() {
// Open file in IOStream from local/disc.
var resourcesFolder = './Resources/Annotationdocs/one-page.docx';
fs.readFile(resourcesFolder, (err, fileStream) => {
var request = new groupdocs_annotation_cloud_1.UploadFileRequest("Annotationdocs/one-page1.docx", fileStream, myStorage);
fileApi.uploadFile(request)
.then(function (response) {
console.log("Expected response type is FilesUploadResult: " + response.uploaded.length);
})
.catch(function (error) {
console.log("Error: " + error.message);
});
});
}
}
module.exports = Annotation_Node_Upload_File;
"use strict";
class Utils {
static Upload_Test_File() {
var resourcesFolder = './Resources/Annotationdocs/';
fs.readdir(resourcesFolder, (err, files) => {
console.log("Total files in 'Annotationdocs' folder: " + files.length);
files.forEach(file => {
var srcFilePath = "Annotationdocs/" + file;
var existsRequest = new groupdocs_annotation_cloud_1.ObjectExistsRequest(srcFilePath, myStorage);
//console.log("srcFilePath: " + srcFilePath);
storageApi.objectExists(existsRequest)
.then(function (existResponse) {
//console.log("existResponse.exists: " + existResponse.exists);
if (existResponse.exists === false) {
var uploadRequest = new groupdocs_annotation_cloud_1.UploadFileRequest(srcFilePath, file);
fileApi.uploadFile(uploadRequest).then(function (createResponse) {
console.log("Uploaded: " + srcFilePath);
}).catch(function (error) {
console.log("File already exists: " + file);
console.log("Error: " + error.message);
});
}
})
.catch(function (error) {
console.log("Error: " + error.message);
});
});
});
}
}
module.exports = Utils;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment