JavaでPPT形式を解析する
MicrosoftやAdobePDFなどのソフトウェアを使用せずに、サーバー側のAspose.Slides forJavaAPIを使用したネイティブで高性能なPPTドキュメントの解析。
Javaを使用してPPTファイルを解析する方法
PPTファイルを解析するために、 [Aspose.Slides for Java](https://products.aspose.com/slides/ja/java) 機能豊富で強力で使いやすいJavaプラットフォーム用の解析APIであるAPI。最新バージョンはから直接ダウンロードできます [Maven](https://repository.aspose.com/webapp/#/artifacts/browse/tree/General/repo/com/aspose/aspose-slides) 次の構成をpom.xmlに追加して、Mavenベースのプロジェクトにインストールします。
リポジトリ
<repository>
<id>AsposeJavaAPI</id>
<name>Aspose Java API</name>
<url>https://releases.aspose.com/java/repo/</url>
</repository>
依存
<dependency>
<groupId>com.aspose</groupId>
<artifactId>aspose-slides</artifactId>
<version>version of aspose-slides API</version>
<classifier>jdk17</classifier>
</dependency>
JavaでPPTファイルを解析する手順
[Aspose.Slides for Java](https://products.aspose.com/slides/ja/java)APIを使用した基本的なドキュメントの解析は、わずか数行のコードで実行できます。
Presentationクラスを開始してPPTファイルをロードします。
最初のスライドテキストフレームを取得します。
各段落部分をループします。
テキスト、フォントなどの必要な出力を取得します。
システム要求
Aspose.Slides for Javaは、すべての主要なプラットフォームとオペレーティングシステムでサポートされています。次の前提条件があることを確認してください。
-MicrosoftWindowsまたはJSP/JSFアプリケーションおよびデスクトップアプリケーション用のJavaランタイム環境と互換性のあるOS。 -最新バージョンのAspose.SlidesforJavaを直接入手する [Maven](https://repository.aspose.com/webapp/#/artifacts/browse/tree/General/repo/com/aspose/aspose-slides)。
PPTファイルの解析-Java
//Load PPT file
Presentation pptPresentation = new Presentation("demo.ppt");
try{
//Get an Array of TextFrameEx objects from the first slide
ITextFrame[] textFramesSlideOne = SlideUtil.getAllTextBoxes(pptPresentation.getSlides().get_Item(0));
//Loop through the Array of TextFrames
for (int i = 0; i < textFramesSlideOne.length; i++){
//Loop through paragraphs in current TextFrame
for (IParagraph para : textFramesSlideOne[0].getParagraphs()){
//Loop through portions in the current Paragraph
for (IPortion port : para.getPortions()){
//Display text in the current portion
System.out.print(port.getText());
//Display font height of the text
System.out.print(port.getPortionFormat().getFontHeight());
//Display font name of the text
System.out.print(port.getPortionFormat().getLatinFont().getFontName());
}
}
}
} finally {
if (pptPresentation != null) pptPresentation.dispose();
}
//Similarly extarcting text from the Whole Presentation
//Use getAllTextFrames(pptPresentation, true) method and Iterate through Array
Aspose.Slides forJavaAPIについて
Aspose.Slides APIを使用して、Microsoft PowerPointドキュメントの読み取り、書き込み、操作、およびPDF、XPS、HTML、TIFF、ODP、その他のさまざまな形式への変換を行うことができます。新しいファイルを最初から作成し、サポートされている関連する形式で保存できます。 Aspose.Slidesは、プレゼンテーション、スライド、要素を作成、解析、または操作するためのスタンドアロンAPIであり、MicrosoftやOpenOfficeなどのソフトウェアに依存しません。Online PPT Parser Live Demos
Extract text and images from PPT documents right now by visiting our Live Demos website . The live demo has the following benefits
PPT PPT ファイル形式とは
A file with PPT extension represents PowerPoint file that consists of a collection of slides for displaying as SlideShow. It specifies the Binary File Format used by Microsoft PowerPoint 97-2003. A PPT file can contain several different types of information such as text, bulleted points, images, multimedia and other embedded OLE objects. Microsoft came up with newer file format for PowerPoint, known as PPTX, from 2007 onwards that is based on Office OpenXML and is different from this binary file format. Several other application programs such as OpenOffice Impress and Apple Keynote can also create PPT files.
続きを読む