PHP Classes

File: pdf_example/pdf_multiline_example.php

Recommend this page to a friend!
  Classes of Khaled Al-Shamaa   ArGlyphs   pdf_example/pdf_multiline_example.php   Download  
File: pdf_example/pdf_multiline_example.php
Role: Example script
Content type: text/plain
Description: Example script
Class: ArGlyphs
Convert Arabic text to Unicode for rendering
Author: By
Last change: Example show how to use new method in this class to get Arabic text with correct right alignment (Note, to download full set of examples please go to: http://www.ar-php.com/php/arabic/index.html#ArGlyphs)
Date: 16 years ago
Size: 819 bytes
 

Contents

Class file image Download
<?php
@ini_set('zend.ze1_compatibility_mode', '1');

define('FPDF_FONTPATH', 'font/');
include_once(
'ufpdf.php');

$pdf = new UFPDF();
$pdf->Open();
$pdf->SetTitle('UFPDF is Cool.');
$pdf->SetAuthor('Khaled Al-Shamaa');

$pdf->AddFont('ae_AlHor', '', 'ae_AlHor.php');

$pdf->AddPage();

require(
'ArGlyphs.class.php');
$ArabicPDF = new ArGlyphs();

$filename = 'ajax.txt';
$handle = fopen($filename, 'r');
$text = fread($handle, filesize($filename));
fclose($handle);

$font_size = 16;
$chars_in_line = $ArabicPDF->a4_max_chars($font_size);
$total_lines = $ArabicPDF->a4_lines($text, $font_size);
$text = $ArabicPDF->convert($text, $chars_in_line);

$pdf->SetFont('ae_AlHor', '', $font_size);
$pdf->MultiCell(0, $total_lines, $text, 0, 'R', 0);

$pdf->Close();
$pdf->Output();
?>