codeinc/pdf2img-client
最新稳定版本:v1.10
Composer 安装命令:
composer require codeinc/pdf2img-client
包简介
A PHP client for the pdf2img service
README 文档
README
Important
This client is deprecated and is replaced by the Document Cloud PHP Client
This repository contains a PHP 8.2+ library for converting PDF files to images using the pdf2img service.
Installation
The library is available on Packagist. The recommended way to install it is via Composer:
composer require codeinc/pdf2img-client
Usage
This client requires a running instance of the pdf2img service. The service can be run locally using Docker or deployed to a server.
Base example:
use CodeInc\Pdf2ImgClient\Pdf2ImgClient; use CodeInc\Pdf2ImgClient\Exception; $apiBaseUri = 'http://localhost:3000/'; $localPdfPath = '/path/to/local/file.pdf'; try { $client = new Pdf2ImgClient($apiBaseUri); // convert $image = $client->convert( $client->createStreamFromFile($localPdfPath) ); // display the image header('Content-Type: image/webp'); echo (string)$image; } catch (Exception $e) { // handle exception }
With options:
use CodeInc\Pdf2ImgClient\Pdf2ImgClient; use CodeInc\Pdf2ImgClient\ConvertOptions; $apiBaseUri = 'http://localhost:3000/'; $localPdfPath = '/path/to/local/file.pdf'; $destinationPath = '/path/to/destination/file.jpg'; $convertOption = new ConvertOptions( format: 'jpg', page: 3, density: 300, height: 800, width: 800, background: 'red', quality: 90, ); try { $client = new Pdf2ImgClient($apiBaseUri); // convert $image = $client->convertLocalFile( $client->createStreamFromFile($localPdfPath), $convertOption ); // saves the image to a file $client->saveStreamToFile($image, $destinationPath); } catch (Exception $e) { // handle exception }
License
The library is published under the MIT license (see LICENSE file).
统计信息
- 总下载量: 27
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2024-02-17