如果您想打开一个文本文件并以纯文本格式处理数据,您可以使用 Dart 语言和操作系统的最基本功能来完成。至于阅读以多种文件格式(DOCX、DOC、PDF、RTF、ODT、HTML 等)呈现的办公文档,这个任务更难解决,因为这些文档是由复杂的树状数据描述的DOM 模型中的结构。
我们的 Dart 库是一个基于云的解决方案,可让您以任何办公室和 Web 格式打开文档。这种分布式方法使您可以灵活地使用 Dart 语言进行软件开发,因为所有资源密集型文档处理都将在 Aspose 服务器上进行。您只需要获取私钥即可在 Dart 代码中访问 Cloud API。
您可以迭代文档元素,也可以在 DOM 树中搜索特定元素。我们提供了广泛的 Dart 函数,用于处理文档结构和文档节点中包含的数据。
以下 Dart 代码示例将帮助您快速了解如何加载文档并对其执行一些操作。
import 'package:aspose_words_cloud/aspose_words_cloud.dart';
final config = Configuration("####-####-####-####-####", "##################");
final wordsApi = WordsApi(config);
final fileName = 'Input.docx';
final requestFileContent = (await File(
await context.loadTextFile(fileName)).readAsBytes()).buffer.asByteData();
final uploadDocumentRequest = UploadFileRequest(requestFileContent, fileName);
await wordsApi.uploadFile(uploadDocumentRequest);
final requestParagraph = ParagraphInsert();
requestParagraph.text = 'Reading and writing to the file in the cloud occurs automatically.';
final insertParagraphRequest = InsertParagraphRequest(fileName, requestParagraph);
await wordsApi.insertParagraph(insertParagraphRequest);
final downloadDocumentRequest = DownloadFileRequest(fileName);
await wordsApi.downloadFile(downloadDocumentRequest);
从 GitHub 克隆 Aspose.Words Cloud SDK for Dart 源代码并在您的项目中使用它。将此依赖项添加到您的 pubspec.yaml: dependencies: aspose_words_cloud: 22.4.0
请按照这些 Instructions 快速获取必要的安全凭证并访问我们的 REST API。
请参阅 Repository Documentation 以查看详细信息。