製品を閲覧する

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-assembly-cloud

Packagist Version Packagist Downloads PHP-GroupDocsCloud


要件

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

依存関係

SDK は次のパッケージを必要とします。

PackageConstraint
guzzlehttp/guzzle^6.2
ext-curl*
ext-json*
ext-mbstring*

クイックスタート

API 認証情報を取得する

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

API を初期化する

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

<?php

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

// Get your ClientId and ClientSecret at https://dashboard.groupdocs.cloud
$assembly = new GroupDocs\Assembly\AssemblyApi("YourClientId", "YourClientSecret");
$assembly->getConfig()->setHost("https://api.groupdocs.cloud");

詳細については BaseTestContext.php を参照してください。

テンプレートからドキュメントを組み立てる

初期化したら、この基本的な例を使用して、GroupDocs Cloud に保存済みのテンプレートとローカルのデータ ファイルからドキュメントを組み立てます。

<?php

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

use GroupDocs\Assembly\Model;
use GroupDocs\Assembly\Model\Requests;

$assembly = new GroupDocs\Assembly\AssemblyApi("YourClientId", "YourClientSecret");
$assembly->getConfig()->setHost("https://api.groupdocs.cloud");

$reportData = file_get_contents("FileWithData");
$assembleData = new Model\AssembleOptions(array(
    "template_file_info" => new Model\TemplateFileInfo(array("file_path" => "FileNameInStorage")),
    "save_format" => "pdf",
    "report_data" => $reportData
));
$request = new Requests\AssembleDocumentRequest($assembleData);
$result = $assembly->assembleDocument($request);

echo "Assembled document size: " . $result->getSize() . "\n";

詳細については SDK README を参照してください。

テンプレートをアップロードして PDF に組み立てる

この例では、TableFeatures.odt をアップロードし、TableData.json で組み立てて、結果のサイズを確認します。

<?php

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

use GroupDocs\Assembly\Model;
use GroupDocs\Assembly\Model\Requests;

$assembly = new GroupDocs\Assembly\AssemblyApi("YourClientId", "YourClientSecret");
$assembly->getConfig()->setHost("https://api.groupdocs.cloud");

$file = __DIR__ . "/TableFeatures.odt";
$remotePath = "Temp/SdkTests/php/GroupDocs/Assembly/TableFeatures.odt";

$assembly->uploadFile(new Requests\UploadFileRequest($file, $remotePath));

$reportData = file_get_contents(__DIR__ . "/TableData.json");
$assembleData = new Model\AssembleOptions(array(
    "template_file_info" => new Model\TemplateFileInfo(array("file_path" => $remotePath)),
    "save_format" => "pdf",
    "report_data" => $reportData
));
$request = new Requests\AssembleDocumentRequest($assembleData);
$result = $assembly->assembleDocument($request);

echo "Assembled document size: " . $result->getSize() . "\n";

詳細については AssemblyApiTests.php を参照してください。

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

サポートされているアセンブリのファイル形式を取得します。

<?php

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

use GroupDocs\Assembly\Model\Requests;

$assembly = new GroupDocs\Assembly\AssemblyApi("YourClientId", "YourClientSecret");
$assembly->getConfig()->setHost("https://api.groupdocs.cloud");

$response = $assembly->getSupportedFileFormats(new Requests\GetSupportedFileFormatsRequest());

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

詳細については GetSupportedFileFormatsRequest.php を参照してください。

クラウド ストレージからファイルをダウンロードする

以前にストレージにアップロードしたファイルをダウンロードします。

<?php

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

use GroupDocs\Assembly\Model\Requests;

$assembly = new GroupDocs\Assembly\AssemblyApi("YourClientId", "YourClientSecret");
$assembly->getConfig()->setHost("https://api.groupdocs.cloud");

$request = new Requests\DownloadFileRequest("Temp/SdkTests/php/GroupDocs/Assembly/TableFeatures.odt");
$result = $assembly->downloadFile($request);

echo "Downloaded bytes: " . $result->getSize() . "\n";

詳細については DownloadFileRequest.php を参照してください。

GitHub の例

GroupDocs.Assembly Cloud PHP SDK リポジトリには、以下をカバーする README のサンプルとテストが含まれています。

CategoryExamples
ドキュメント アセンブリストレージ上のテンプレートとローカルのデータ ファイルからドキュメントを組み立てる
テストTestData/TableFeatures.odt をアップロードし、TestData/TableData.json で PDF に組み立てる
ファイルおよび形式 APIサポートされているファイル形式、アップロード、ダウンロード

サンプルの実行方法

  1. composer require groupdocscloud/groupdocs-assembly-cloud でパッケージをインストールします。
  2. require_once('vendor/autoload.php'); で Composer のオートロードを読み込みます。
  3. 認証情報を Settings/servercreds.json に設定します。
  4. README のサンプル使用法を実行します。その他の例は tests にあります。

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


Product Docs Swagger Examples Blog Support Dashboard


タグ

Document Automation | PHP Cloud API | GroupDocs.Assembly Cloud | REST API | Document Generation | Template Assembly | Report Generation | Mail Merge | JSON Data | Dynamic Data Merging | PDF Generation | Cloud Storage | File Upload API | Supported File Formats | Secure API Access



 日本