Code Monkey home page Code Monkey logo

ghostscript's Introduction

Ghostscript

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

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.3

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.

ghostscript's People

Contributors

alexandre-castelain avatar breiteseite avatar fgilio avatar julietgar avatar pionl avatar schroedan avatar wsilva94 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.