Jelajahi Produk kami

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

Pemasangan

Paketnya adalah tersedia di Packagist dan dapat diinstal melalui Composer dengan menjalankan perintah berikut:

composer require groupdocscloud/groupdocs-viewer-cloud

Packagist Version Packagist Downloads PHP-GroupDocsCloud


Persyaratan

  • PHP 8.1 atau lebih baru
  • Composer
  • Ekstensi PHP — curl, json, mbstring
  • Kredensial GroupDocs Cloud — Client ID and Client Secret dari Dashboard

Ketergantungan

SDK memerlukan paket-paket berikut:

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

Mulai Cepat

Dapatkan kredensial API Anda

Untuk menggunakan GroupDocs.Viewer Cloud, daftar di GroupDocs.Cloud Dashboard dan dapatkan ID Klien dan Rahasia Klien Anda.

Inisialisasi API

Gunakan kode berikut untuk mulai menggunakan GroupDocs.Viewer Cloud SDK untuk PHP:

<?php

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

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

$viewApi = new GroupDocs\Viewer\ViewApi($configuration);

Lihat contoh lengkap di Utils.php.

Konversi dan unduh dokumen (langsung, tanpa penyimpanan cloud)

Setelah diinisialisasi, gunakan contoh dasar ini untuk mengonversi dokumen lokal ke JPG dan menerima hasilnya secara langsung.

<?php

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

use GroupDocs\Viewer\Model\Requests;

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

$viewApi = new GroupDocs\Viewer\ViewApi($configuration);

$format = "jpg";
$filePath = __DIR__ . "/sample.docx";
$request = new Requests\convertAndDownloadRequest($format, $filePath);

$result = $viewApi->convertAndDownload($request);

echo "Document converted: " . $result->getSize() . "\n";

Lihat contoh lengkap di ConvertAndDownload.php.

Render Dokumen dengan HTML Responsif

Contoh ini merender dokumen Word dari penyimpanan cloud sebagai HTML responsif.

<?php

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

use GroupDocs\Viewer\Model;
use GroupDocs\Viewer\Model\Requests;

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

$viewApi = new GroupDocs\Viewer\ViewApi($configuration);

$viewOptions = new Model\ViewOptions();

$fileInfo = new Model\FileInfo();
$fileInfo->setFilePath("SampleFiles/sample.docx");
$viewOptions->setFileInfo($fileInfo);
$viewOptions->setViewFormat(Model\ViewOptions::VIEW_FORMAT_HTML);

$renderOptions = new Model\HtmlOptions();
$renderOptions->setIsResponsive(true);
$viewOptions->setRenderOptions($renderOptions);

$request = new Requests\createViewRequest($viewOptions);
$response = $viewApi->createView($request);

echo "Responsive HTML rendered: " . count($response->getPages()) . "\n";

Lihat contoh lengkap di HtmlViewerResponsiveLayout.php.

Render Halaman yang Dipilih

Contoh ini hanya merender halaman 1 dan 3.

<?php

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

use GroupDocs\Viewer\Model;
use GroupDocs\Viewer\Model\Requests;

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

$viewApi = new GroupDocs\Viewer\ViewApi($configuration);

$viewOptions = new Model\ViewOptions();

$fileInfo = new Model\FileInfo();
$fileInfo->setFilePath("SampleFiles/sample.docx");
$viewOptions->setFileInfo($fileInfo);
$viewOptions->setViewFormat(Model\ViewOptions::VIEW_FORMAT_HTML);

$renderOptions = new Model\HtmlOptions();
$renderOptions->setPagesToRender([1, 3]);
$viewOptions->setRenderOptions($renderOptions);

$request = new Requests\createViewRequest($viewOptions);
$response = $viewApi->createView($request);

echo "Selected pages rendered: " . count($response->getPages()) . "\n";

Lihat contoh lengkap di RenderSelectedPages.php.

Dapatkan Format File yang Didukung

Ambil format file yang didukung.

<?php

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

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

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

$response = $infoApi->getSupportedFileFormats();

echo "Number of formats = " . count($response->getFormats()) . "\n";

Lihat contoh lengkap di GetSupportedFormats.php.

Contoh di GitHub

Repositori GroupDocs.Viewer Cloud PHP Examples menyertakan contoh siap dijalankan yang meliputi:

CategoryExamples
Penggunaan DasarFormat yang didukung, info dokumen, lampiran, konversi dan unduh
Penampil HTMLTata letak responsif, perkecil HTML, kecualikan font, batasi ukuran gambar, optimalkan untuk pencetakan
Penampil GambarSesuaikan ukuran gambar, kualitas JPG, hamparan teks, koordinat teks
Penampil PDFLindungi PDF, sesuaikan kualitas JPG
Opsi Rendering UmumTanda air, balik dan putar halaman, komentar, halaman berurutan, halaman tersembunyi, catatan, halaman yang dipilih, font khusus, urutkan ulang halaman, ganti font yang hilang
Opsi PemuatanDokumen yang dilindungi, tentukan pengkodean
Render berdasarkan Jenis FileArsip, CAD, email, Lotus Notes, MS Project, Outlook, PDF, spreadsheet, teks, Visio, Word

Cara menjalankan contoh

  1. Kloning atau unduh repositori contoh
  2. Sunting Examples/Utils.php dan atur Client Id dan Client Secret Anda
  3. Pergi ke direktori Examples
  4. Jalankan composer update
  5. Jalankan php RunExamples.php

Untuk lebih jelasnya, kunjungi Getting Started.


Product Docs Swagger Examples Blog Support Dashboard


Tags

Document Rendering API | PHP Cloud API | GroupDocs.Viewer Cloud | REST API | HTML Rendering | PDF Conversion | Image Rendering | Document Viewing | Multi-Page Rendering | Document Streaming | CAD Rendering | E-Mail Message Rendering | Visio Rendering | MS Project Rendering | Outlook Data Rendering | Spreadsheet Rendering | Word Processing Rendering | Custom View Options | Responsive HTML | Attachment Rendering | Secure API Access | Cloud Storage Integration



 Indonesia