
Node.js で PowerPoint PPT または PPTX を複数のファイルに分割する
PowerPoint は、スライドショー プレゼンテーションを作成するために Microsoft PowerPoint で作成されたプレゼンテーション ファイルです。 PPT または PPTX スライドには、スライド、図形、画像、オーディオ、ビデオ、テキストなどのレコードと構造のコレクションが保存されます。さまざまなシナリオで、長い PowerPoint プレゼンテーションを複数のファイルに分割する必要がある場合があります。スライド範囲ごとに指定したり、すべての PowerPoint スライドを複数の PPT/PPTX ファイルに分割したりできます。大きな PowerPoint ファイルを手動で個別のファイルに分割すると、時間のかかる作業になります。したがって、この記事では、Node.js を使用して PowerPoint PPT または PPTX を個別のファイルに分割する方法について説明します。
この記事では、次の質問について説明します。
- PowerPoint スプリッター REST API および Node.js SDK
- Node.js を使用して PowerPoint スライドを個別のファイルに分割する
- Node.js を使用して PowerPoint PPTX を複数ページのファイルに分割する
- Node.js API を使用してオンラインで PPT スライドをページ範囲ごとに分割
PowerPoint Splitter REST API と Node.js SDK
PPT または PPTX ファイルを分割するには、GroupDocs.Merger Cloud の Node.js SDK API を使用します。 サポートされている文書形式、Word、Excel、PowerPoint、 Visio 図面、PDF、HTML など。
コンソールで次のコマンドを使用して、GroupDocs.Merger Cloud を Node.js アプリケーションにインストールできます。
npm install groupdocs-merger-cloud
上記の手順に従う前に、ダッシュボードからクライアント ID とシークレットを取得してください。 ID とシークレットを取得したら、以下に示すようにコードを追加します。
# http://api.groupdocs.cloud から Node.js SDK をノード アプリケーションにインポートします
global.groupdocs_merger_cloud = require("groupdocs-merger-cloud");
global.fs = require("fs");
// https://dashboard.groupdocs.cloud から clientId と clientSecret を取得します (無料の登録が必要です)。
global.clientId = "xxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx";
global.clientSecret = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx";
global.myStorage = "test-internal-storage";
const config = new groupdocs_merger_cloud.Configuration(clientId, clientSecret);
config.apiBaseUrl = "https://api.groupdocs.cloud";
Node.js を使用して PowerPoint スライドを個別のファイルに分割する
以下に説明する簡単な手順に従って、クラウド上でプログラムによって PPTX ファイルをオンラインで分割できます。
PowerPoint ファイルをアップロードする
まず、以下のコード例を使用して、PowerPoint ファイルをクラウドにアップロードします。
// システム ドライブから IOStream 内のファイルを開きます。
var resourcesFolder = 'H:\\groupdocs-cloud-data\\sample-file.pptx';
// ファイルを読み取る
fs.readFile(resourcesFolder, (err, fileStream) => {
// FileApi を構築する
var fileApi = groupdocs_conversion_cloud.FileApi.fromConfig(config);
// アップロードファイルリクエストの作成
var request = new groupdocs_conversion_cloud.UploadFileRequest("sample-file.pptx", fileStream, myStorage);
// ファイルをアップロードする
fileApi.uploadFile(request)
.then(function (response) {
console.log("Expected response type is FilesUploadResult: " + response.uploaded.length);
})
.catch(function (error) {
console.log("Error: " + error.message);
});
});
その結果、アップロードされた PowerPoint ファイルは、クラウド上のダッシュボードの ファイル セクション で利用できるようになります。
Node.js で PowerPoint PPTX ファイルをオンラインで分割する
以下の手順に従って、PowerPoint PPTX スライドを 1 ページで構成される個別のファイルにプログラム的に作成できます。
- まず、DocumentApiのインスタンスを作成します。
- 次に、FileInfo のインスタンスを作成します。
- 次に、入力 PPTX ファイルへのパスを設定します。
- SplitOptions のインスタンスを作成します。
- 次に、FileInfo を分割オプションに割り当てます。
- PPTX を分割するには、コンマ区切りの配列で特定のページ番号を設定します。
- また、スライドと分割モードをページに設定します。これにより、API はカンマ区切りの配列で指定されたページ番号を別の PPTX ファイルとして分割できます。
- Split Options パラメータを使用して SplitRequest を作成する
- 最後に、SplitRequest で DocumentAPI.split() メソッドを呼び出し、結果を取得します。
次のコード スニペットは、REST API を使用して Node.js で PowerPoint PPTX ファイルを分割する方法を示しています。
// Node.js を使用して PowerPoint スライドを個別のファイルに分割する方法
const split = async () => {
let documentApi = groupdocs_merger_cloud.DocumentApi.fromKeys(clientId, clientSecret);
let options = new groupdocs_merger_cloud.SplitOptions();
options.fileInfo = new groupdocs_merger_cloud.FileInfo();
options.fileInfo.filePath = "nodejs-testing/sample-file.pptx";
options.outputPath = "nodejs-testing/split-file.pptx";
options.pages = [1, 3];
options.mode = groupdocs_merger_cloud.SplitOptions.ModeEnum.Pages;
try {
// 分割ドキュメントの作成リクエスト
let splitRequest = new groupdocs_merger_cloud.SplitRequest(options)
let result = await documentApi.split(splitRequest);
}
catch (err) {
throw err;
}
}
split()
.then(() => {
console.log("Successfully split pptx file online: ");
})
.catch((err) => {
console.log("Error occurred while splitting the powerpoint file:", err);
})
分割ファイルをダウンロードする
上記のコードサンプルでは、分割したファイルをクラウド上に保存します。次のコード サンプルを使用してダウンロードできます。
// マージされたファイルをダウンロードするための FileApi を構築する
var fileApi = groupdocs_merger_cloud.FileApi.fromConfig(config);
// ダウンロードファイルリクエストの作成
let request = new groupdocs_merger_cloud.DownloadFileRequest("nodejs-testing/split-file.pptx", myStorage);
// ダウンロード ファイルと応答タイプ ストリーム
fileApi.downloadFile(request)
.then(function (response) {
// ファイルをシステムディレクトリに保存します
fs.writeFile("H:\\groupdocs-cloud-data\\split-file.pptx", response, "binary", function (err) { });
console.log("Expected response type is Stream: " + response.length);
})
.catch(function (error) {
console.log("Error: " + error.message);
});
Node.js を使用して PowerPoint PPTX を複数ページのファイルに分割する
以下の手順に従って、PowerPoint プレゼンテーションをプログラムで複数のファイルに分割できます。
- まず、DocumentApiのインスタンスを作成します。
- 次に、FileInfo クラスのインスタンスを作成します。
- 次に、入力 PowerPoint ファイルへのパスを設定します。
- SplitOptions のインスタンスを作成します。
- 次に、FileInfo を分割オプションに割り当てます。
- カンマ区切りの配列で分割するページ番号の間隔を設定します。
- また、スライドの分割モードを「間隔」に設定します。これにより、API はカンマ区切りの配列で指定されたページ間隔に基づいて PowerPoint スライドを分割できます。
- 次に、SplitOptions を使用して SplitRequest を作成します。
- 最後に、SplitRequest で DocumentAPI.split() メソッドを呼び出し、結果を取得します。
次のコード スニペットは、REST API を使用して Node.js で特定の PowerPoint スライドを個別のファイルに分割する方法を示しています。
// Node.js を使用して PowerPoint PPTX を複数ページのファイルに分割する方法
const splitspecific = async () => {
// APIの初期化
let documentApi = groupdocs_merger_cloud.DocumentApi.fromKeys(clientId, clientSecret);
// 入力ファイルのパスを指定します
let fileInfo = new groupdocs_merger_cloud.FileInfo();
fileInfo.filePath = "nodejs-testing/sample-file.pptx";
// 分割オプションを定義する
let options = new groupdocs_merger_cloud.SplitOptions();
options.fileInfo = fileInfo;
options.outputPath = "nodejs-testing/split-file.pptx";
options.pages = [3, 6, 8];
options.mode = groupdocs_merger_cloud.SplitOptions.ModeEnum.Intervals;
try {
// 分割リクエストを作成する
let splitRequest = new groupdocs_merger_cloud.SplitRequest(options);
// 分割文書
let result = await documentApi.split(splitRequest);
}
catch (err) {
throw err;
}
}
splitspecific()
.then(() => {
console.log("Successfully specific pages of PPT online: ");
})
.catch((err) => {
console.log("Error occurred while splitting PowerPoint slides:", err);
})
Node.js APIを使用してPPTスライドをオンラインでページ範囲ごとに分割する
このセクションでは、以下の手順を使用してプログラムでページ番号の範囲を指定することにより、PowerPoint ファイルからスライドを抽出できます。
- まず、DocumentApiのインスタンスを作成します。
- 次に、FileInfo のインスタンスを作成します。
- 次に、入力 PowerPoint ファイルへのパスを設定します。
- SplitOptions のインスタンスを作成します。
- 次に、FileInfo を分割オプションに割り当てます。
- 開始ページ番号と終了ページ番号を設定します。
- また、PowerPoint の分割モードを Pages に設定します。
- 分割オプションを使用して SplitRequest を作成します。
- 最後に、SplitRequest で DocumentAPI.split() メソッドを呼び出し、結果を取得します。
次のコード スニペットは、Node.js のスライド番号範囲を使用して、PPT オンラインで個別のファイルに分割する方法を示しています。
// Node.js APIを使用してPPTスライドをページ範囲ごとにオンラインで分割する方法
const splitpages = async () => {
// APIの初期化
let documentApi = groupdocs_merger_cloud.DocumentApi.fromKeys(clientId, clientSecret);
// 入力ファイルのパスを指定します
let fileInfo = new groupdocs_merger_cloud.FileInfo();
fileInfo.filePath = "nodejs-testing/sample-file.pptx";
// 分割オプションを定義する
let options = new groupdocs_merger_cloud.SplitOptions();
options.fileInfo = fileInfo;
options.outputPath = "nodejs-testing/split-file.pptx";
options.startPageNumber = 3;
options.endPageNumber = 7;
options.mode = groupdocs_merger_cloud.SplitOptions.ModeEnum.Pages;
try {
// 分割リクエストを作成する
let splitRequest = new groupdocs_merger_cloud.SplitRequest(options);
// 分割文書
let result = await documentApi.split(splitRequest);
}
catch (err) {
throw err;
}
}
splitpages()
.then(() => {
console.log("Successfully split specific pages of PowerPoint presentation: ");
})
.catch((err) => {
console.log("Error occurred while splitting PPTX file online:", err);
})
PPT スライドをオンラインで無料で分割
PPT ファイルをオンラインで無料で分割するにはどうすればよいですか?上記の API を使用して開発された次の 無料オンライン PowerPoint 分割ツール をお試しください。
結論
結論として、このブログ投稿では次のことを実証しました。
- Nodejs で PowerPoint PPTX または PPT プレゼンテーションを分割する方法;
- 分割されたスライドをプログラムでクラウドからアップロードおよびダウンロードします。
- Nodejs は、特定の PowerPoint PPT または PPTX スライドを複数のファイルに分割します。
- オンラインでPPTスライドをNodejsで別々のファイルに分割する方法;
さらに、Nodejs API を使用すると、サポートされているさまざまなファイル形式に対して、PowerPoint ページの並べ替えや置換、ページの向きの変更、ドキュメントのパスワードの管理などの操作を簡単に実行できます。さらに、GroupDocs.Merge Cloud API の詳細については、ドキュメント を参照してください。また、ブラウザを通じて直接 API を表示および操作できる API リファレンス セクション も提供しています。
詳細については、[はじめに] ページをご覧ください。](https://docs.groupdocs.cloud/merger/getting-started/)
さらに、Groupdocs.cloud は新しい主題で継続的に更新されます。そのため、常に最新の API 情報を入手してください。
質問する
PowerPoint PPT スプリッターに関する質問は、無料サポート フォーラム からオンラインで行うことができます。
よくある質問
Node.js で PowerPoint を複数のファイルに分割するにはどうすればよいですか?
このリンク に従って、node.js を便利に使用して PowerPoint スライドを個別のファイルに分割する方法のコード スニペットを学習してください。
REST API を使用して、Node.js で PowerPoint プレゼンテーションをオンラインで分割するにはどうすればよいですか?
ConvertApi, のインスタンスを作成し、変換設定の値を設定し、ConvertDocumentRequest で convertDocument メソッドを呼び出して PPTX を分割します。各スライドの PowerPoint を個別に保存します。
PowerPoint のスライドをオンラインで無料で分割するにはどうすればよいですか?
オンライン PPT スプリッター 無料を使用すると、PPT をオンラインで複数のファイルに迅速かつ簡単に分割できます。分割プロセスが完了すると、分割された PowerPoint スライドをダウンロードできます。
Windows で PowerPoint プレゼンテーションを 2 つの別々のプレゼンテーションに分割するにはどうすればよいですか?
Windows で PPT スプリッターをダウンロードするには、このリンク にアクセスしてください。この PPT 分割ツールは、ウィンドウ内でワンクリックで PPT プレゼンテーションを素早く分割するために使用されます。
関連項目
- Node.js で複数の PowerPoint プレゼンテーションを 1 つに結合する
- Node.js を使用して PDF ファイルをオンラインで 1 つに結合およびマージする
- Node.js を使用して Word ドキュメントを個別のファイルに分割する方法
- Node.js の Rest API を使用して PDF ファイルからページを抽出する方法
- Node.js の Rest API を使用して PDF ページを回転する方法
- Node.js を使用して Word DOC/DOCX Online からページを抽出する方法
- Python で SVG を高品質の PNG に変換する
- Python で CSV を JSON に変換し、JSON を CSV に変換する
- REST APIを使用してPythonでPDFをExcelに変換する方法