Subversion Repositories Applications.annuaire

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
296 aurelien 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
 * @copyright 2004-2009 Nicola Asuni - Tecnick.com S.r.l (www.tecnick.com) Via Della Pace, 11 - 09044 - Quartucciu (CA) - ITALY - www.tecnick.com - info@tecnick.com
28
 * @link http://tcpdf.org
29
 * @license http://www.gnu.org/copyleft/lesser.html LGPL
30
 * @since 2008-03-06
31
 */
32
 
33
require_once('../config/lang/eng.php');
34
require_once('../tcpdf.php');
35
 
36
// create new PDF document
37
$pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);
38
 
39
// set document information
40
$pdf->SetCreator(PDF_CREATOR);
41
$pdf->SetAuthor('Nicola Asuni');
42
$pdf->SetTitle('TCPDF Example 018');
43
$pdf->SetSubject('TCPDF Tutorial');
44
$pdf->SetKeywords('TCPDF, PDF, example, test, guide');
45
 
46
// set default header data
47
$pdf->SetHeaderData(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, PDF_HEADER_TITLE.' 018', PDF_HEADER_STRING);
48
 
49
// set header and footer fonts
50
$pdf->setHeaderFont(Array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN));
51
$pdf->setFooterFont(Array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA));
52
 
53
// set default monospaced font
54
$pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);
55
 
56
//set margins
57
$pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT);
58
$pdf->SetHeaderMargin(PDF_MARGIN_HEADER);
59
$pdf->SetFooterMargin(PDF_MARGIN_FOOTER);
60
 
61
//set auto page breaks
62
$pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM);
63
 
64
//set image scale factor
65
$pdf->setImageScale(PDF_IMAGE_SCALE_RATIO);
66
 
67
// set some language dependent data:
68
$lg = Array();
69
$lg['a_meta_charset'] = 'UTF-8';
70
$lg['a_meta_dir'] = 'rtl';
71
$lg['a_meta_language'] = 'fa';
72
$lg['w_page'] = 'page';
73
 
74
//set some language-dependent strings
75
$pdf->setLanguageArray($lg);
76
 
77
// ---------------------------------------------------------
78
 
79
// set font
80
$pdf->SetFont('dejavusans', '', 12);
81
 
82
// add a page
83
$pdf->AddPage();
84
 
85
// Persian and English content
86
$htmlpersian = '<span color="#660000">Persian example:</span><br />سلام بالاخره مشکل PDF فارسی به طور کامل حل شد. اینم یک نمونش.<br />مشکل حرف \"ژ\" در بعضی کلمات مانند کلمه ویژه نیز بر طرف شد.<br />نگارش حروف لام و الف پشت سر هم نیز تصحیح شد.<br />با تشکر از  "Asuni Nicola" و محمد علی گل کار برای پشتیبانی زبان فارسی.';
87
$pdf->WriteHTML($htmlpersian, true, 0, true, 0);
88
 
89
// set LTR direction for english translation
90
$pdf->setRTL(false);
91
 
92
$pdf->SetFontSize(10);
93
 
94
// print newline
95
$pdf->Ln();
96
 
97
// Persian and English content
98
$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>';
99
$pdf->WriteHTML($htmlpersiantranslation, true, 0, true, 0);
100
 
101
// Restore RTL direction
102
$pdf->setRTL(true);
103
 
104
// set font size
105
$pdf->SetFont('almohanad', '', 18);
106
 
107
// print newline
108
$pdf->Ln();
109
 
110
// Arabic and English content
111
$pdf->Cell(0, 12, 'بِسْمِ اللهِ الرَّحْمنِ الرَّحِيمِ',0,1,'C');
112
$htmlcontent = 'تمَّ بِحمد الله حلّ مشكلة الكتابة باللغة العربية في ملفات الـ<span color="#FF0000">PDF</span> مع دعم الكتابة <span color="#0000FF">من اليمين إلى اليسار</span> و<span color="#009900">الحركَات</span> .<br />تم الحل بواسطة <span color="#993399">صالح المطرفي و Asuni Nicola</span>  . ';
113
$pdf->WriteHTML($htmlcontent, true, 0, true, 0);
114
 
115
// set LTR direction for english translation
116
$pdf->setRTL(false);
117
 
118
// set font size
119
$pdf->SetFontSize(18);
120
 
121
// print newline
122
$pdf->Ln();
123
 
124
// Arabic and English content
125
$htmlcontent2 = '<span color="#0000ff">This is Arabic "العربية" Example With TCPDF.</span>';
126
$pdf->WriteHTML($htmlcontent2, true, 0, true, 0);
127
 
128
// ---------------------------------------------------------
129
 
130
//Close and output PDF document
131
$pdf->Output('example_018.pdf', 'I');
132
 
133
//============================================================+
134
// END OF FILE
135
//============================================================+