PEAR is archived and read-only

This mirror preserves historical PEAR package releases and metadata so existing references remain available.

Home » File Formats » File_PDF » Bug #9595

Font file typos

Details

Submitted2006-12-11 01:14 UTC
Fromatex at php dot net
Assignedyunosh
StatusClosed
PackageFile_PDF
PHP Version5.2.0 RC4
OSLinux
Roadmaps(Not assigned)

Comments

[2006-12-11 01:14 UTC] atex at php dot net

Description:
------------
When trying to use the getStringWidth() method on a string with a ',' (comma) in it, I sometimes get the following error:

Notice: Undefined index: , in /usr/lib/php/File/PDF.php on line 1127

It seems that the ',' character's width cannot be determined.

Test script:
---------------
I have tried to use the following test script:

error_reporting(E_ALL);
require_once 'File/PDF.php';

$options = array('orientation' => 'P',
'unit' => 'pt',
'format' => 'Letter');
$pdf =& File_PDF::factory($options);
$pdf->addPage();
$pdf->aliasNbPages();

$text = 'hello, goodbye, hello again';
$size = $pdf->getStringWidth($text);
$pdf->setFont('Times', NULL, 12);
$pdf->cell($size, 0, $text, 'R', 0, 'L', 0);

$pdf_len = strlen($pdf->getOutput());
header('Cache-Control: no-cache');
header('Pragma: no-cache');
header("Content-Length: " . pdf_len);
$pdf->output('file_pdf_test.pdf', true);

However, I cannot force the error to appear. The problem, however, appears to come from the fact that the ',' entry in the arrays in the php files in the fonts/ directory for many of the fonts are as follows:

',
' => 250,

The line-break and indentation seem to cause the problem as when I rewrite the line as:

',' => 250,

I no longer have any issues.

I have created a patch at the following URL:

http://molior.mcs.suffolk.edu/patches/File_PDF-comma.patch.bz2

Expected result:
----------------
Correct generation of a PDF file.

Actual result:
--------------
Notice: Undefined index: , in /usr/lib/php/File/PDF.php on line 1127