Printing Σ (Sigma) not possible in PDF [message #7894] |
Tue, 31 December 2024 10:23 |
htManager
Messages: 441 Registered: May 2014
|
Senior Member |
|
|
I want to print the Σ Sign in a pdf document but it won't be printed.
With var_dump($str = "\u{2211}"); the Σ sign will be shown correctly. I use the Times font.
I read that the Times font supports the sigma character. Do I have to include an additional library? Or do I have to do something else?
|
|
|
|
Re: Printing Σ (Sigma) not possible in PDF [message #7896 is a reply to message #7895] |
Wed, 01 January 2025 07:00 |
htManager
Messages: 441 Registered: May 2014
|
Senior Member |
|
|
I don't know where is my fault.
If I call the following php file, the ∑ sign will be shown correctly in a pdf file.
<?php
require('c:\xampp\htdocs\radicore\includes\tcpdf\tcpdf.php') ;
$pdf = new TCPDF();
$pdf->AddPage();
$pdf->SetFont('times', '', 16);
$pdf->Cell(40, 10, 'Großes Sigma: Σ'); // Funktioniert mit Unicode
or
$pdf->Cell(40, 10, 'Großes Sigma: ' . "\u{03A3}"); // Funktioniert mit Unicode
$pdf->Output();
?>
If I define a field in my report nothing will be shown. - array('field' => 'sigma', 'width' => 10, 'x' => 0); - $sigma = "\u{03A3}";
If I define a label with value "\u{03A3}", a ? will be shown. - array('label' => "\u{03A3}", 'width' => 10, 'x' => 0);
The value sigma will also be shown correctly if I output it in my class file with var_dump("\u{03A3}");
|
|
|
Re: Printing Σ (Sigma) not possible in PDF [message #7897 is a reply to message #7896] |
Thu, 02 January 2025 06:27 |
AJM
Messages: 2373 Registered: April 2006 Location: Surrey, UK
|
Senior Member |
|
|
I tried ruuning a test with the sigma character on my PC using the Times font and it displayed as '?' which is incorrect.
I tried running example_008.php in the TCPDF download as this demonstrates the ability to print numerous UTF-8 characters. I even added 'Großes Sigma: Σ' to the 'German (de)' entry in the examples/data/utf8test.txt file and it printed as it should. I noticed that the font used in that test was 'freeserif', so I changed the font in the RADICORE test to 'freeserif' and the sigma character displayed correctly. I even tried the 'freesans' font, and that displayed correctly as well.
It would appear that the 'Times' font will not display this character, so you will need to switch to a font that does.
Tony Marston
http://www.tonymarston.net
http://www.radicore.org
|
|
|