forked from PHPOffice/PHPWord
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Sample_43_RTLDefault.php
33 lines (28 loc) · 1.18 KB
/
Sample_43_RTLDefault.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
<?php
include_once 'Sample_Header.php';
use PhpOffice\PhpWord\PhpWord;
use PhpOffice\PhpWord\Settings;
use PhpOffice\PhpWord\Shared\Html as SharedHtml;
// Suggested by issue 2427.
echo date('H:i:s'), ' Create new PhpWord object', EOL;
$phpWord = new PhpWord();
Settings::setDefaultRtl(true);
$phpWord->setDefaultFontName('DejaVu Sans'); // for good rendition of PDF
$rendererName = Settings::PDF_RENDERER_MPDF;
$rendererLibraryPath = $vendorDirPath . '/mpdf/mpdf';
Settings::setPdfRenderer($rendererName, $rendererLibraryPath);
// New section
$section = $phpWord->addSection();
$arabic = '<p> الألم الذي ربما تنجم عنه بعض ا.</p>';
$english = '<p style="text-align: left; direction: ltr; font-family: DejaVu Sans, sans-serif;">LTR in RTL document.</p>';
SharedHtml::addHtml($section, $arabic, false, false);
SharedHtml::addHtml($section, $english, false, false);
SharedHtml::addHtml($section, $english, false, false);
SharedHtml::addHtml($section, $arabic, false, false);
SharedHtml::addHtml($section, $arabic, false, false);
// Save file
echo write($phpWord, basename(__FILE__, '.php'), $writers);
if (!CLI) {
include_once 'Sample_Footer.php';
}
Settings::setDefaultRtl(false);