1 | <?php |
---|
2 | //============================================================+ |
---|
3 | // File name : example_018.php |
---|
4 | // Begin : 2008-03-06 |
---|
5 | // Last Update : 2010-08-08 |
---|
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 s.r.l. |
---|
15 | // Via Della Pace, 11 |
---|
16 | // 09044 Quartucciu (CA) |
---|
17 | // ITALY |
---|
18 | // www.tecnick.com |
---|
19 | // info@tecnick.com |
---|
20 | //============================================================+ |
---|
21 | |
---|
22 | /** |
---|
23 | * Creates an example PDF TEST document using TCPDF |
---|
24 | * @package com.tecnick.tcpdf |
---|
25 | * @abstract TCPDF - Example: RTL document with Persian language |
---|
26 | * @author Nicola Asuni |
---|
27 | * @since 2008-03-06 |
---|
28 | */ |
---|
29 | |
---|
30 | require_once('../config/lang/eng.php'); |
---|
31 | require_once('../tcpdf.php'); |
---|
32 | |
---|
33 | // create new PDF document |
---|
34 | $pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false); |
---|
35 | |
---|
36 | // set document information |
---|
37 | $pdf->SetCreator(PDF_CREATOR); |
---|
38 | $pdf->SetAuthor('Nicola Asuni'); |
---|
39 | $pdf->SetTitle('TCPDF Example 018'); |
---|
40 | $pdf->SetSubject('TCPDF Tutorial'); |
---|
41 | $pdf->SetKeywords('TCPDF, PDF, example, test, guide'); |
---|
42 | |
---|
43 | // set default header data |
---|
44 | $pdf->SetHeaderData(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, PDF_HEADER_TITLE.' 018', PDF_HEADER_STRING); |
---|
45 | |
---|
46 | // set header and footer fonts |
---|
47 | $pdf->setHeaderFont(Array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN)); |
---|
48 | $pdf->setFooterFont(Array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA)); |
---|
49 | |
---|
50 | // set default monospaced font |
---|
51 | $pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED); |
---|
52 | |
---|
53 | //set margins |
---|
54 | $pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT); |
---|
55 | $pdf->SetHeaderMargin(PDF_MARGIN_HEADER); |
---|
56 | $pdf->SetFooterMargin(PDF_MARGIN_FOOTER); |
---|
57 | |
---|
58 | //set auto page breaks |
---|
59 | $pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM); |
---|
60 | |
---|
61 | //set image scale factor |
---|
62 | $pdf->setImageScale(PDF_IMAGE_SCALE_RATIO); |
---|
63 | |
---|
64 | // set some language dependent data: |
---|
65 | $lg = Array(); |
---|
66 | $lg['a_meta_charset'] = 'UTF-8'; |
---|
67 | $lg['a_meta_dir'] = 'rtl'; |
---|
68 | $lg['a_meta_language'] = 'fa'; |
---|
69 | $lg['w_page'] = 'page'; |
---|
70 | |
---|
71 | //set some language-dependent strings |
---|
72 | $pdf->setLanguageArray($lg); |
---|
73 | |
---|
74 | // --------------------------------------------------------- |
---|
75 | |
---|
76 | // set font |
---|
77 | $pdf->SetFont('dejavusans', '', 12); |
---|
78 | |
---|
79 | // add a page |
---|
80 | $pdf->AddPage(); |
---|
81 | |
---|
82 | // Persian and English content |
---|
83 | $htmlpersian = '<span color="#660000">Persian example:</span><br />سÙاÙ
ؚاÙاخر٠Ù
ØŽÚ©Ù PDF ÙØ§Ø±Ø³Û ØšÙ Ø·Ùر کاÙ
Ù Ø٠؎د. اÛÙÙ
ÛÚ© ÙÙ
ÙÙØŽ.<br />Ù
ØŽÚ©Ù Øر٠\"Ú\" در ØšØ¹Ø¶Û Ú©ÙÙ
ات Ù
اÙÙد Ú©ÙÙ
Ù ÙÛÚÙ ÙÛز ؚر طر٠؎د.<br />Ùگار؎ ØرÙÙ ÙاÙ
٠اÙ٠ٟ؎ت سر ÙÙ
ÙÛز تصØÛØ ØŽØ¯.<br />ؚا ت؎کر از "Asuni Nicola" Ù Ù
ØÙ
د عÙÛ Ú¯Ù Ú©Ø§Ø± ØšØ±Ø§Û ÙŸØŽØªÛؚاÙÛ Ø²ØšØ§Ù ÙارسÛ.'; |
---|
84 | $pdf->WriteHTML($htmlpersian, true, 0, true, 0); |
---|
85 | |
---|
86 | // set LTR direction for english translation |
---|
87 | $pdf->setRTL(false); |
---|
88 | |
---|
89 | $pdf->SetFontSize(10); |
---|
90 | |
---|
91 | // print newline |
---|
92 | $pdf->Ln(); |
---|
93 | |
---|
94 | // Persian and English content |
---|
95 | $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>'; |
---|
96 | $pdf->WriteHTML($htmlpersiantranslation, true, 0, true, 0); |
---|
97 | |
---|
98 | // Restore RTL direction |
---|
99 | $pdf->setRTL(true); |
---|
100 | |
---|
101 | // set font size |
---|
102 | $pdf->SetFont('almohanad', '', 18); |
---|
103 | |
---|
104 | // print newline |
---|
105 | $pdf->Ln(); |
---|
106 | |
---|
107 | // Arabic and English content |
---|
108 | $pdf->Cell(0, 12, 'ØšÙسÙÙ
٠اÙÙÙ٠اÙرÙÙØÙÙ
Ù٠اÙرÙÙØÙÙÙ
Ù',0,1,'C'); |
---|
109 | $htmlcontent = 'تÙ
ÙÙ ØšÙØÙ
د اÙÙÙ ØÙÙ Ù
ØŽÙÙØ© اÙÙتاؚة ؚاÙÙغة اÙعرؚÙØ© ÙÙ Ù
ÙÙات اÙÙ<span color="#FF0000">PDF</span> Ù
ع دعÙ
اÙÙتاؚة <span color="#0000FF">Ù
٠اÙÙÙ
Ù٠إÙ٠اÙÙسار</span> Ù<span color="#009900">اÙØرÙÙات</span> .<br />تÙ
اÙØÙ ØšÙاسطة <span color="#993399">صاÙØ Ø§ÙÙ
طرÙÙ Ù Asuni Nicola</span> . '; |
---|
110 | $pdf->WriteHTML($htmlcontent, true, 0, true, 0); |
---|
111 | |
---|
112 | // set LTR direction for english translation |
---|
113 | $pdf->setRTL(false); |
---|
114 | |
---|
115 | // set font size |
---|
116 | $pdf->SetFontSize(18); |
---|
117 | |
---|
118 | // print newline |
---|
119 | $pdf->Ln(); |
---|
120 | |
---|
121 | // Arabic and English content |
---|
122 | $htmlcontent2 = '<span color="#0000ff">This is Arabic "اÙعرؚÙØ©" Example With TCPDF.</span>'; |
---|
123 | $pdf->WriteHTML($htmlcontent2, true, 0, true, 0); |
---|
124 | |
---|
125 | // --------------------------------------------------------- |
---|
126 | |
---|
127 | //Close and output PDF document |
---|
128 | $pdf->Output('example_018.pdf', 'I'); |
---|
129 | |
---|
130 | //============================================================+ |
---|
131 | // END OF FILE |
---|
132 | //============================================================+ |
---|