<dependency>
<groupId>com.groupdocs</groupId>
<artifactId>groupdocs-editor-cloud</artifactId>
<version>22.5</version>
</dependency>compile(group: 'com.groupdocs', name: 'groupdocs-editor-cloud', version: '22.5')<dependency org="com.groupdocs" name="groupdocs-editor-cloud" rev="22.5">
<artifact name="groupdocs-editor-cloud" ext="jar"/>
</dependency>libraryDependencies += "com.groupdocs" % "groupdocs-editor-cloud" % "22.5"文档编辑器 Java Cloud REST API
Product Page | Docs | Live Demos | Swagger UI | Code Samples | Blog | Free Support | Free Trial
GroupDocs.Editor Cloud SDK for Java 帮助您构建无需安装任何第 3 方软件即可运行的云文档编辑器 Java 应用程序。它是 GroupDocs.Editor Cloud REST APIs 的包装器。
要求
构建 API 客户端库需要:
- Java 1.7+
- 行家
先决条件
要使用 GroupDocs.Editor Cloud SDK for Java,您需要在 GroupDocs Cloud 注册一个帐户并在 Cloud Dashboard 查找/创建客户端 ID 和客户端密码。有可用的免费配额。有关详细信息,请参阅GroupDocs Cloud Pricing。
从 Maven 安装 GroupDocs.Editor-Cloud
将 GroupDocs 云存储库添加到您的应用程序 pom.xml
<repository>
<id>repository.groupdocs.cloud</id>
<name>repository.groupdocs.cloud</name>
<url>https://releases.groupdocs.cloud/java/repo/</url>
</repository>
从源安装
要将 API 客户端库安装到本地 Maven 存储库,只需执行:
mvn clean install
要将其部署到远程 Maven 存储库,请配置存储库的设置并执行:
mvn clean deploy
有关更多信息,请参阅 OSSRH Guide。
Maven 用户
将此依赖项添加到项目的 POM 中:
<dependency>
<groupId>com.groupdocs</groupId>
<artifactId>groupdocs-editor-cloud</artifactId>
<version>22.5</version>
<type>pom</type>
</dependency>
### 其他
首先通过执行生成JAR:
mvn clean package
然后手动安装以下 JAR:
-target/groupdocs-editor-cloud-22.5.jar
-target/lib/*.jar
开始
请按照 Quick Start 说明进行操作。
在云中编辑 DOCX 的示例 Java 代码
/ For complete examples and data files, please go to https://github.com/groupdocs-editor-cloud/groupdocs-editor-cloud-java-samples
String MyAppKey = ""; // Get AppKey and AppSID from https://dashboard.groupdocs.cloud
String MyAppSid = ""; // Get AppKey and AppSID from https://dashboard.groupdocs.cloud
Configuration configuration = new Configuration(MyAppSid, MyAppKey);
// Create necessary API instances
EditApi editApi = new EditApi(configuration);
FileApi fileApi = new FileApi(configuration);
// The document already uploaded into the storage.
// Load it into editable state
FileInfo fileInfo = new FileInfo();
fileInfo.setFilePath("WordProcessing/password-protected.docx");
fileInfo.setPassword("password");
WordProcessingLoadOptions loadOptions = new WordProcessingLoadOptions();
loadOptions.setFileInfo(fileInfo);
loadOptions.setOutputPath("output");
LoadResult loadResult = editApi.load(new LoadRequest(loadOptions));
// Download html document
File file = fileApi.downloadFile(new DownloadFileRequest(loadResult.getHtmlPath(), null, null));
// Edit something...
List<String> lines = Files.readAllLines(file.toPath());
List<String> newLines = new ArrayList<String>();
for (String line : lines) {
newLines.add(line.replaceAll("Sample test text", "Hello world"));
}
Files.write(file.toPath(), newLines);
// Upload html back to storage
fileApi.uploadFile(new UploadFileRequest(loadResult.getHtmlPath(), file, Common.MYStorage));
// Save html back to docx
WordProcessingSaveOptions saveOptions = new WordProcessingSaveOptions();
saveOptions.setFileInfo(fileInfo);
saveOptions.setOutputPath("output/edited.docx");
saveOptions.setHtmlPath(loadResult.getHtmlPath());
saveOptions.setResourcesPath(loadResult.getResourcesPath());
DocumentResult saveResult = editApi.save(new SaveRequest(saveOptions));
System.out.println("Document edited: " + saveResult.getPath());
授权与认证
Authentication schemes API定义如下:
###智威汤逊
- 类型:OAuth 2.0
- 流程:应用
- 授权网址:https://api.groupdocs.cloud/connect/token
- 令牌生命周期:1 天(默认)
Product Page | Docs | Live Demos | Swagger UI | Code Samples | Blog | Free Support | Free Trial
GroupDocs Java REST API Maven SDK Java SDK Cloud REST REST API Cloud API MIT JWT oauth GroupDocs.Total Cloud GroupDocs.Editor Cloud JAR document automation document automation cloud document DOC DOCX DOCM DOT DOTM DOTX FlatOPC RTF WordML TXT ODT OTT XLS XLT XLSX XLSM XLTX XLTM XLSB XLAM SpreadsheetML DIF DSV CSV TSV SXC ODS FODS PPT PPTX PPTM PPS PPSX PPSM POT POTX POTM ODP OTP HTML XML editor editing multi lingual font appearance XML document structure highlight formatting extraction extract extractor

