Sample 36 RTL

03:20:36 Create new PhpWord object
03:20:36 Write to Word2007 format
03:20:36 Write to ODText format
03:20:36 Write to RTF format
03:20:36 Write to HTML format
03:20:36 Write to PDF format
03:20:36 Done writing file(s)
03:20:36 Peak memory usage: 2 MB

 

Results: docx odt rtf html pdf


<?php
include_once 'Sample_Header.php';

// New Word document
echo date('H:i:s'), ' Create new PhpWord object'EOL;
$phpWord = new \PhpOffice\PhpWord\PhpWord();

// New section
$section $phpWord->addSection();

$textrun $section->addTextRun();
$textrun->addText('This is a Left to Right paragraph.');

$textrun $section->addTextRun(array('alignment' => \PhpOffice\PhpWord\SimpleType\Jc::END));
$textrun->addText('سلام این یک پاراگراف راست به چپ است', array('rtl' => true));

// Save file
echo write($phpWordbasename(__FILE__'.php'), $writers);
if (!
CLI) {
    include_once 
'Sample_Footer.php';
}