source: sipes/libraries/tcpdf/examples/example_018.php

stableversion-3.0
Last change on this file was 307d09d, checked in by José Gregorio Puentes <jpuentes@…>, 8 años ago

se agregaron las librerias

  • Propiedad mode establecida a 100755
File size: 4.7 KB
Línea 
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
30require_once('../config/lang/eng.php');
31require_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//============================================================+
Nota: Vea TracBrowser para ayuda de uso del navegador del repositorio.