Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Forced line break and German umlaut #464

Open
hf2094 opened this issue Jan 4, 2022 · 1 comment
Open

Forced line break and German umlaut #464

hf2094 opened this issue Jan 4, 2022 · 1 comment

Comments

@hf2094
Copy link

hf2094 commented Jan 4, 2022

Hello,
I use TCPDF to generate PFD-reports from nuBuilder Reports on an Arch Linux system with AMD x86_64, 4GB RAM, Kernel 5.15.12 and PHP 8.0.14.

In my PDF-reports I have a small text field with size=80px, font dejavusanscondensed, fontsize 10.
When I put one test string in this field, e.g. "Wanderstöcke" then TCPDF automatically performs a forced line break winthin the text. If this line break is just in front of the german umlaut (ö here, but i can use any other umlaut), then TCPDF terminates the PDF-generation and puts a message in /var/log/httpd/error_log :

[Tue Jan 04 19:35:49.820175 2022] [php:error] [pid 6823] [client 127.0.0.1:46818] PHP Fatal error:
Uncaught TypeError: array_map(): Argument #2 ($array) must be of type array, bool given in /srv/http/nubuilder/core/libs/tcpdf/include/tcpdf_fonts.php:2004
Stack trace:
#0 /srv/http/nubuilder/core/libs/tcpdf/include/tcpdf_fonts.php(2004): array_map()
#1 /srv/http/nubuilder/core/libs/tcpdf/tcpdf.php(6394): TCPDF_FONTS::UTF8StringToArray()
#2 /srv/http/nubuilder/core/libs/tcpdf/tcpdf.php(5971): TCPDF->Write()
#3 /srv/http/nubuilder/core/nurunpdf.php(948): TCPDF->MultiCell()
#4 /srv/http/nubuilder/core/nurunpdf.php(178): nuPrintField()
#5 /srv/http/nubuilder/core/nurunpdf.php(78): nuPrintReport()
#6 /srv/http/nubuilder/core/nurunpdf.php(23): nuRunReportId()
#7 {main}
thrown in /srv/http/nubuilder/core/libs/tcpdf/include/tcpdf_fonts.php on line 2004, referer: http://achleiten/minadmin/

There is no problem, when I change the text of the field so that the linebreak in not in front of the umlaut or on any other position in the text. The problem is bound to PHP8. When I use PHP7 there is also no problem.

Thanks for your attention
Yours Hf2094

@sgiehl
Copy link

sgiehl commented Jan 10, 2022

The problem seems to be here:

TCPDF/include/tcpdf_fonts.php

Lines 2002 to 2004 in bf02c1c

// requires PCRE unicode support turned on
$chars = TCPDF_STATIC::pregSplit('//','u', $str, -1, PREG_SPLIT_NO_EMPTY);
$carr = array_map(array('TCPDF_FONTS', 'uniord'), $chars);

TCPDF_STATIC::pregSplit might return false, if an error occurs within the preg_split it performs.
In PHP 7 that only triggered a warning, while PHP 8 now throws an error.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants