PHPRtfLite::sendRtf PHP Метод

sendRtf() публичный Метод

sends rtf content as file attachment
public sendRtf ( string $filename = 'simple', $free = true )
$filename string
    public function sendRtf($filename = 'simple', $free = true)
    {
        $pathInfo = pathinfo($filename);
        if (empty($pathInfo['extension'])) {
            $filename .= '.rtf';
        }
        if (false !== strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE 5.5')) {
            header('Content-Disposition: filename="' . $filename . '"');
        } else {
            header('Content-Disposition: attachment; filename="' . $filename . '"');
        }
        header('Content-type: application/msword');
        header('Expires: 0');
        header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
        header('Pragma: public');
        $this->createWriter();
        $this->render();
        if ($free) {
            $this->free();
        }
        echo $this->_writer->getContent();
    }

Usage Example

Пример #1
0
        $formatH2->setSpaceAfter(6);
        $formatP = new PHPRtfLite_ParFormat();
        $formatP->setSpaceAfter(3);
        // Содержание страницы
        $section = $rtf->addSection();
        $section->writeText('Used Cars for Sale', $fontH1, $formatH1);
        while ($row = getRow($result)) {
            $section->writeText($row['make'], $fontH2, $formatH2);
            $section->setNoBreak();
            $section->writeText('<bullet> Price: $' . number_format($row['price'], 2), $fontP, $formatP);
            $section->writeText('<bullet> Mileage: ' . number_format($row['mileage']), $fontP, $formatP);
            $section->writeText('<bullet> Transmission: ' . $row['transmission'], $fontP, $formatP);
            $section->writeText($row['description'] . '<hr>', $fontP, $formatP);
        }
        // Выходной файл
        $rtf->sendRtf('cars.rtf');
    } catch (Exception $e) {
        $error = $e->getMessage();
    }
}
?>
<!doctype html>
<html>
<head>
  <meta charset="utf-8">
  <title>Used Cars</title>
  <link href="styles/styles.css" rel="stylesheet" type="text/css">
</head>

<body>
<div id="wrapper">
All Usage Examples Of PHPRtfLite::sendRtf