Beispiel #1
0
 /**
  * Primary processing routine for the source
  */
 private function processBook()
 {
     // Preset collectors
     $pageContents = array();
     $pageCssContents = array();
     // Work through all source files
     foreach ($this->sourceFiles as $sourceFile) {
         // Init Apache POI
         $converter = new XWPFToHTMLConverter($this->workingDir, $this->progress);
         if (!$converter) {
             throw new Exception('[WordProcessor::routine] ' . 'Book ID ' . $this->bookId . ' cannot be processed as a working directory cannot be found.');
         }
         // Set docx file to parse
         $converter->setDocFileToParse($sourceFile);
         // Convert everything to HTML
         $converter->convertToHTML();
         // Get HTML pages
         $pages = $converter->getHTMLPages();
         $this->progress->adjustMaxSteps(count($pages) * 2 + count($this->sourceAssets) + 1);
         foreach ($pages as $key => $page) {
             $pages[$key]->setStyleInline(false);
             $pageContents[] = $pages[$key]->getBodyHTML();
             $this->progress->incrementStep();
         }
         // Get CSS
         $pageCssContents[] = $converter->mainStyleSheet->getPagesCSS();
         // Save image assets
         $this->createImageAssets();
     }
     // Save page HTML
     foreach ($pageContents as $page => $contents) {
         $this->savePageHTML($pageContents[$page], $page + 1);
         $this->savePageCSS('', $page + 1);
         $this->progress->incrementStep();
     }
     // Save book CSS
     $this->saveBookCSS("body {margin: 0px; padding: 0px;} \n\n" . implode("\n", $pageCssContents));
     $this->progress->incrementStep();
     $this->setCoverImage();
     $numPages = count($pages);
     $this->importSourceAssets();
     $this->updatePageCount($numPages);
     return true;
 }
Beispiel #2
0
    //                    'page_ref' => '',
    //                    'visible' => 1
    //                );
    //            }
    //
    //
    //
    //
    //        }
    //    }
    //
    //    //var_dump($headlineList);
    //    var_dump($contentStructure);
}
// Get HTML pages
$pages = $converter->getHTMLPages();
foreach ($pages as $key => $page) {
    $pageContents[] = $pages[$key]->getBodyHTML();
    echo $pages[$key]->getBodyHTML();
}
// Get CSS
echo "<style>";
echo $converter->mainStyleSheet->getPagesCSS();
echo "</style>";
$elapsedTime = microtime(true) - $start;
// Save image assets
//$this->createImageAssets();
?>


<p>Time Elapsed to convert this document:<?php