protected function _convertFileToPdf($inputFile = null, $outputFile = null) {
		$cfgUnoconv = $this->_getUnoconvConfig();
		if ($cfgUnoconv === false) {
			throw new InternalErrorException(__d('view_extension', 'Unoconv is not configured'));
		}

		if (!file_exists($inputFile)) {
			throw new InternalErrorException(__d('view_extension', 'Invalid input file for converting to PDF'));
		}

		if (empty($outputFile)) {
			throw new InternalErrorException(__d('view_extension', 'Invalid output file for converting to PDF'));
		}

		if (mime_content_type($inputFile) === 'application/pdf') {
			return false;
		}

		extract($cfgUnoconv);
		if ($timeout <= 0) {
			$timeout = 60;
		}
		$unoconvOpt = [
			'timeout' => $timeout,
			'unoconv.binaries' => $binaries,
		];
		$unoconv = Unoconv\Unoconv::create($unoconvOpt);
		$unoconv->transcode($inputFile, 'pdf', $outputFile);
		if (!file_exists($outputFile)) {
			throw new InternalErrorException(__d('view_extension', 'Error on creation PDF file'));
		}

		return true;
	}
protected function _convertFileToPdf($inputFile = null, $outputFile = null) {
		$cfgUnoconv = $this->_getUnoconvConfig();
		if ($cfgUnoconv === false) {
			throw new InternalErrorException(__d('view_extension', 'Unoconv is not configured'));
		}

		if (!file_exists($inputFile)) {
			throw new InternalErrorException(__d('view_extension', 'Invalid input file for converting to PDF'));
		}

		if (empty($outputFile)) {
			throw new InternalErrorException(__d('view_extension', 'Invalid output file for converting to PDF'));
		}

		if (mime_content_type($inputFile) === 'application/pdf') {
			return false;
		}

		extract($cfgUnoconv);
		if ($timeout <= 0) {
			$timeout = 60;
		}
		$unoconvOpt = [
			'timeout' => $timeout,
			'unoconv.binaries' => $binaries,
		];
		$unoconv = Unoconv\Unoconv::create($unoconvOpt);
		$unoconv->transcode($inputFile, 'pdf', $outputFile);
		if (!file_exists($outputFile)) {
			throw new InternalErrorException(__d('view_extension', 'Error on creation PDF file'));
		}

		return true;
	}
protected function _convertFileToPdf ( $ inputFile = null , $ outputFile = null ) { $ cfgUnoconv = $ this -> _getUnoconvConfig ( ) ; if ( $ cfgUnoconv === false ) { throw new InternalErrorException ( __d ( 'view_extension' , 'Unoconv is not configured' ) ) ; } if ( ! file_exists ( $ inputFile ) ) { throw new InternalErrorException ( __d ( 'view_extension' , 'Invalid input file for converting to PDF' ) ) ; } if ( empty ( $ outputFile ) ) { throw new InternalErrorException ( __d ( 'view_extension' , 'Invalid output file for converting to PDF' ) ) ; } if ( mime_content_type ( $ inputFile ) === 'application/pdf' ) { return false ; } extract ( $ cfgUnoconv ) ; if ( $ timeout <= 0 ) { $ timeout = 60 ; } $ unoconvOpt = [ 'timeout' => $ timeout , 'unoconv.binaries' => $ binaries , ] ; $ unoconv = Unoconv \ Unoconv :: create ( $ unoconvOpt ) ; $ unoconv -> transcode ( $ inputFile , 'pdf' , $ outputFile ) ; if ( ! file_exists ( $ outputFile ) ) { throw new InternalErrorException ( __d ( 'view_extension' , 'Error on creation PDF file' ) ) ; } return true ; }
Converting input file into PDf file

@param string $inputFile Input file for converting.
@param string $outputFile Output file of converting.
@throws InternalErrorException if Unoconv is not configured.
@throws InternalErrorException if input file is
not exists.
@throws InternalErrorException if empty path to output file.
@throws InternalErrorException if PDF file is not created.
@return bool Return True, if input file is successfully converted
into PDF file. False otherwise.
Converting input file into PDf file