Project

General

Profile

Arial font, utf-8 and empty cells

Added by Alonso Uribe over 10 years ago

Hello, thank you very much for your bookstore is helpful. I have doubts not yet resolved.

I want to change the font arial bold, I do it with the following code $this->pdf->AddFont('Arial', '', 'arial.ttf', true);

To use a cell used in the code $addRow[0]['TEXT_TYPE'] = 'B'; But when generating the pdf, accents do not apply (utf-8) .

example: image1.png

Necessarily I have to print a pdf and when there is no record, cells appear to me as follows, example: image2.png

thank you very much =)


Replies (4)

RE: Arial font, utf-8 and empty cells - Added by Andrei Bintintan over 10 years ago

Which version are you using?

  1. This seems like a configuration problem.

Did you loaded the "bold" Arial font as well? $this->pdf->AddFont('Arial', '', 'arial.ttf', true) --> doesn't load the "bold" by default.

Normally you should have:

$pdf->AddFont('Arial', 'B', 'arialbd.ttf', true);
$table->setStyle("B","arial","B",10,"0,151,200");

  1. If cells are empty, the cell should use by default an empty space(" "). Indeed might be a bug. for 2 please provide an example.

Andrei.

RE: Arial font, utf-8 and empty cells - Added by Alonso Uribe over 10 years ago

Which version are you using? tfpdf table 4.2.0 - How can get my license? I need to update the library.

  1. This code $pdf->AddFont('Arial', 'B', 'arialbd.ttf', true), It works perfectly.

  2. this is an example:

$data = array(
0=> array('field1'=>' ', 'field2'=>' ','field3'=>''),
1=> array('field1'=>' ', 'field2'=>' ','field3'=>''),
2=> array('field1'=>' ', 'field2'=>' ','field3'=>''),
3=> array('field1'=>' ', 'field2'=>' ','field3'=>''),
4=> array('field1'=>' ', 'field2'=>' ','field3'=>''),
5=> array('field1'=>' ', 'field2'=>' ','field3'=>'')
);

$columns = array(
array('TEXT'=>'COLUMN 1'),
array('TEXT'=>'COLUMN 2'),
array('TEXT'=>'COLUMN 3')
);

$this->pdf = new PDF('L', 'mm', 'Legal');
$this->pdf->Open();
$this->pdf->AddPage();

$oTable = new TfpdfTable($this->pdf);
$oTable->initialize(array(50, 50, 50));
$oTable->addHeader($columns);

foreach($data as $row)
{
$addRow = array();
$addRow[0]['TEXT'] = $row['field1'];
$addRow[1]['TEXT'] = $row['field2'];
$addRow[2]['TEXT'] = $row['field3'];
$oTable->addRow($addRow);
}
$oTable->close();

$this->pdf->Output('test.pdf', 'I');

RE: Arial font, utf-8 and empty cells - Added by Andrei Bintintan over 10 years ago

Problem #2 seems a bug. Can you put a space(" ") where you have empty strings?

Or do the following in the tfpdftable.php
in function _addDataToCache add this:

//if string is empty, add a default "space"
if (0 == strlen($data[$i]['TEXT'])) {
$data[$i]['TEXT'] = ' ';
}

after

$data[$i] = $this->applyDefaultValues($data[$i], $sDataType);

See attached screenshot.

Regarding license: you have purchased the "Fpdf Advanced Table Utf8 Addon (fpdfDownload)". That was a ONE TIME download. No updates included.
If you need to upgrade to the latest version, you'll have to purchase the latest version.

Regards, Andrei.

RE: Arial font, utf-8 and empty cells - Added by Alonso Uribe over 10 years ago

Thanks, it's worked for me :D

I hope to buy the new version, regards.

    (1-4/4)