/** * Renders the specified object into images. * The images do not need to be of the preview image size. * * @param ilObjFile $obj The object to create images from. * @return array An array of ilRenderedImage containing the absolute file paths to the images. */ protected function renderImages($obj) { $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; }
/** * Renders the specified object into images. * The images do not need to be of the preview image size. * * @param ilObjFile $obj The object to create images from. * @return array An array of ilRenderedImage containing the absolute file paths to the images. */ protected function renderImages($obj) { $filepath = $obj->getFile(); $tmpPath = $this->prepareFileForExec($filepath); $isTemporary = $tmpPath != $filepath; return array(new ilRenderedImage($tmpPath . "[0]", $isTemporary)); }
/** * send File to User */ public function sendFile() { global $ilAccess; //need read access to receive file if ($ilAccess->checkAccess("read", "", $this->parent_obj->ref_id)) { $rec_id = $_GET['record_id']; $record = ilDataCollectionCache::getRecordCache($rec_id); $field_id = $_GET['field_id']; $file_obj = new ilObjFile($record->getRecordFieldValue($field_id), false); if (!$this->recordBelongsToCollection($record, $this->parent_obj->ref_id)) { return; } ilUtil::deliverFile($file_obj->getFile(), $file_obj->getTitle()); } }