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 |
|
---|
19 | /**
|
---|
20 | * Creates an example PDF TEST document using TCPDF
|
---|
21 | * @package com.tecnick.tcpdf
|
---|
22 | * @abstract TCPDF - Example: RTL document with Persian language
|
---|
23 | * @author Nicola Asuni
|
---|
24 | * @since 2008-03-06
|
---|
25 | */
|
---|
26 |
|
---|
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
|
---|
41 | $pdf->SetHeaderData(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, PDF_HEADER_TITLE.' 018', PDF_HEADER_STRING);
|
---|
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
|
---|
51 | $pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT);
|
---|
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 />سÙاÙ
|
---|
81 | ؚاÙاخر٠Ù
|
---|
82 | ØŽÚ©Ù PDF ÙØ§Ø±Ø³Û ØšÙ Ø·Ùر کاÙ
|
---|
83 | Ù Ø٠؎د. اÛÙÙ
|
---|
84 | ÛÚ© ÙÙ
|
---|
85 | ÙÙØŽ.<br />Ù
|
---|
86 | ØŽÚ©Ù Øر٠\"Ú\" در ØšØ¹Ø¶Û Ú©ÙÙ
|
---|
87 | ات Ù
|
---|
88 | اÙÙد Ú©ÙÙ
|
---|
89 | Ù ÙÛÚÙ ÙÛز ؚر طر٠؎د.<br />Ùگار؎ ØرÙÙ ÙاÙ
|
---|
90 | ٠اÙ٠ٟ؎ت سر ÙÙ
|
---|
91 | ÙÛز تصØÛØ ØŽØ¯.<br />ؚا ت؎کر از "Asuni Nicola" Ù Ù
|
---|
92 | ØÙ
|
---|
93 | د عÙÛ Ú¯Ù Ú©Ø§Ø± ØšØ±Ø§Û ÙŸØŽØªÛؚاÙÛ Ø²ØšØ§Ù ÙارسÛ.';
|
---|
94 | $pdf->WriteHTML($htmlpersian, true, 0, true, 0);
|
---|
95 |
|
---|
96 | // set LTR direction for english translation
|
---|
97 | $pdf->setRTL(false);
|
---|
98 |
|
---|
99 | $pdf->SetFontSize(10);
|
---|
100 |
|
---|
101 | // print newline
|
---|
102 | $pdf->Ln();
|
---|
103 |
|
---|
104 | // Persian and English content
|
---|
105 | $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>';
|
---|
106 | $pdf->WriteHTML($htmlpersiantranslation, true, 0, true, 0);
|
---|
107 |
|
---|
108 | // Restore RTL direction
|
---|
109 | $pdf->setRTL(true);
|
---|
110 |
|
---|
111 | // set font
|
---|
112 | $pdf->SetFont('aefurat', '', 18);
|
---|
113 |
|
---|
114 | // print newline
|
---|
115 | $pdf->Ln();
|
---|
116 |
|
---|
117 | // Arabic and English content
|
---|
118 | $pdf->Cell(0, 12, 'ØšÙسÙÙ
|
---|
119 | ٠اÙÙÙ٠اÙرÙÙØÙÙ
|
---|
120 | Ù٠اÙرÙÙØÙÙÙ
|
---|
121 | Ù',0,1,'C');
|
---|
122 | $htmlcontent = 'تÙ
|
---|
123 | ÙÙ ØšÙØÙ
|
---|
124 | د اÙÙÙ ØÙÙ Ù
|
---|
125 | ØŽÙÙØ© اÙÙتاؚة ؚاÙÙغة اÙعرؚÙØ© ÙÙ Ù
|
---|
126 | ÙÙات اÙÙ<span color="#FF0000">PDF</span> Ù
|
---|
127 | ع دعÙ
|
---|
128 | اÙÙتاؚة <span color="#0000FF">Ù
|
---|
129 | ٠اÙÙÙ
|
---|
130 | Ù٠إÙ٠اÙÙسار</span> Ù<span color="#009900">اÙØرÙÙات</span> .<br />تÙ
|
---|
131 | اÙØÙ ØšÙاسطة <span color="#993399">صاÙØ Ø§ÙÙ
|
---|
132 | طرÙÙ Ù Asuni Nicola</span> . ';
|
---|
133 | $pdf->WriteHTML($htmlcontent, true, 0, true, 0);
|
---|
134 |
|
---|
135 | // set LTR direction for english translation
|
---|
136 | $pdf->setRTL(false);
|
---|
137 |
|
---|
138 | // print newline
|
---|
139 | $pdf->Ln();
|
---|
140 |
|
---|
141 | $pdf->SetFont('aealarabiya', '', 18);
|
---|
142 |
|
---|
143 | // Arabic and English content
|
---|
144 | $htmlcontent2 = '<span color="#0000ff">This is Arabic "اÙعرؚÙØ©" Example With TCPDF.</span>';
|
---|
145 | $pdf->WriteHTML($htmlcontent2, true, 0, true, 0);
|
---|
146 |
|
---|
147 | // ---------------------------------------------------------
|
---|
148 |
|
---|
149 | //Close and output PDF document
|
---|
150 | $pdf->Output('example_018.pdf', 'I');
|
---|
151 |
|
---|
152 | //============================================================+
|
---|
153 | // END OF FILE
|
---|
154 | //============================================================+
|
---|