ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
ilCountPDFPagesPreProcessors Class Reference

Class ilCountPDFPagesPreProcessors. More...

+ Inheritance diagram for ilCountPDFPagesPreProcessors:
+ Collaboration diagram for ilCountPDFPagesPreProcessors:

Public Member Functions

 process (FileStream $stream, Metadata $metadata)
 This method gets invoked by the file upload service to process the file with the help of the processor.If the return value is REJECTED, no further invocations of processors are done for the rejected file.If the processor fails or returns an unexpected value, the file gets automatically rejected because the file could be dangerous to ILIAS.
Parameters
FileStream$streamThe stream of the file.
Metadata$metadataThe meta data of the uploaded file.
Returns
ProcessingStatus The new status of the file.
More...
 

Data Fields

const PAGE_COUNT = 'page_count'
 

Detailed Description

Member Function Documentation

◆ process()

ilCountPDFPagesPreProcessors::process ( FileStream  $stream,
Metadata  $metadata 
)

This method gets invoked by the file upload service to process the file with the help of the processor.If the return value is REJECTED, no further invocations of processors are done for the rejected file.If the processor fails or returns an unexpected value, the file gets automatically rejected because the file could be dangerous to ILIAS.

Parameters
FileStream$streamThe stream of the file.
Metadata$metadataThe meta data of the uploaded file.
Returns
ProcessingStatus The new status of the file.

Implements ILIAS\FileUpload\Processor\PreProcessor.

Definition at line 21 of file class.ilCountPDFPagesPreProcessors.php.

References ILIAS\FileUpload\DTO\Metadata\additionalMetaData(), ilMimeTypeUtil\APPLICATION__PDF, ilUtil\execQuoted(), Psr\Http\Message\StreamInterface\getMetadata(), and ILIAS\FileUpload\DTO\Metadata\getMimeType().

22  {
24  && PATH_TO_GHOSTSCRIPT != ""
25  ) {
26  $PATH_TO_PDF = $stream->getMetadata('uri');
27  $arg = "-q -dNODISPLAY -c \"($PATH_TO_PDF) (r) file runpdfbegin pdfpagecount = quit\";";
28  $return = ilUtil::execQuoted(PATH_TO_GHOSTSCRIPT, $arg);
29 
30  $metadata->additionalMetaData()->put(self::PAGE_COUNT, (string) $return[0]);
31  }
32 
33  return new ProcessingStatus(ProcessingStatus::OK, 'ilCountPDFPagesPreProcessors');
34  }
getMimeType()
Client supplied mime type of the uploaded.
Definition: Metadata.php:118
additionalMetaData()
Provides a string map implementation which allows the processors to store additional values...
Definition: Metadata.php:149
getMetadata($key=null)
Get stream metadata as an associative array or retrieve a specific key.
static execQuoted($cmd, $args=null)
exec command and fix spaces on windows
+ Here is the call graph for this function:

Field Documentation

◆ PAGE_COUNT

const ilCountPDFPagesPreProcessors::PAGE_COUNT = 'page_count'

Definition at line 15 of file class.ilCountPDFPagesPreProcessors.php.

Referenced by ilObjFile\raiseUploadError().


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