PHPRtfLite::render PHP Метод

render() защищенный Метод

prepares rtf contents
protected render ( )
    protected function render()
    {
        $this->_writer->open();
        $defaultFontSize = 20;
        $defaultFontIndex = 0;
        if ($this->_defaultFont) {
            $defaultFontIndex = $this->getFontTable()->getFontIndex($this->_defaultFont->getFontFamily());
            $defaultFontSize = $this->_defaultFont->getSize() * 2;
        }
        $this->_writer->write('{\\rtf\\ansi\\deff' . $defaultFontIndex . '\\fs' . $defaultFontSize . "\r\n");
        $this->_writer->write($this->getFontTable()->getContent());
        $this->_writer->write($this->getColorTable()->getContent());
        $this->_writer->write($this->getInfoPart());
        $paperWidth = $this->_paperWidth;
        $paperHeight = $this->_paperHeight;
        // page properties
        if ($this->_isLandscape) {
            $this->_writer->write('\\landscape ');
            if ($paperWidth < $paperHeight) {
                $tmp = $paperHeight;
                $paperHeight = $paperWidth;
                $paperWidth = $tmp;
            }
        }
        $this->_writer->write('\\paperw' . PHPRtfLite_Unit::getUnitInTwips($paperWidth) . ' ');
        $this->_writer->write('\\paperh' . PHPRtfLite_Unit::getUnitInTwips($paperHeight) . ' ');
        // hyphenation
        if ($this->_isHyphenation) {
            $this->_writer->write('\\hyphauto1');
        }
        $this->_writer->write('\\deftab' . PHPRtfLite_Unit::getUnitInTwips($this->_defaultTabWidth) . ' ');
        $this->_writer->write('\\margl' . PHPRtfLite_Unit::getUnitInTwips($this->_marginLeft) . ' ');
        $this->_writer->write('\\margr' . PHPRtfLite_Unit::getUnitInTwips($this->_marginRight) . ' ');
        $this->_writer->write('\\margt' . PHPRtfLite_Unit::getUnitInTwips($this->_marginTop) . ' ');
        $this->_writer->write('\\margb' . PHPRtfLite_Unit::getUnitInTwips($this->_marginBottom) . ' ');
        if (null !== $this->_gutter) {
            $this->_writer->write('\\gutter' . PHPRtfLite_Unit::getUnitInTwips($this->_gutter) . ' ');
        }
        if (true == $this->_useMirrorMargins) {
            $this->_writer->write('\\margmirror ');
        }
        if (null !== $this->_viewMode) {
            $this->_writer->write('\\viewkind' . $this->_viewMode . ' ');
        }
        if (null !== $this->_zoomMode) {
            $this->_writer->write('\\viewzk' . $this->_zoomMode . ' ');
        }
        if (null !== $this->_zoomLevel) {
            $this->_writer->write('\\viewscale' . $this->_zoomLevel . ' ');
        }
        // page numbering start
        $this->_writer->write('\\pgnstart' . $this->_pageNumberStart);
        // headers and footers properties
        if ($this->_useOddEvenDifferent) {
            $this->_writer->write('\\facingp ');
        }
        if ($this->_titlepg) {
            $this->_writer->write('\\titlepg ');
        }
        // document header definition for footnotes and endnotes
        $this->_writer->write($this->getNoteDocHead()->getContent());
        // default font
        if ($this->_defaultFont) {
            $this->_writer->write($this->_defaultFont->getContent());
        }
        // headers and footers if there are no sections
        if (count($this->_sections) == 0) {
            foreach ($this->_headers as $header) {
                $header->render();
            }
            foreach ($this->_footers as $footer) {
                $footer->render();
            }
        }
        // sections
        foreach ($this->_sections as $key => $section) {
            if ($key != 0) {
                $this->_writer->write('\\sect\\sectd ');
            }
            $section->render();
        }
        $this->_writer->write('}');
        $this->_writer->close();
    }