<?php

require_once dirname(__FILE__) . '/../../common.php';
require_once dirname(__FILE__) . '/../../Converter.php';
// -----------------------------------------------------------------------------
define('PATH_BASE', dirname(__FILE__));
//if (isset($_GET['fileName'])){
//$fileName = $_GET['fileName'];
//}
//$inputFilename = PATH_BASE . DIRECTORY_SEPARATOR . $fileName.'.rtf';  // convert this file
//$outputFormat  = 'pdf';                                             // into this format
$inputFilename = PATH_BASE . DIRECTORY_SEPARATOR . $fileName . '.rtf';
// convert this file
$outputFormat = 'pdf';
// -----------------------------------------------------------------------------
$outputFilename = Converter::getFilename($inputFilename, $outputFormat);
//printf('Converting %s to %s... ', basename($inputFilename), basename($outputFilename));
$convertedDocument = Converter::convert($inputFilename, $outputFormat);
if (false !== $convertedDocument) {
    file_put_contents($outputFilename, $convertedDocument);
    print "DONE.\n";
} else {
    print "ERROR.\n";
}
// -----------------------------------------------------------------------------
Beispiel #2
0
 $outputFormat = strtolower($outputFormat);
 if (!in_array($outputFormat, $outputFormats)) {
     echo $opts->getUsageMessage();
     exit;
 }
 // -------------------------------------------------------------------------
 touch(FILENAME_LOCK);
 // -------------------------------------------------------------------------
 $path = new DirectoryIterator(PATH_INPUT);
 $inputFormats = $phpLiveDocx->getTemplateFormats();
 foreach ($path as $file) {
     $inputFormat = Tis_Service_LiveDocx::getFormat($file->getFilename());
     if (in_array($inputFormat, $inputFormats)) {
         $inputFilename = PATH_INPUT . DIRECTORY_SEPARATOR . $file->getFilename();
         $inputDoneFilename = PATH_INPUT_DONE . DIRECTORY_SEPARATOR . $file->getFilename();
         $outputFilename = PATH_OUTPUT . DIRECTORY_SEPARATOR . Converter::getFilename($file->getFilename(), $outputFormat);
         printf('Converting %s to %s... ', basename($inputFilename), basename($outputFilename));
         if ($inputFormat === $outputFormat) {
             rename($inputFilename, $inputDoneFilename);
             print "SKIPPED.\n";
         } else {
             $convertedDocument = Converter::convert($inputFilename, $outputFormat);
             if (false !== $convertedDocument) {
                 file_put_contents($outputFilename, $convertedDocument);
                 rename($inputFilename, $inputDoneFilename);
                 print "DONE.\n";
             } else {
                 print "ERROR.\n";
             }
         }
     }