PNG JPG BMP TIFF PPTX
Aspose.Slides  for .NET

在 C# 中解析 PPTX 格式

使用用於 .NET API 的服務器端 Aspose.Slides 進行本機和高性能 PPTX 文檔解析,無需使用 Microsoft 或 Adob​​e PDF 等任何軟件。

如何使用 C# 解析 PPTX 文件

為了解析 PPTX 文件,我們將使用

Aspose.Slides for .NET

API 是一個功能豐富、功能強大且易於使用的 C# 平台文檔操作 API。打開

NuGet

包管理器,搜索 Aspose.Slides 並安裝。您還可以從包管理器控制台使用以下命令。

命令


PM> Install-Package Aspose.Slides.NET

在 C# 中解析 PPTX 文件的步驟

使用 Aspose.Slides for .NET API 解析基本文檔只需幾行代碼即可完成。

  1. 加載 PPTX 文件。

  2. 獲取所有文本框架。

  3. 循環遍歷每個段落部分。

  4. 獲取所需的輸出,如文本、字體等。

系統要求

所有主要平台和操作系統都支持我們的 API。在執行以下代碼之前,請確保您的系統具有以下先決條件。

  • Microsoft Windows 或兼容 .NET Framework、.NET Core、Windows Azure、Mono 或 Xamarin 平台的操作系統
  • Microsoft Visual Studio 等開發環境
  • 項目中引用的 .NET DLL 的 Aspose.Slides - 使用上面的下載按鈕從 NuGet 安裝
 

解析 PPTX 文件 - C#

//Extract Text from the Whole pptx Presentation 
    Presentation pptxPresentation = new Presentation(dataDir + "demo.pptx");
    
    //Get an Array of ITextFrame objects from all slides in the PPTX
    ITextFrame[] textFramesPPTX = Aspose.Slides.Util.SlideUtil.GetAllTextFrames(pptxPresentation, true);
    
    //Loop through the Array of TextFrames
     for (int i = 0; i < textFramesPPTX.Length; i++)
    
        //Loop through paragraphs in current ITextFrame
        foreach (IParagraph para in textFramesPPTX[i].Paragraphs)
    
             //Loop through portions in the current IParagraph
             foreach (IPortion port in para.Portions)
             {
                //Display text in the current portion
                Console.WriteLine(port.Text);
    
                //Display font height of the text
                Console.WriteLine(port.PortionFormat.FontHeight);
    
                //Display font name of the text
                if (port.PortionFormat.LatinFont != null)
                   Console.WriteLine(port.PortionFormat.LatinFont.FontName);
            }  

    
 
  • 關於 Aspose.Slides for .NET API

    Aspose.Slides API 可用於讀取、寫入、操作 Microsoft PowerPoint 文檔並將其轉換為 PDF、XPS、HTML、TIFF、ODP 和各種其他格式。可以從頭開始創建新文件並將其保存為相關支持的格式。 Aspose.Slides 是一個獨立的 API,用於創建、解析或操作演示文稿、幻燈片和元素,它不依賴於 Microsoft 或 OpenOffice 等任何軟件。

    Online PPTX Parser Live Demos

    Extract text and images from PPTX documents right now by visiting our Live Demos website . The live demo has the following benefits

      No need to download Aspose API.
      No need to write any code.
      Just upload your PPTX files.
      It will be parsed instantly.

    PPTX 什麼是 PPTX 文件格式

    Files with PPTX extension are presentation files created with popular Microsoft PowerPoint application. Unlike the previous version of presentation file format PPT which was binary, the PPTX format is based on the Microsoft PowerPoint open XML presentation file format. A presentation file is a collection of slides where each slide can comprise of text, images, formatting, animations, and other media. These slides are presented to audience in the form of slideshows with custom presentation settings.

    閱讀更多

    其他支持的解析格式

    使用 C#,可以輕鬆解析其他格式,包括。

    ODP (OpenDocument 演示格式)
    PPT (微軟PowerPoint 97-2003)