ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
example_018.php
Go to the documentation of this file.
1 <?php
2 //============================================================+
3 // File name : example_018.php
4 // Begin : 2008-03-06
5 // Last Update : 2013-05-14
6 //
7 // Description : Example 018 for TCPDF class
8 // RTL document with Persian language
9 //
10 // Author: Nicola Asuni
11 //
12 // (c) Copyright:
13 // Nicola Asuni
14 // Tecnick.com LTD
15 // www.tecnick.com
16 // info@tecnick.com
17 //============================================================+
18 
27 // Include the main TCPDF library (search for installation path).
28 require_once('tcpdf_include.php');
29 
30 // create new PDF document
31 $pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);
32 
33 // set document information
34 $pdf->SetCreator(PDF_CREATOR);
35 $pdf->SetAuthor('Nicola Asuni');
36 $pdf->SetTitle('TCPDF Example 018');
37 $pdf->SetSubject('TCPDF Tutorial');
38 $pdf->SetKeywords('TCPDF, PDF, example, test, guide');
39 
40 // set default header data
42 
43 // set header and footer fonts
44 $pdf->setHeaderFont(Array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN));
45 $pdf->setFooterFont(Array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA));
46 
47 // set default monospaced font
48 $pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);
49 
50 // set margins
52 $pdf->SetHeaderMargin(PDF_MARGIN_HEADER);
53 $pdf->SetFooterMargin(PDF_MARGIN_FOOTER);
54 
55 // set auto page breaks
56 $pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM);
57 
58 // set image scale factor
59 $pdf->setImageScale(PDF_IMAGE_SCALE_RATIO);
60 
61 // set some language dependent data:
62 $lg = Array();
63 $lg['a_meta_charset'] = 'UTF-8';
64 $lg['a_meta_dir'] = 'rtl';
65 $lg['a_meta_language'] = 'fa';
66 $lg['w_page'] = 'page';
67 
68 // set some language-dependent strings (optional)
69 $pdf->setLanguageArray($lg);
70 
71 // ---------------------------------------------------------
72 
73 // set font
74 $pdf->SetFont('dejavusans', '', 12);
75 
76 // add a page
77 $pdf->AddPage();
78 
79 // Persian and English content
80 $htmlpersian = '<span color="#660000">Persian example:</span><br />سلام بالاخره مشکل PDF فارسی به طور کامل حل شد. اینم یک نمونش.<br />مشکل حرف \"ژ\" در بعضی کلمات مانند کلمه ویژه نیز بر طرف شد.<br />نگارش حروف لام و الف پشت سر هم نیز تصحیح شد.<br />با تشکر از "Asuni Nicola" و محمد علی گل کار برای پشتیبانی زبان فارسی.';
81 $pdf->WriteHTML($htmlpersian, true, 0, true, 0);
82 
83 // set LTR direction for english translation
84 $pdf->setRTL(false);
85 
86 $pdf->SetFontSize(10);
87 
88 // print newline
89 $pdf->Ln();
90 
91 // Persian and English content
92 $htmlpersiantranslation = '<span color="#0000ff">Hi, At last Problem of Persian PDF Solved completely. This is a example for it.<br />Problem of "jeh" letter in some word like "ویژه" (=special) fix too.<br />The joining of laa and alf letter fix now.<br />Special thanks to "Nicola Asuni" and "Mohamad Ali Golkar" for Persian support.</span>';
93 $pdf->WriteHTML($htmlpersiantranslation, true, 0, true, 0);
94 
95 // Restore RTL direction
96 $pdf->setRTL(true);
97 
98 // set font
99 $pdf->SetFont('aefurat', '', 18);
100 
101 // print newline
102 $pdf->Ln();
103 
104 // Arabic and English content
105 $pdf->Cell(0, 12, 'بِسْمِ اللهِ الرَّحْمنِ الرَّحِيمِ',0,1,'C');
106 $htmlcontent = 'تمَّ بِحمد الله حلّ مشكلة الكتابة باللغة العربية في ملفات الـ<span color="#FF0000">PDF</span> مع دعم الكتابة <span color="#0000FF">من اليمين إلى اليسار</span> و<span color="#009900">الحركَات</span> .<br />تم الحل بواسطة <span color="#993399">صالح المطرفي و Asuni Nicola</span> . ';
107 $pdf->WriteHTML($htmlcontent, true, 0, true, 0);
108 
109 // set LTR direction for english translation
110 $pdf->setRTL(false);
111 
112 // print newline
113 $pdf->Ln();
114 
115 $pdf->SetFont('aealarabiya', '', 18);
116 
117 // Arabic and English content
118 $htmlcontent2 = '<span color="#0000ff">This is Arabic "العربية" Example With TCPDF.</span>';
119 $pdf->WriteHTML($htmlcontent2, true, 0, true, 0);
120 
121 // ---------------------------------------------------------
122 
123 //Close and output PDF document
124 $pdf->Output('example_018.pdf', 'I');
125 
126 //============================================================+
127 // END OF FILE
128 //============================================================+
const PDF_MARGIN_BOTTOM
Bottom margin.
const PDF_MARGIN_LEFT
Left margin.
$pdf
Definition: example_018.php:31
$lg
Definition: example_018.php:62
const PDF_MARGIN_HEADER
Header margin.
$htmlcontent2
const PDF_HEADER_STRING
Header description string.
const PDF_FONT_SIZE_MAIN
Default main font size.
const PDF_FONT_SIZE_DATA
Default data font size.
const PDF_FONT_NAME_MAIN
Default main font name.
$htmlcontent
PHP class for generating PDF documents without requiring external extensions.
Definition: tcpdf.php:134
const PDF_HEADER_LOGO_WIDTH
Header logo image width in user units.
const PDF_HEADER_LOGO
Deafult image logo used be the default Header() method.
const PDF_UNIT
Document unit of measure [pt=point, mm=millimeter, cm=centimeter, in=inch].
const PDF_IMAGE_SCALE_RATIO
Ratio used to adjust the conversion of pixels to user units.
const PDF_PAGE_ORIENTATION
Page orientation (P=portrait, L=landscape).
$htmlpersiantranslation
Definition: example_018.php:92
const PDF_MARGIN_RIGHT
Right margin.
const PDF_HEADER_TITLE
Header title.
const PDF_FONT_NAME_DATA
Default data font name.
const PDF_CREATOR
Document creator.
const PDF_PAGE_FORMAT
Page format.
const PDF_FONT_MONOSPACED
Default monospaced font name.
$htmlpersian
Definition: example_018.php:80
const PDF_MARGIN_TOP
Top margin.
const PDF_MARGIN_FOOTER
Footer margin.