ILIAS  Release_4_4_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
ilGhostscriptRenderer Class Reference

Preview renderer class that is able to create previews from PDF, PS and EPS by using GhostScript. More...

+ Inheritance diagram for ilGhostscriptRenderer:
+ Collaboration diagram for ilGhostscriptRenderer:

Public Member Functions

 getSupportedFileFormats ()
 Gets an array containing the file formats that are supported by the renderer.
- Public Member Functions inherited from ilFilePreviewRenderer
 getSupportedRepositoryTypes ()
 Gets an array containing the repository types (e.g.
 supports ($preview)
 Determines whether the specified preview object is supported by the renderer.
 prepareFileForExec ($filepath)
 Checks whether the specified file path can be used with exec() commands.
- Public Member Functions inherited from ilPreviewRenderer
 getName ()
 Gets the name of the renderer.
 isPlugin ()
 Determines whether the renderer is a plugin or a built in one.
 render ($preview, $obj, $async)
 Creates the preview of the specified preview object.

Static Public Member Functions

static isGhostscriptInstalled ()
 Determines whether Ghostscript is installed.

Data Fields

const SUPPORTED_FORMATS = "eps,pdf,pdfa,ps"

Protected Member Functions

 renderImages ($obj)
 Renders the specified object into images.

Static Private Attributes

static $supported_formats = null

Detailed Description

Preview renderer class that is able to create previews from PDF, PS and EPS by using GhostScript.

Author
Stefan Born stefa.nosp@m.n.bo.nosp@m.rn@ph.nosp@m.zh.c.nosp@m.h
Version
$Id$

Definition at line 14 of file class.ilGhostscriptRenderer.php.

Member Function Documentation

ilGhostscriptRenderer::getSupportedFileFormats ( )

Gets an array containing the file formats that are supported by the renderer.

Returns
array An array containing the supported file formats.

Reimplemented from ilFilePreviewRenderer.

Definition at line 27 of file class.ilGhostscriptRenderer.php.

References $supported_formats.

{
// build formats only once
if (self::$supported_formats == null)
self::$supported_formats = explode(",", self::SUPPORTED_FORMATS);
}
static ilGhostscriptRenderer::isGhostscriptInstalled ( )
static

Determines whether Ghostscript is installed.

Definition at line 39 of file class.ilGhostscriptRenderer.php.

Referenced by ilRendererFactory\loadAvailableRenderers().

{
return (PATH_TO_GHOSTSCRIPT != "");
}

+ Here is the caller graph for this function:

ilGhostscriptRenderer::renderImages (   $obj)
protected

Renders the specified object into images.

The images do not need to be of the preview image size.

Parameters
ilObjFile$objThe object to create images from.
Returns
array An array of ilRenderedImage containing the absolute file paths to the images.

Reimplemented from ilPreviewRenderer.

Definition at line 51 of file class.ilGhostscriptRenderer.php.

References ilUtil\escapeShellArg(), ilUtil\execQuoted(), ilPreviewRenderer\getMaximumNumberOfPreviews(), ilUtil\ilTempnam(), and ilFilePreviewRenderer\prepareFileForExec().

{
$numOfPreviews = $this->getMaximumNumberOfPreviews();
// get file path
$filepath = $obj->getFile();
$inputFile = $this->prepareFileForExec($filepath);
// create a temporary file name and remove its extension
$output = str_replace(".tmp", "", ilUtil::ilTempnam());
// use '#' instead of '%' as it gets replaced by 'escapeShellArg' on windows!
$outputFile = $output . "_#02d.png";
// create images with ghostscript (we use PNG here as it has better transparency quality)
// gswin32c -dBATCH -dNOPAUSE -dSAFER -dFirstPage=1 -dLastPage=5 -sDEVICE=pngalpha -dEPSCrop -r72 -o $outputFile $inputFile
// gswin32c -dBATCH -dNOPAUSE -dSAFER -dFirstPage=1 -dLastPage=5 -sDEVICE=jpeg -dJPEGQ=90 -r72 -o $outputFile $inputFile
$args = sprintf(
"-dBATCH -dNOPAUSE -dSAFER -dFirstPage=1 -dLastPage=%d -sDEVICE=pngalpha -dEPSCrop -r72 -o %s %s",
$numOfPreviews,
str_replace("#", "%", ilUtil::escapeShellArg($outputFile)),
ilUtil::escapeShellArg($inputFile));
ilUtil::execQuoted(PATH_TO_GHOSTSCRIPT, $args);
// was a temporary file created? then delete it
if ($filepath != $inputFile)
@unlink($inputFile);
// check each file and add it
$images = array();
$outputFile = str_replace("#", "%", $outputFile);
for ($i = 1; $i <= $numOfPreviews; $i++)
{
$imagePath = sprintf($outputFile, $i);
if (!file_exists($imagePath))
break;
$images[] = new ilRenderedImage($imagePath);
}
return $images;
}

+ Here is the call graph for this function:

Field Documentation

ilGhostscriptRenderer::$supported_formats = null
staticprivate

Definition at line 20 of file class.ilGhostscriptRenderer.php.

Referenced by getSupportedFileFormats().

const ilGhostscriptRenderer::SUPPORTED_FORMATS = "eps,pdf,pdfa,ps"

Definition at line 17 of file class.ilGhostscriptRenderer.php.


The documentation for this class was generated from the following file: