Просмотрите наши продукты

If so you can download any of the below versions for testing. The product will function as normal except for an evaluation limitation. At the time of purchase we provide a license file via email that will allow the product to work in its full capacity. If you would also like an evaluation license to test without any restrictions for 30 days, please follow the directions provided here.


Product Docs Swagger Examples Blog Support Dashboard

Установка

Пакет доступен на npmjs.com и может быть установлен через npm следующей командой:

npm install groupdocs-editor-cloud

NPM Version NPM Downloads NPM-GroupDocsCloud


Требования

  • Node.js 4.8 или новее
  • npm
  • Учетные данные GroupDocs Cloud — Client ID and Client Secret из панели управления

Зависимости

SDK требует следующие пакеты:

PackageConstraint
axios1.8.4
form-data*
jsonwebtoken9.0.1
qs6.11.2

Быстрый старт

Получите учетные данные API

Чтобы использовать GroupDocs.Editor Cloud, зарегистрируйтесь на GroupDocs.Cloud Dashboard и получите Client ID и Client Secret.

Инициализируйте API

Используйте следующий код, чтобы начать использовать GroupDocs.Editor Cloud SDK for Node.js.

"use strict";
const editor_cloud = require("groupdocs-editor-cloud");

const clientId = "YourClientId";
const clientSecret = "YourClientSecret";

const config = new editor_cloud.Configuration(clientId, clientSecret);
config.apiBaseUrl = "https://api.groupdocs.cloud";

const editApi = editor_cloud.EditApi.fromConfig(config);

Полный пример см. в RunExamples.js.

Редактировать текстовый документ

После инициализации используйте этот базовый пример, чтобы загрузить защищенный паролем документ Word, заменить текст в HTML и снова сохранить его как DOCX.

"use strict";
const editor_cloud = require("groupdocs-editor-cloud");

const clientId = "YourClientId";
const clientSecret = "YourClientSecret";

const config = new editor_cloud.Configuration(clientId, clientSecret);
config.apiBaseUrl = "https://api.groupdocs.cloud";

const editApi = editor_cloud.EditApi.fromConfig(config);
const fileApi = editor_cloud.FileApi.fromConfig(config);

(async () => {
    let fileInfo = new editor_cloud.FileInfo();
    fileInfo.filePath = "WordProcessing/password-protected.docx";
    fileInfo.password = "password";
    let loadOptions = new editor_cloud.WordProcessingLoadOptions();
    loadOptions.fileInfo = fileInfo;
    loadOptions.outputPath = "output";
    let loadResult = await editApi.load(new editor_cloud.LoadRequest(loadOptions));

    let buf = await fileApi.downloadFile(new editor_cloud.DownloadFileRequest(loadResult.htmlPath));
    let htmlString = buf.toString("utf-8");
    htmlString = htmlString.replace("Sample test text", "Hello world");
    await fileApi.uploadFile(new editor_cloud.UploadFileRequest(loadResult.htmlPath, new Buffer(htmlString, "utf-8")));

    let saveOptions = new editor_cloud.WordProcessingSaveOptions();
    saveOptions.fileInfo = fileInfo;
    saveOptions.outputPath = "output/edited.docx";
    saveOptions.htmlPath = loadResult.htmlPath;
    saveOptions.resourcesPath = loadResult.resourcesPath;
    let saveResult = await editApi.save(new editor_cloud.SaveRequest(saveOptions));
    console.log("Document edited: " + saveResult.path);
})();

Полный пример см. в EditWordProcessingDocument.js.

Редактировать электронную таблицу

Этот пример загружает первый лист, редактирует HTML и снова сохраняет его как XLSX.

"use strict";
const editor_cloud = require("groupdocs-editor-cloud");

const clientId = "YourClientId";
const clientSecret = "YourClientSecret";

const config = new editor_cloud.Configuration(clientId, clientSecret);
config.apiBaseUrl = "https://api.groupdocs.cloud";

const editApi = editor_cloud.EditApi.fromConfig(config);
const fileApi = editor_cloud.FileApi.fromConfig(config);

(async () => {
    let fileInfo = new editor_cloud.FileInfo();
    fileInfo.filePath = "Spreadsheet/four-sheets.xlsx";
    let loadOptions = new editor_cloud.SpreadsheetLoadOptions();
    loadOptions.fileInfo = fileInfo;
    loadOptions.outputPath = "output";
    loadOptions.worksheetIndex = 0;
    let loadResult = await editApi.load(new editor_cloud.LoadRequest(loadOptions));

    let buf = await fileApi.downloadFile(new editor_cloud.DownloadFileRequest(loadResult.htmlPath));
    let htmlString = buf.toString("utf-8");
    htmlString = htmlString.replace("This is sample sheet", "This is sample sheep");
    await fileApi.uploadFile(new editor_cloud.UploadFileRequest(loadResult.htmlPath, new Buffer(htmlString, "utf-8")));

    let saveOptions = new editor_cloud.SpreadsheetSaveOptions();
    saveOptions.fileInfo = fileInfo;
    saveOptions.outputPath = "output/edited.xlsx";
    saveOptions.htmlPath = loadResult.htmlPath;
    saveOptions.resourcesPath = loadResult.resourcesPath;
    let saveResult = await editApi.save(new editor_cloud.SaveRequest(saveOptions));
    console.log("Document edited: " + saveResult.path);
})();

Полный пример см. в EditSpreadsheetDocument.js.

Получить сведения о документе

Этот пример возвращает число страниц документа Word, защищенного паролем.

"use strict";
const editor_cloud = require("groupdocs-editor-cloud");

const clientId = "YourClientId";
const clientSecret = "YourClientSecret";

const config = new editor_cloud.Configuration(clientId, clientSecret);
config.apiBaseUrl = "https://api.groupdocs.cloud";

const infoApi = editor_cloud.InfoApi.fromConfig(config);

(async () => {
    let fileInfo = new editor_cloud.FileInfo();
    fileInfo.filePath = "WordProcessing/password-protected.docx";
    fileInfo.password = "password";
    fileInfo.storageName = "First Storage";
    let request = new editor_cloud.GetInfoRequest(fileInfo);
    let response = await infoApi.getInfo(request);
    console.log("GetDocumentInfo: Page Count = " + response.pageCount);
})();

Полный пример см. в GetDocumentInfo.js.

Получить поддерживаемые форматы редактирования

Получите форматы документов, которые API может редактировать.

"use strict";
const editor_cloud = require("groupdocs-editor-cloud");

const clientId = "YourClientId";
const clientSecret = "YourClientSecret";

const config = new editor_cloud.Configuration(clientId, clientSecret);
config.apiBaseUrl = "https://api.groupdocs.cloud";

const infoApi = editor_cloud.InfoApi.fromConfig(config);

(async () => {
    let response = await infoApi.getSupportedFileFormats();
    console.log("Supported file-formats:");
    response.formats.forEach(function (format) {
        console.log(format.fileFormat + "(" + format.extension + ")");
    });
})();

Полный пример см. в GetSupportedFormats.js.

Примеры на GitHub

Репозиторий GroupDocs.Editor Cloud Node.js Examples содержит готовые к запуску примеры:

CategoryExamples
Edit OperationsОбработка текста, электронная таблица, презентация, текст и файлы с разделителями
InfoСведения о документе, расход лицензии, поддерживаемые типы файлов

Как запустить примеры

  1. Клонируйте или скачайте репозиторий примеров
  2. Отредактируйте Examples/RunExamples.js и задайте clientId и clientSecret
  3. Перейдите в каталог Examples
  4. Выполните npm install
  5. Выполните npm update
  6. Выполните npm run-script start

Подробности см. в разделе Getting Started.


Product Docs Swagger Examples Blog Support Dashboard


Tags

Document Editing API | Node.js Cloud API | GroupDocs.Editor Cloud | REST API | Word Processing Formats | Spreadsheet Formats | Presentation Formats | Text Formats | CSV Files | DOCX Documents | XLSX Documents | PPTX Presentations | Password-Protected Files | Cloud Storage Integration | Document Info Retrieval | File Operations | WYSIWYG Editing | Multi-Platform Support | Secure API Access | HTML Editing | Cross-platform API



 Русский