製品を閲覧する

If so you can download any of the below versions for testing. The product will function as normal except for an evaluation limitation. At the time of purchase we provide a license file via email that will allow the product to work in its full capacity. If you would also like an evaluation license to test without any restrictions for 30 days, please follow the directions provided here.


Product Docs Swagger Examples Blog Support Dashboard

インストール

パッケージは、available Packagist にあり、Composer 経由で次のコマンドを実行してインストールできます。

composer require groupdocscloud/groupdocs-editor-cloud

Packagist Version Packagist Downloads PHP-GroupDocsCloud


要件

  • PHP 8.2 以降
  • Composer
  • PHP 拡張機能 — curl, json, mbstring
  • GroupDocs Cloud 認証情報 — Client ID and Client Secret ダッシュボードから

依存関係

SDK には次のパッケージが必要です。

PackageConstraint
guzzlehttp/guzzle^6.5.8 or ^7.4.5
ext-curl*
ext-json*
ext-mbstring*

クイックスタート

API 認証情報を取得する

GroupDocs.Editor Cloud を使用するには、GroupDocs.Cloud Dashboard でサインアップし、クライアント ID と クライアント シークレット を取得します。

API を初期化する

GroupDocs.Editor Cloud SDK for PHP の使用を開始するには、次のコードを使用します。

<?php

require_once(__DIR__ . '/vendor/autoload.php');

// Get your ClientId and ClientSecret at https://dashboard.groupdocs.cloud
$configuration = new GroupDocs\Editor\Configuration();
$configuration->setAppSid("YourClientId");
$configuration->setAppKey("YourClientSecret");
$configuration->setApiBaseUrl("https://api.groupdocs.cloud");

$editApi = new GroupDocs\Editor\EditApi($configuration);

完全な例は CommonUtils.php を参照してください。

Word ドキュメントを編集する

初期化したら、この基本的な例を使用して、パスワードで保護された Word ドキュメントを読み込み、その HTML 表現を編集して、結果を保存します。

<?php

require_once(__DIR__ . '/vendor/autoload.php');

use GroupDocs\Editor\Model;
use GroupDocs\Editor\Model\Requests;

$configuration = new GroupDocs\Editor\Configuration();
$configuration->setAppSid("YourClientId");
$configuration->setAppKey("YourClientSecret");
$configuration->setApiBaseUrl("https://api.groupdocs.cloud");

$editApi = new GroupDocs\Editor\EditApi($configuration);
$fileApi = new GroupDocs\Editor\FileApi($configuration);

$fileInfo = new Model\FileInfo();
$fileInfo->setFilePath("WordProcessing/password-protected.docx");
$fileInfo->setPassword("password");

$loadOptions = new Model\WordProcessingLoadOptions();
$loadOptions->setFileInfo($fileInfo);
$loadOptions->setOutputPath("output");
$loadResult = $editApi->load(new Requests\loadRequest($loadOptions));

$htmlFile = $fileApi->downloadFile(new Requests\downloadFileRequest($loadResult->getHtmlPath()));
$html = file_get_contents($htmlFile->getRealPath());
$html = str_replace("Sample test text", "Hello world", $html);
file_put_contents($htmlFile->getRealPath(), $html);

$fileApi->uploadFile(new Requests\uploadFileRequest($loadResult->getHtmlPath(), $htmlFile->getRealPath()));

$saveOptions = new Model\WordProcessingSaveOptions();
$saveOptions->setFileInfo($fileInfo);
$saveOptions->setOutputPath("output/edited.docx");
$saveOptions->setHtmlPath($loadResult->getHtmlPath());
$saveOptions->setResourcesPath($loadResult->getResourcesPath());
$saveResult = $editApi->save(new Requests\saveRequest($saveOptions));

echo "Document edited: " . $saveResult->getPath() . "\n";

完全な例は EditWordProcessingDocument.php を参照してください。

スプレッドシート ドキュメントを編集する

この例では、XLSX ファイルの最初のワークシートを読み込み、その HTML コンテンツを編集して、スプレッドシートを保存します。

<?php

require_once(__DIR__ . '/vendor/autoload.php');

use GroupDocs\Editor\Model;
use GroupDocs\Editor\Model\Requests;

$configuration = new GroupDocs\Editor\Configuration();
$configuration->setAppSid("YourClientId");
$configuration->setAppKey("YourClientSecret");
$configuration->setApiBaseUrl("https://api.groupdocs.cloud");

$editApi = new GroupDocs\Editor\EditApi($configuration);
$fileApi = new GroupDocs\Editor\FileApi($configuration);

$fileInfo = new Model\FileInfo();
$fileInfo->setFilePath("Spreadsheet/four-sheets.xlsx");

$loadOptions = new Model\SpreadsheetLoadOptions();
$loadOptions->setFileInfo($fileInfo);
$loadOptions->setOutputPath("output");
$loadOptions->setWorksheetIndex(0);
$loadResult = $editApi->load(new Requests\loadRequest($loadOptions));

$htmlFile = $fileApi->downloadFile(new Requests\downloadFileRequest($loadResult->getHtmlPath()));
$html = file_get_contents($htmlFile->getRealPath());
$html = str_replace("This is sample sheet", "This is sample sheep", $html);
file_put_contents($htmlFile->getRealPath(), $html);

$fileApi->uploadFile(new Requests\uploadFileRequest($loadResult->getHtmlPath(), $htmlFile->getRealPath()));

$saveOptions = new Model\SpreadsheetSaveOptions();
$saveOptions->setFileInfo($fileInfo);
$saveOptions->setOutputPath("output/edited.xlsx");
$saveOptions->setHtmlPath($loadResult->getHtmlPath());
$saveOptions->setResourcesPath($loadResult->getResourcesPath());
$saveResult = $editApi->save(new Requests\saveRequest($saveOptions));

echo "Document edited: " . $saveResult->getPath() . "\n";

完全な例は EditSpreadsheetDocument.php を参照してください。

ドキュメント情報を取得する

パスワードで保護された Word ドキュメントのページ数を取得します。

<?php

require_once(__DIR__ . '/vendor/autoload.php');

use GroupDocs\Editor\Model;
use GroupDocs\Editor\Model\Requests;

$configuration = new GroupDocs\Editor\Configuration();
$configuration->setAppSid("YourClientId");
$configuration->setAppKey("YourClientSecret");
$configuration->setApiBaseUrl("https://api.groupdocs.cloud");

$infoApi = new GroupDocs\Editor\InfoApi($configuration);

$fileInfo = new Model\FileInfo();
$fileInfo->setFilePath("WordProcessing/password-protected.docx");
$fileInfo->setPassword("password");

$response = $infoApi->getInfo(new Requests\getInfoRequest($fileInfo));

echo "Page Count = " . $response->getPageCount() . "\n";

完全な例は GetDocumentInformation.php を参照してください。

サポートされているファイル タイプを取得する

サポートされているファイル形式を取得します。

<?php

require_once(__DIR__ . '/vendor/autoload.php');

$configuration = new GroupDocs\Editor\Configuration();
$configuration->setAppSid("YourClientId");
$configuration->setAppKey("YourClientSecret");
$configuration->setApiBaseUrl("https://api.groupdocs.cloud");

$infoApi = new GroupDocs\Editor\InfoApi($configuration);

$response = $infoApi->getSupportedFileFormats();

foreach ($response->getFormats() as $format) {
    echo $format->getFileFormat() . " - " . $format->getExtension() . "\n";
}

完全な例は GetSupportedFileTypes.php を参照してください。

GitHub の例

GroupDocs.Editor Cloud PHP Examples リポジトリには、以下をカバーするすぐに実行できるサンプルが含まれています。

CategoryExamples
ファイル タイプサポートされているファイル タイプ
ドキュメント情報ドキュメント情報、ライセンスの消費
編集操作 — Wordパスワードで保護されたファイルを含む、ワード プロセッシング ドキュメントの編集
編集操作 — Spreadsheetワークシートを選択してスプレッドシート ドキュメントを編集
編集操作 — Presentationスライドを選択してプレゼンテーション ドキュメントを編集
編集操作 — DSV区切り文字で区切られた値ドキュメントの編集
編集操作 — Textプレーン テキスト ドキュメントの編集

サンプルの実行方法

  1. 例のリポジトリ のクローンを作成するか、ダウンロードします。
  2. Examples/CommonUtils.php を編集し、ClientId と ClientSecret を設定します。
  3. Examples ディレクトリに移動します。
  4. composer update を実行します。
  5. php RunExamples.php を実行します。

詳細については、次のサイトをご覧ください。 Getting Started.


Product Docs Swagger Examples Blog Support Dashboard


タグ

Document Editing API | PHP Cloud API | GroupDocs.Editor Cloud | REST API | Word Processing Formats | Spreadsheet Formats | Presentation Formats | Text Formats | CSV Files | DOCX Documents | XLSX Documents | PPTX Presentations | Password-Protected Files | Cloud Storage Integration | Document Info Retrieval | File Operations | WYSIWYG Editing | Multi-Platform Support | Secure API Access | HTML Editing | Cross-platform API



 日本