本文整理汇总了PHP中PHPRtfLite::getWriter方法的典型用法代码示例。如果您正苦于以下问题:PHP PHPRtfLite::getWriter方法的具体用法?PHP PHPRtfLite::getWriter怎么用?PHP PHPRtfLite::getWriter使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PHPRtfLite
的用法示例。
在下文中一共展示了PHPRtfLite::getWriter方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testRender
/**
* tests render
*/
public function testRender()
{
$header = new PHPRtfLite_Container_Header($this->_rtf);
$header->writeText('hello world and see my rtf header!');
$header->render();
$this->assertEquals('{\\header {hello world and see my rtf header!}' . "\r\n\\par}\r\n", $this->_rtf->getWriter()->getContent());
}
示例2: testRender
/**
* tests render().
*/
public function testRender()
{
$hyperlink = new PHPRtfLite_Element_Hyperlink($this->_rtf, 'My link text!');
$hyperlink->setHyperlink('http://www.phprtf.com/');
$hyperlink->render();
$expected = '{\\field {\\*\\fldinst {HYPERLINK "http://www.phprtf.com/"}}{\\fldrslt {My link text!}}}';
$this->assertEquals($expected, trim($this->_rtf->getWriter()->getContent()));
}
示例3: testRenderImageUnresized
/**
*
*/
public function testRenderImageUnresized()
{
$source = dirname(__FILE__) . '/../../samples/sources/rtf_thumb.jpg';
if (!is_file($source)) {
$this->markTestSkipped('Source image file could not be found!');
return;
}
$image = PHPRtfLite_Image::createFromFile($this->_rtf, $source);
$image->render();
$expected = self::getRtfThumbHexCode(510, 510);
$this->assertEquals($expected, $this->_rtf->getWriter()->getContent());
}
示例4: render
/**
* renders list
*/
public function render()
{
$stream = $this->_rtf->getWriter();
$number = 0;
foreach ($this->_items as $item) {
// item is a list
if ($item instanceof PHPRtfLite_List_Numbering) {
if ($this instanceof PHPRtfLite_List_Numbering) {
$item->setPrefix($this->_prefix . $this->getNumber($number) . $this->_separator);
$item->setSuffix($this->_suffix);
}
} else {
$number++;
$listCharFontIndex = $this->getListCharFontIndex();
$listCharacter = $this->getListCharacter($number);
$listCharDefinition = '{\\*\\pn\\pnlvlblt' . '\\pnf' . $listCharFontIndex;
if ($this->_font) {
$listCharDefinition .= '\\pnfs' . $this->_font->getSize() * 2;
if ($color = $this->_font->getColor()) {
$listCharDefinition .= '\\pncf' . $this->_rtf->getColorTable()->getColorIndex($color);
}
}
$listCharDefinition .= '\\pnindent0{\\pntxtb ' . $listCharacter . '}}';
$textIndent = $this->_listIndent + $this->_textIndent;
$stream->write('\\nowidctlpar\\fi-' . $this->_listIndent . '\\li' . $textIndent . "\r\n");
$stream->write($listCharDefinition);
}
// renders item
$item->render();
if (false == $item instanceof PHPRtfLite_List) {
$stream->write('\\par\\pard' . "\r\n");
}
}
}
示例5: render
/**
* renders rtf code for cell
*/
public function render()
{
$stream = $this->_rtf->getWriter();
$stream->write("\r\n");
// renders container elements
parent::render();
$containerElements = $this->getElements();
$numOfContainerElements = count($containerElements);
if ($this->_table->isNestedTable()) {
// if last container element is not a nested table, close cell
if ($numOfContainerElements == 0 || !$containerElements[$numOfContainerElements - 1] instanceof PHPRtfLite_Table_Nested) {
$stream->write('{\\nestcell{\\nonesttables\\par}\\pard}' . "\r\n");
// if last cell of row, close row
if ($this->getColumnIndex() == $this->_table->getColumnsCount()) {
$stream->write('{\\*\\nesttableprops ');
$row = $this->_table->getRow($this->_rowIndex);
$this->_table->renderRowDefinition($row);
$stream->write('\\nestrow}');
}
}
} else {
if ($numOfContainerElements > 0 && $containerElements[$numOfContainerElements - 1] instanceof PHPRtfLite_Table_Nested) {
$stream->write('\\intbl\\itap1\\~');
}
// closing tag for cell definition
$stream->write('\\cell');
}
$stream->write("\r\n");
}
示例6: render
/**
* renders rtf code for that container
*
* @return string rtf code
*/
public function render()
{
$stream = $this->_rtf->getWriter();
if ($this instanceof PHPRtfLite_Table_Cell && $this->countElements() == 0) {
$stream->write('{');
$font = $this->getCellFont($this);
if ($font) {
$stream->write($font->getContent());
}
if (!$this->isVerticalMerged() && !$this->isHorizontalMerged() || $this->isVerticalMergedFirstInRange()) {
$stream->write('{\\~}');
}
$stream->write('}\\intbl');
}
$lastKey = $this->countElements() - 1;
foreach ($this->_elements as $key => $element) {
if ($this instanceof PHPRtfLite_Table_Cell && !$element instanceof PHPRtfLite_Table) {
// table cell initialization
$stream->write('\\intbl\\itap' . $this->getTable()->getNestDepth() . "\r\n");
$stream->write($this->getCellAlignment());
}
if ($element instanceof PHPRtfLite_Element_Plain) {
$element->render();
continue;
}
$parFormat = null;
if (!$element instanceof PHPRtfLite_Table) {
$parFormat = $element->getParFormat();
}
if ($parFormat) {
$stream->write($this->_pard);
if ($this instanceof PHPRtfLite_Table_Cell && $lastKey != $key) {
$stream->write('{');
}
$stream->write($parFormat->getContent());
}
$font = $this->getCellFont($element);
if ($font) {
$stream->write($font->getContent());
}
$element->render();
if ($this->needToAddParagraphEnd($key)) {
$stream->write('\\par ');
}
if ($font) {
$stream->write($font->getClosingContent());
}
if ($parFormat && $this instanceof PHPRtfLite_Table_Cell && $lastKey != $key) {
$stream->write('}');
}
}
}
示例7: render
/**
* renders form field
*/
public function render()
{
$stream = $this->_rtf->getWriter();
$stream->write(' ');
if ($this->_font) {
$stream->write('{' . $this->_font->getContent());
}
$defaultValue = PHPRtfLite_Utf8::getUnicodeEntities($this->_defaultValue, $this->_rtf->getCharset());
$content = '{\\field' . '{\\*\\fldinst ' . $this->getType() . ' {\\*\\formfield' . $this->getRtfCode() . '}' . '}{\\fldrslt ' . $defaultValue . '}}';
$stream->write($content);
if ($this->_font) {
$stream->write($this->_font->getClosingContent() . '}');
}
$stream->write(' ');
}
示例8: writeIntoRtfStream
/**
* writes image into rtf stream
*
* @param integer $startFrom
*/
protected function writeIntoRtfStream($startFrom = 0)
{
fseek($this->_stream, $startFrom);
$rtfImageType = $this->getImageTypeAsRtf();
$rtfStream = $this->_rtf->getWriter();
$rtfStream->write('{\\*\\shppict {\\pict');
if ($this->_border) {
$rtfStream->write($this->_border->getContent());
}
$rtfStream->write($rtfImageType . '\\picscalex100\\picscaley100');
$rtfStream->write('\\picwgoal' . $this->getImageRtfWidth());
$rtfStream->write('\\pichgoal' . $this->getImageRtfHeight());
$rtfStream->write(' ');
while (!feof($this->_stream)) {
$stringBuffer = fread($this->_stream, 1024);
$stringHex = bin2hex($stringBuffer);
$rtfStream->write($stringHex);
}
$rtfStream->write('}}');
}
示例9: testRender
/**
* tests render
*/
public function testRender()
{
$footnote = new PHPRtfLite_Footnote($this->_rtf, 'hello rtf world!');
$footnote->render();
$this->assertEquals('\\chftn {\\footnote\\pard\\plain \\lin283\\fi-283 \\fs20 {\\up6\\chftn}' . "\r\n" . 'hello rtf world!} ', $this->_rtf->getWriter()->getContent());
}
示例10: render
/**
* renders footnote/endnote
*/
public function render()
{
$stream = $this->_rtf->getWriter();
$typeSetting = $this->_typeSettingType != self::TYPE_NORMAL ? '\\' . $this->_typeSettingType : '';
$stream->write('{' . $typeSetting . '\\chftn}' . '{' . $this->getTypeAsRtfCode() . '\\pard\\plain\\lin283\\fi-283 ');
if ($this->_parFormat) {
$stream->write($this->_parFormat->getContent());
}
if ($this->_font) {
$stream->write($this->_font->getContent());
}
$stream->write('{\\up6\\chftn}' . "\r\n" . PHPRtfLite::quoteRtfCode($this->_text) . '} ');
}