public function preview($id = null) {
		if (!method_exists($this->_model, 'generateExportFile')) {
			throw new InternalErrorException(__d(
				'view_extension',
				'Method "%s" is not exists in model "%s"',
				'generateExportFile()',
				$this->_model->name
			));
		}
		if (!method_exists($this->_model, 'getExportFilename')) {
			throw new InternalErrorException(__d(
				'view_extension',
				'Method "%s" is not exists in model "%s"',
				'getExportFilename()',
				$this->_model->name
			));
		}

		$tempFile = $this->_model->generateExportFile($id);
		if (empty($tempFile)) {
			throw new InternalErrorException(__d('view_extension', 'Invalid generated file'));
		}

		$previewFile = $tempFile;
		$exportPath = $this->_getExportDir();
		$pdfTempFile = $exportPath . uniqid() . '.pdf';
		if ($this->_convertFileToPdf($tempFile, $pdfTempFile)) {
			$previewFile = $pdfTempFile;
		}

		$exportFileName = $this->_model->getExportFilename($id, false);
		$preview = $this->_createImgPreview($previewFile);
		$orig = pathinfo($tempFile, PATHINFO_FILENAME);
		$pdf = null;
		if (!empty($pdfTempFile)) {
			$pdf = pathinfo($pdfTempFile, PATHINFO_FILENAME);
		}

		$download = compact('orig', 'pdf');
		$result = compact('exportFileName', 'preview', 'download');

		return $result;
	}
public function preview($id = null) {
		if (!method_exists($this->_model, 'generateExportFile')) {
			throw new InternalErrorException(__d(
				'view_extension',
				'Method "%s" is not exists in model "%s"',
				'generateExportFile()',
				$this->_model->name
			));
		}
		if (!method_exists($this->_model, 'getExportFilename')) {
			throw new InternalErrorException(__d(
				'view_extension',
				'Method "%s" is not exists in model "%s"',
				'getExportFilename()',
				$this->_model->name
			));
		}

		$tempFile = $this->_model->generateExportFile($id);
		if (empty($tempFile)) {
			throw new InternalErrorException(__d('view_extension', 'Invalid generated file'));
		}

		$previewFile = $tempFile;
		$exportPath = $this->_getExportDir();
		$pdfTempFile = $exportPath . uniqid() . '.pdf';
		if ($this->_convertFileToPdf($tempFile, $pdfTempFile)) {
			$previewFile = $pdfTempFile;
		}

		$exportFileName = $this->_model->getExportFilename($id, false);
		$preview = $this->_createImgPreview($previewFile);
		$orig = pathinfo($tempFile, PATHINFO_FILENAME);
		$pdf = null;
		if (!empty($pdfTempFile)) {
			$pdf = pathinfo($pdfTempFile, PATHINFO_FILENAME);
		}

		$download = compact('orig', 'pdf');
		$result = compact('exportFileName', 'preview', 'download');

		return $result;
	}
public function preview ( $ id = null ) { if ( ! method_exists ( $ this -> _model , 'generateExportFile' ) ) { throw new InternalErrorException ( __d ( 'view_extension' , 'Method "%s" is not exists in model "%s"' , 'generateExportFile()' , $ this -> _model -> name ) ) ; } if ( ! method_exists ( $ this -> _model , 'getExportFilename' ) ) { throw new InternalErrorException ( __d ( 'view_extension' , 'Method "%s" is not exists in model "%s"' , 'getExportFilename()' , $ this -> _model -> name ) ) ; } $ tempFile = $ this -> _model -> generateExportFile ( $ id ) ; if ( empty ( $ tempFile ) ) { throw new InternalErrorException ( __d ( 'view_extension' , 'Invalid generated file' ) ) ; } $ previewFile = $ tempFile ; $ exportPath = $ this -> _getExportDir ( ) ; $ pdfTempFile = $ exportPath . uniqid ( ) . '.pdf' ; if ( $ this -> _convertFileToPdf ( $ tempFile , $ pdfTempFile ) ) { $ previewFile = $ pdfTempFile ; } $ exportFileName = $ this -> _model -> getExportFilename ( $ id , false ) ; $ preview = $ this -> _createImgPreview ( $ previewFile ) ; $ orig = pathinfo ( $ tempFile , PATHINFO_FILENAME ) ; $ pdf = null ; if ( ! empty ( $ pdfTempFile ) ) { $ pdf = pathinfo ( $ pdfTempFile , PATHINFO_FILENAME ) ; } $ download = compact ( 'orig' , 'pdf' ) ; $ result = compact ( 'exportFileName' , 'preview' , 'download' ) ; return $ result ; }
Generate preview images of exported file

@param int|string $id ID for exported data.
@throws InternalErrorException if method Model::generateExportFile() is
not exists.
@throws InternalErrorException if empty result of call method Model::generateExportFile().
@throws InternalErrorException if the exported file is not converted into the PDF file.
@return array Return array of information for preview exported file. Format:
- key `exportFileName`; value - name of preview file;
- key `preview` - array of preview images; value - relative path to preview images.
- key `download` - array of files for downloading; value:
- key `orig`; value - file name of original file;
- key `pdf`; value - file name of PDF preview file.
Generate preview images of exported file