Download the PHP package daandesmedt/phpghostscript without Composer
On this page you can find all versions of the php package daandesmedt/phpghostscript. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download daandesmedt/phpghostscript
More information about daandesmedt/phpghostscript
Files in daandesmedt/phpghostscript
Package phpghostscript
Short Description A PHP wrapper for Ghostscript (An interpreter for the PostScript language and for PDF). Export PDF / PS to PDF or various image types (jpeg / png). Easy to use and OOP interfaced.
License MIT
Informations about the package phpghostscript
PHPGhostscript
A PHP wrapper for Ghostscript ; an interpreter for PostScript™ and Portable Document Format (PDF) files.
Use PHPGhostscript
for rendering PDF / PostScript™ files to various image types (jpeg / png) or export to PDF with page range (single page / multipage).
Setting multiple input files merge them.
Easy to use and OOP interfaced.
Installation
Install the package through composer:
Make sure, that you include the composer autoloader somewhere in your codebase.
Usage
Use PHPGhostscript
for rendering PDF / PostScript™ files to various image types (jpeg / png) or export to PDF with page range (single page / multipage).
Working examples
Working examples can be found in the examples
folder.
Supported devices
PHPGhostscript
output devices implement DeviceInterface
.
PHPGhostscript
supports common output devices:
- JPEG file format
- JPEG
- JPEG Grey
- PNG file format
- PNG
- PNG 16
- PNG 256
- PNG 16M
- PNG Alpha
- PNG Grey
- PNG Mono
- PNG MonoD
- PDF file format
Specify a output device
Set output decive through DeviceTypes
constant.
OR set with instanceof DeviceInterface
Device specific parameters
Device output type | Function |
---|---|
JPEG / JPEG GREY | setQuality(int $quality) |
PNG ALPHA | setBackgroundColor(string $color) |
setDownScaleFactor(int $factor) |
|
PNG MONO D | setMinFeatureSize(int $size) |
PNG 16M | setDownScaleFactor(int $factor) |
Example :
PDF (single page) / PostScript™ to Image
Single output file per page
Export multi-page PDF files to seperate image files using the ` Specifying a single output file works fine for printing and rasterizing figures, but sometimes you want images of each page of a multi-page document. You can tell
PHPGhostscriptto put each page of the input file in a series of similarly named files. To do this place a template
%din the
setOutputFilesetter (
%d` will be replaced by the matching page number).
Specify page range
or set start and end explicitly
Clear specified page range
Subsample antialiasing
These options control the use of subsample antialiasing. Their use is highly recommended for producing high quality rasterizations of the input files.
Use Ghostscript::ANTIALIASING_HIGH
for optimum output, user Ghostscript::ANTIALIASING_LOW
or Ghostscript::ANTIALIASING_NONE
for faster rendering. Antialiasing can be set separately for text and graphics content, but only for image type output devices.
or set text and graphics antialiasing explicitly
Output resolution
This option sets the resolution of the output file in dots per inch. The default value if you don't specify this options is 72 dpi. Support for specifying horizontal and vertical resolution.
Setting CIE Color
Set UseCIEColor in the page device dictionary, remapping device-dependent color values through a Postscript defined CIE color space. Document DeviceGray, DeviceRGB and DeviceCMYK source colors will be substituted respectively by Postscript CIEA, CIEABC and CIEDEFG color spaces. Only for image type output devices.
Setting page content region
Sets the page size to one of the following :
- BleedBox (
Ghostscript::BOX_BLEED
) : defines the region to which the contents of the page should be clipped when output in a production environment. This may include any extra bleed area needed to accommodate the physical limitations of cutting, folding, and trimming equipment. The actual printed page may include printing marks that fall outside the bleed box. - TrimBox (
Ghostscript::BOX_TRIM
) : defines the intended dimensions of the finished page after trimming. Some files have a TrimBox that is smaller than the MediaBox and may include white space, registration or cutting marks outside the CropBox. Using this option simulates appearance of the finished printed page. - ArtBox (
Ghostscript::BOX_ART
) : defines the extent of the page's meaningful content (including potential white space) as intended by the page's creator. The art box is likely to be the smallest box. It can be useful when one wants to crop the page as much as possible without losing the content. - CropBox (
Ghostscript::BOX_CROP
) : Unlike the other "page boundary" boxes, CropBox does not have a defined meaning, it simply provides a rectangle to which the page contents will be clipped (cropped). By convention, it is often, but not exclusively, used to aid the positioning of content on the (usually larger, in these cases) media. - NONE (
Ghostscript::BOX_NONE
)
Handling exceptions
PHPGhostscript
will throw following exceptions :
InvalidArgumentException
: thrown if an argument is not of the expected type.GhostscriptException
: thrown if Ghostscript was unable to transcode.