source: trunk/client/inc/hpdf5/tecnickcom/tcpdf/examples/example_018.php

Last change on this file was 347, checked in by roby, 4 years ago

Aggiornamento per compatibilità con php7.4

File size: 4.6 KB
Line 
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).
28require_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//============================================================+
Note: See TracBrowser for help on using the repository browser.