定制 gravitymedia/ghostscript 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

gravitymedia/ghostscript

最新稳定版本:2.4.0

Composer 安装命令:

composer require gravitymedia/ghostscript

包简介

Ghostscript is an object oriented Ghostscript binary wrapper for PHP.

README 文档

README

Latest Version on Packagist Software License Build Status Coverage Status Quality Score Total Downloads

Ghostscript is an object oriented Ghostscript binary wrapper for PHP.

Requirements

This library has the following requirements:

  • PHP 8.0+
  • Ghostscript 9.00+

Installation

Install Composer in your project:

$ curl -s https://getcomposer.org/installer | php

Require the package via Composer:

$ php composer.phar require gravitymedia/ghostscript:v2.4

Usage

This is a simple usage example how to convert an input PDF to an output PDF.

// Initialize autoloader
require_once __DIR__ . '/vendor/autoload.php';

// Import classes
use GravityMedia\Ghostscript\Ghostscript;
use Symfony\Component\Process\Process;

// Define input and output files
$inputFile = '/path/to/input/file.pdf';
$outputFile = '/path/to/output/file.pdf';

// Create Ghostscript object
$ghostscript = new Ghostscript([
    'quiet' => false
]);

// Create and configure the device
$device = $ghostscript->createPdfDevice($outputFile);
$device->setCompatibilityLevel(1.4);

// Create process
$process = $device->createProcess($inputFile);

// Print the command line
print '$ ' . $process->getCommandLine() . PHP_EOL;

// Run process
$process->run(function ($type, $buffer) {
    if ($type === Process::ERR) {
        throw new \RuntimeException($buffer);
    }

    print $buffer;
});

Testing

Clone this repository, install Composer and all dependencies:

$ php composer.phar install

Run the test suite:

$ php composer.phar test

Generating documentation

Clone this repository, install Composer and all dependencies:

$ php composer.phar install

Generate the documentation to the build/docs directory:

$ php composer.phar doc

Contributing

Please see CONTRIBUTING for details.

Credits

License

The MIT License (MIT). Please see License File for more information.

统计信息

  • 总下载量: 219.17k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 30
  • 点击次数: 1
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 29
  • Watchers: 1
  • Forks: 17
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2014-06-01