本文整理汇总了PHP中Converter::Convert方法的典型用法代码示例。如果您正苦于以下问题:PHP Converter::Convert方法的具体用法?PHP Converter::Convert怎么用?PHP Converter::Convert使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Converter
的用法示例。
在下文中一共展示了Converter::Convert方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: openOOdocument
public static function openOOdocument($filepath)
{
$myConverter = new Converter();
$pdfFilter = self::getPDFFilterString($filepath);
if ($pdfFilter == 'PDF') {
//None Convert anything
$PDFPath = $myConverter->Convert($filepath);
} else {
//Convert to PDF
$PDFPath = $myConverter->Convert($filepath, $pdfFilter);
}
$PDFDir = dirname($PDFPath);
if (!$PDFPath || !file_exists($PDFPath)) {
throw new Exception('Cannot convert document');
}
//Generate Images from PDF
$imageRadixName = 'results';
$smallImageRadixName = 'preview';
$cmd = 'convert -interlace line -quality 75 -density 100 ' . escapeshellarg($PDFPath) . ' ' . escapeshellarg($PDFDir . '/' . $imageRadixName . '.jpg');
shell_exec('LANG=en_US.utf-8;' . $cmd);
$cmd = 'convert -interlace line -quality 30 -density 70 ' . escapeshellarg($PDFPath) . ' ' . escapeshellarg($PDFDir . '/' . $smallImageRadixName . '.jpg');
shell_exec('LANG=en_US.utf-8;' . $cmd);
$iterator = new DirectoryIterator($PDFDir);
$imagesList = array();
$smallImageList = array();
foreach ($iterator as $fileInfo) {
if (strpos($fileInfo->getFilename(), $smallImageRadixName) !== false) {
$smallImageList[] = $fileInfo->getFileName();
}
if (strpos($fileInfo->getFilename(), $imageRadixName) !== false) {
$imageList[] = $fileInfo->getFileName();
}
}
natsort($imageList);
natsort($smallImageList);
return array('hash' => basename($PDFDir), 'images' => array_values($imageList), 'previews' => array_values($smallImageList));
}
示例2: fileExport
public static function fileExport(array $params)
{
$destinationFile = $params[0];
$originalFile = $params[1];
$format = $params[2];
if ($format == 'PDF') {
$extension = 'pdf';
$format = 'writer_pdf_Export';
} elseif ($format == 'Doc') {
$extension = 'doc';
$format = 'MS Word 97';
} elseif ($format == 'Open Office') {
$extension = 'odt';
$format = 'writer8';
} elseif ($format == 'HTML') {
$extension = 'html';
$format = 'HTML (StarWriter)';
} elseif ($format == 'RTF') {
$extension = 'rtf';
$format = 'Rich Text Format';
} elseif ($format == 'TXT') {
$extension = 'txt';
$format = 'Text (encoded)';
}
$destinationFile .= '.' . $extension;
$file = FSI::getFile($originalFile);
$memory = MemoryManager::getInstance();
$file->checkReadPermission();
$to = 'home:///';
//then, check the destination file
$myFileDest = FSI::getFile($to);
$myFileDest->checkWritePermission();
$myRealFile = $myFileDest->getRealFile();
$partName = '.office/' . uniqid(time()) . '_conversion/';
$fileNameDestination = AdvancedPathLib::getPhpLocalHackPath($myRealFile->getPath()) . '/' . $partName;
mkdir($fileNameDestination);
$myRealFile = $file->getRealFile();
$originalFile = AdvancedPathLib::getPhpLocalHackPath($myRealFile->getPath());
$cmd = 'unzip -d ' . escapeshellarg($fileNameDestination) . ' ' . escapeshellarg($originalFile);
shell_exec($cmd);
$myConverter = new Converter();
$fileName = $myConverter->Convert($to . $partName . '/document.html', $format);
shell_exec('rm -rf ' . escapeshellarg($fileNameDestination));
if (!file_exists($fileName)) {
return false;
}
$content = file_get_contents($fileName);
$newFile = FSI::getFile($destinationFile);
$newFile->createNewFile(true);
$newFile->putContents($content);
return $destinationFile;
}
示例3: getDocument
public static function getDocument($params)
{
$instance = MemoryManager::getInstance();
$plist = $instance->get('playList');
$filepath = $plist[$params];
$info = utf8_pathinfo($filepath);
//TODO: maybe fsi has better things than pathinfo
if (strtolower($info['extension']) == 'odt' || strtolower($info['extension']) == 'doc' || strtolower($info['extension']) == 'xls' || strtolower($info['extension']) == 'ods') {
$myConverter = new Converter();
$path = $myConverter->Convert($filepath, 'HTML (StarWriter)');
$md5 = utf8_basename($path);
if (!$path || !file_exists($path)) {
return array($filepath, 'Unable to convert office file, maybe this system does not have office support installed?');
}
//TODO: we are having problems with FSI and hidden folders
$data = file_get_contents($path);
$data = str_replace('<IMG SRC="', '<IMG SRC="index.php/externMsg/' . ProcManager::getInstance()->getCurrentProcess()->getChecknum() . '/viewTempImg/', $data);
return array($filepath, $data);
}
$myFile = FSI::getFile($filepath);
$data = $myFile->getContents();
return array($filepath, $data);
}
示例4: openOOdocument
private function openOOdocument($filepath)
{
$myConverter = new Converter();
$pdfFilter = self::getPDFFilterString($filepath);
if ($pdfFilter == 'PDF') {
//None Convert anything
$PDFPath = $myConverter->Convert($filepath);
} else {
//Convert to PDF
$PDFPath = $myConverter->Convert($filepath, $pdfFilter);
}
if (!$PDFPath || !file_exists($PDFPath)) {
throw new Exception('Cannot convert document');
}
return $PDFPath;
}