/**
  * @dataProvider getTestDocuments
  */
 public function testCommonConversions($from, $to)
 {
     $tempDir = $this->createTempDir('odt_tests_') . '/';
     $imgDir = $tempDir . 'img';
     mkdir($imgDir);
     $options = new ezcDocumentOdtOptions();
     $options->imageDir = $imgDir;
     $document = new ezcDocumentOdt();
     $document->setFilters(array(new ezcDocumentOdtImageFilter($options), new ezcDocumentOdtElementFilter(), new ezcDocumentOdtStyleFilter()));
     $document->loadFile($from);
     $docbook = $document->getAsDocbook();
     $xml = $docbook->save();
     $xml = $this->verifyAndReplaceImages(basename($to, '.xml'), $xml);
     // Store test file, to have something to compare on failure
     file_put_contents($tempDir . basename($to), $xml);
     $this->assertTrue($docbook->validateString($xml));
     if (!is_file($to)) {
         $this->fail("Missing comparison file '{$to}'.");
     }
     $this->assertEquals(file_get_contents($to), $xml, 'Document not visited as expected.');
     // Remove tempdir, when nothing failed.
     $this->removeTempDir();
 }
Ejemplo n.º 2
0
function fodt2text($filename,$id) {    
    Env::useLibrary('ezcomponents');
    
    $odt = new ezcDocumentOdt();
    $odt->loadFile( $filename );

    $docbook = $odt->getAsDocbook();

    $converter = new ezcDocumentDocbookToRstConverter();
    $rst = $converter->convert( $docbook );
    
    $file_path_txt = 'tmp/fodt2text_' . $id . '.txt';
    file_put_contents( $file_path_txt, $rst );
    $content = file_get_contents($file_path_txt); //Guardamos archivo.txt en $archivo
    unlink($file_path_txt);
    return $content;
}