Пример #1
0
<?php

require __DIR__ . "/../vendor/autoload.php";
$document = new Rtfparser();
$document->parse(file_get_contents(__DIR__ . "/sample.rtf"));
file_put_contents(__DIR__ . "/sample_dump.html", $document->root->dumpHtml());
$writer = new RtfHtml();
file_put_contents(__DIR__ . "/sample.html", $writer->Format($document->root));
Пример #2
0
function leerdoc($documento)
{
    //require('fpdf/fpdf.php');
    require_once 'rtf2html.php';
    require_once 'aux_pdf.php';
    $reader = new RtfReader();
    $rtf = file_get_contents("{$documento}");
    // or use a string
    $reader->Parse($rtf);
    $formatter = new RtfHtml();
    $pdf = new PDF_HTML();
    $pdf->SetFont('Arial', '', 12);
    $pdf->AddPage();
    $text = $formatter->Format($reader->root);
    if (ini_get('magic_quotes_gpc') == '1') {
        $text = stripslashes($text);
    }
    $pdf->WriteHTML($text);
    $pdf->Output();
    exit;
}
Пример #3
0
    protected function EndState()
    {
        $this->output .= "</span>";
    }
    protected function FormatControlSymbol($symbol)
    {
        if ($symbol->symbol == '\'') {
            $this->BeginState();
            $this->output .= htmlentities(chr($symbol->parameter), ENT_QUOTES, 'ISO-8859-1');
            $this->EndState();
        }
    }
    protected function FormatText($text)
    {
        $this->BeginState();
        $this->output .= $text->text;
        $this->EndState();
    }
}
if (__FILE__ === realpath($_SERVER['SCRIPT_NAME']) && php_sapi_name() === 'cli') {
    if (isset($_SERVER['argv'][1]) && $_SERVER['argv'][1] !== '-') {
        $file = $_SERVER['argv'][1];
    } else {
        $file = 'php://stdin';
    }
    $reader = new RtfReader();
    $rtf = file_get_contents($file);
    $reader->Parse($rtf);
    $formatter = new RtfHtml();
    echo $formatter->Format($reader->root);
}