PHP code example of biztecheg / easy-pdf-word
1. Go to this page and download the library: Download biztecheg/easy-pdf-word library . Choose the download type require .
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
biztecheg / easy-pdf-word example snippets
use BiztechEG\EasyPdfWord\EasyPdfWord;
$docs = EasyPdfWord::create([
'locale' => 'ar',
'theme' => ['company' => ['name' => 'شركة بيزتك', 'tax_number' => '123-456-789']],
]);
$docs = EasyPdfWord::create([
'images' => ['paths' => [__DIR__.'/images']],
'theme' => ['logo' => __DIR__.'/images/logo.png'],
]);
$invoice = $docs->template('invoice', [
'invoice' => ['number' => 'INV-1024', 'date' => '2026-10-08', 'currency' => 'EGP', 'tax_rate' => 14],
'seller' => ['name' => 'شركة بيزتك', 'tax_number' => '123-456-789'],
'buyer' => ['name' => 'مؤسسة النور'],
'items' => [
['description' => 'تطوير نظام', 'quantity' => 1, 'unit_price' => 25000],
],
]);
$invoice->pdf()->save(__DIR__.'/invoice.pdf');
$invoice->word()->save(__DIR__.'/invoice.docx');
// Or send it to the browser
$invoice->pdf('INV-1024.pdf')->send(inline: true);
$docs->make()
->locale('ar')
->heading('تقرير المبيعات')
->paragraph('إجمالي المبيعات لشهر أكتوبر.')
->table([['البند', 'القيمة'], ['المبيعات', '120,000']], ['header' => true])
->pdf()
->save(__DIR__.'/report.pdf');
$docs->make()->locale('ar')->paragraph([
['text' => 'السعر شامل الضريبة ', 'bold' => true],
['text' => '12,000', 'strike' => true, 'color' => 'gray'],
['text' => ' 10,000 ريال', 'background' => '#FEF3C7'],
['text' => ' — التفاصيل على '],
['text' => 'موقعنا', 'link' => 'https://biztech.example/offers'],
]);
$docs->make()->locale('ar')->list([
'الأسعار لا تشمل ضريبة القيمة المضافة.',
'يسري العرض 30 يوماً.',
['التسليم في:', ['الموقع أ', 'الموقع ب']],
], ['ordered' => true]);
use BiztechEG\EasyPdfWord\Builder\DocumentBuilder as B;
$docs->make()->locale('ar')->table([
['البند', 'الكمية', 'الإجمالي'],
B::row([['text' => 'أعمال مدنية', 'colspan' => 3]], ['style' => ['bold' => true, 'background' => '#F1F5F9'], 'keep_with_next' => true]),
['حفر', '120', '10,200.00'],
B::row([['text' => 'المجموع', 'colspan' => 2], '10,200.00'], ['total' => true]),
], ['header' => true]);
[['lines' => ['مدير المبيعات', '', 'عمرو محمد'], 'overlay' => ['image' => $stamp, 'width' => 35, 'offset' => [5, 2]]]]
$docs->make()->locale('ar')->table([
['القسم', 'البند', 'الإجمالي'],
[['text' => 'أعمال مدنية', 'rowspan' => 2, 'valign' => 'middle'], 'حفر', '10,200.00'],
['ردم', '4,000.00'],
], ['header' => true, 'borders' => 'grid', 'padding' => 3]);
$this->assertStringContainsString("الإجمالي\t33,580.00", $docs->template('quotation', $data)->text());
use BiztechEG\EasyPdfWord\Builder\DocumentBuilder;
$docs->make()->locale('ar')
->header(fn (DocumentBuilder $h) => $h->table(
[[['image' => __DIR__.'/images/logo.png', 'width' => 30], ['lines' => ['شركة بيزتك', 'الدقي، الجيزة']]]],
['borders' => false, 'columns' => [30, 70]],
))
->footer(fn (DocumentBuilder $f) => $f->paragraph('صفحة {page} من {pages}', ['align' => 'center', 'size' => 8]))
->firstPageHeader(fn (DocumentBuilder $h) => $h->table($fullLetterhead, ['borders' => false]))
->firstPageFooter(null) // no footer on page 1
->headerDistance(6); // mm from the top of the page
$docs->template('quotation', $data)->watermarkImage(__DIR__.'/images/draft.png', ['opacity' => 0.15, 'width' => 140])->word();
$docs->html('<h1>مرحباً</h1>')->locale('ar')->pdf()->save(__DIR__.'/hello.pdf');
// views/contracts/show.html.php, with 'views' => ['paths' => [__DIR__.'/views']]
$docs->view('contracts.show', ['contract' => $contract])->pdf();
$docs->make()->locale('ar')
->richText($offer->preamble)
->table($rows, ['header' => true])
->richText($offer->terms, ['font_size' => 10])
->pdf();
use BiztechEG\EasyPdfWord\Support\HtmlSanitizer;
$clean = (new HtmlSanitizer)->sanitize($request['terms']);
$docs = EasyPdfWord::create(['templates' => ['paths' => [__DIR__.'/doc-templates']]]);
$docs->template('invoice', $data)->locale('tr')->pdf(); // Fatura, 08.10.2026, 1.250,50, KDV (%20)
use BiztechEG\EasyPdfWord\Support\Language;
Language::addPath(__DIR__.'/lang'); // lang/fr.json; keys left out come from English
use BiztechEG\EasyPdfWord\Arabic\Arabic;
Arabic::tafqeet(1250.5, 'EGP'); // ألف ومائتان وخمسون جنيهاً وخمسون قرشاً
Arabic::hijri('2026-10-08'); // ٢٧ ربيع الآخر ١٤٤٨ هـ
Arabic::numerals('INV-2026'); // INV-٢٠٢٦
$docs = EasyPdfWord::create(['fonts' => ['custom' => [
'my-font' => ['regular' => __DIR__.'/fonts/MyFont-Regular.ttf', 'bold' => __DIR__.'/fonts/MyFont-Bold.ttf', 'arabic' => true],
]]]);
$docs->template('letter', $data)->font('my-font')->pdf();
$docs = EasyPdfWord::create(['temp_dir' => __DIR__.'/storage/tmp']);
use BiztechEG\EasyPdfWord\EasyPdfWord;
$docs = EasyPdfWord::create(['locale' => 'ar']);
$docs->template('invoice', $data)->pdf()->save(__DIR__.'/invoice.pdf');
$docs->template('invoice', $data)->word()->save(__DIR__.'/invoice.docx');