使用 Node.js API 從 PowerPoint 簡報中提取文本 - PowerPoint 文本提取器

如果您需要從 Microsoft PowerPoint 簡報中提取文本以進行自動化、存檔或搜索索引,GroupDocs.Parser Cloud SDK for Node.js 提供了一種快速、靈活且易於集成的雲端解決方案。只需幾行代碼,您就可以從 .ppt.pptx 文件中提取純文本或結構化文本,而無需依賴 Microsoft Office。

PowerPoint 文字萃取 API

The GroupDocs.Parser Cloud SDK for Node.js 是一個建立在強大 REST API 之上的高階 SDK,允許您提取:

  • Slide text (per slide or entire presentation).
  • 結構化的表格內容。
  • Metadata.
  • 嵌入的文件或圖片。

它支持多種格式,包括 PDFWordExcelPowerPointMSGZIP 等等。

先決條件

  1. GroupDocs.Cloud Dashboard 註冊。
  2. 獲取您的客戶端 ID 和客戶端密鑰。
  3. 安裝 SDK:
npm install groupdocs-parser-cloud

Visit the following link to learn more about, 如何獲取您的客戶端 ID 和客戶端密鑰以進行身份驗證 .

如何使用 Node.js 從 PowerPoint 中提取文本

此部分提供有關如何使用 Node.js SDK 以程式方式從 PowerPoint 簡報中提取文本的詳細資訊。

步驟 1:初始化配置:

const { ParserApi, Configuration, ImagesRequest, FileInfo, ImagesOptions } = require("groupdocs-parser-cloud");

const config = new Configuration("YOUR_CLIENT_ID", "YOUR_CLIENT_SECRET");
const parserApi = new ParserApi(config);

步驟 2:設置文件信息和選項: 初始化 TextRequest 類的物件,並傳遞 TextOptions 類的實例。

const fileInfo = new FileInfo();
// path to PowerPoint presentation
fileInfo.filePath = "input.pptx";

const options = new TextOptions();
options.fileInfo = fileInfo;

const request = new TextRequest(options);

步驟 3:從 PowerPoint 中提取文本: Invoke the text method, and it will return the plain text from PowerPoint presentation.

parserApi.text(request).then(response => {
    console.log("Extracted text content:");
    console.log(response.text);
}).catch(err => {
    console.error("Error extracting text:", err);
});
// 對於更多範例,請訪問 https://github.com/groupdocs-parser-cloud/groupdocs-parser-cloud-node
const { Configuration, ParserApi, TextOptions, TextRequest, FileInfo } = require("groupdocs-parser-cloud");

const config = new Configuration("YOUR_CLIENT_ID", "YOUR_CLIENT_SECRET");
const parserApi = new ParserApi(config);

const fileInfo = new FileInfo();
// Input PowerPoint path
fileInfo.filePath = "input.pptx";

// 指定 TextOptions 物件
const options = new TextOptions();
options.fileInfo = fileInfo;

const request = new TextRequest(options);

parserApi.text(request).then(response => {
    console.log("Extracted text content:");
    console.log(response.text);
}).catch(err => {
    console.error("Error extracting text:", err);
});

您可以在下方的圖片中看到上述代碼範例的輸出:

提取 PowerPoint 簡報文字

從 PowerPoint 透過 cURL 擷取文字

如果您較喜歡命令行操作或想要集成到腳本中?您可以使用 cURL 和 GroupDocs.Parser REST API 從 Word 文檔中提取文本。

步驟 1 – 生成存取令牌:

curl -X POST "https://api.groupdocs.cloud/connect/token" \
-d "grant_type=client_credentials&client_id=YOUR_CLIENT_ID&client_secret=YOUR_CLIENT_SECRET" \
-H "Content-Type: application/x-www-form-urlencoded"

步驟 2 – 通過 API 調用提取文本:

curl -v -X POST "https://api.groupdocs.cloud/v1.0/parser/text" \
-H  "accept: application/json" \
-H  "authorization: Bearer {ACCESS_TOKEN}" \
-H  "Content-Type: application/json" \
-d 
    "{  
        \"FileInfo\": 
        {
            \"FilePath\": \"input.pptx\",
            \"StorageName\": \"internal\"
        }
    }"
  • 用您生成的取代 。

使用 cURL 與 GroupDocs.Parser API 的好處

  • ✅ 無需安裝 SDK。
  • ✅ 適用於 bash 腳本或 cron 工作。
  • ✅ 在 Linux、macOS 和 Windows 環境中運行。
  • ✅ 輕量且快速。

Free PowerPoint Text Extractor

使用我們的 Free Online PowerPoint Text Extractor,這是由 GroupDocs.Parser Cloud 提供支持的無代碼選項。

線上 PowerPoint 文字提取器

結論

使用 GroupDocs.Parser Cloud SDK for Node.js,您可以以最少的代碼有效地從 PowerPoint 演示文稿中提取文本。該 SDK 和 REST API 支持現代開發工作流程——無論您更喜歡程式化的 SDK 還是輕量級的 cURL 腳本。

📚 其他資源

常見問題 – FAQs

  1. Can I extract text from slides with formatting?
  • 是的。API 返回包含幻燈片順序的結構化文本。
  1. 是否需要 PowerPoint 來提取內容?
  • 不。該 API 在雲端運行,並不依賴於 Microsoft Office。
  1. 定價模型是什麼?
  • 我們提供單一的隨用隨付定價模式。如需更多信息,請訪問 pricing guide
  1. 是否有免費試用?
  • 是的。使用免費試用帳戶,您每月可以進行最多 150 次 API 呼叫。如需更多詳情,請訪問 pricing guide

推薦文章