PDFMerger icon indicating copy to clipboard operation
PDFMerger copied to clipboard

PHP 8.2 not working

Open RigidCollision opened this issue 1 year ago • 6 comments

I am running back to back PHP8.0 and PHP8.2 and am getting the following in PHP8.2:

PHP Deprecated: Optional parameter $isunicode declared before required parameter $currentfont is implicitly treated as a required parameter in PDFMerger\tcpdf\include\tcpdf_fonts.php on line 1999 PHP Deprecated: Optional parameter $isunicode declared before required parameter $currentfont is implicitly treated as a required parameter in PDFMerger\tcpdf\include\tcpdf_fonts.php on line 2021 PHP Deprecated: Optional parameter $setbom declared before required parameter $currentfont is implicitly treated as a required parameter in PDFMerger\tcpdf\include\tcpdf_fonts.php on line 2037 PHP Deprecated: Optional parameter $isunicode declared before required parameter $currentfont is implicitly treated as a required parameter in PDFMerger\tcpdf\include\tcpdf_fonts.php on line 2037 PHP Deprecated: Optional parameter $setbom declared before required parameter $currentfont is implicitly treated as a required parameter in PDFMerger\tcpdf\include\tcpdf_fonts.php on line 2057 PHP Deprecated: Optional parameter $forcertl declared before required parameter $currentfont is implicitly treated as a required parameter in PDFMerger\tcpdf\include\tcpdf_fonts.php on line 2057 PHP Deprecated: Optional parameter $isunicode declared before required parameter $currentfont is implicitly treated as a required parameter in PDFMerger\tcpdf\include\tcpdf_fonts.php on line 2057 PHP Deprecated: Optional parameter $str declared before required parameter $currentfont is implicitly treated as a required parameter in PDFMerger\tcpdf\include\tcpdf_fonts.php on line 2074 PHP Deprecated: Optional parameter $setbom declared before required parameter $currentfont is implicitly treated as a required parameter in PDFMerger\tcpdf\include\tcpdf_fonts.php on line 2074 PHP Deprecated: Optional parameter $forcertl declared before required parameter $currentfont is implicitly treated as a required parameter in PDFMerger\tcpdf\include\tcpdf_fonts.php on line 2074 PHP Deprecated: Optional parameter $isunicode declared before required parameter $currentfont is implicitly treated as a required parameter in PDFMerger\tcpdf\include\tcpdf_fonts.php on line 2074 PHP Deprecated: Optional parameter $str declared before required parameter $currentfont is implicitly treated as a required parameter in PDFMerger\tcpdf\include\tcpdf_fonts.php on line 2090 PHP Deprecated: Optional parameter $forcertl declared before required parameter $currentfont is implicitly treated as a required parameter in PDFMerger\tcpdf\include\tcpdf_fonts.php on line 2090 PHP Deprecated: Optional parameter $isunicode declared before required parameter $currentfont is implicitly treated as a required parameter in PDFMerger\tcpdf\include\tcpdf_fonts.php on line 2090 PHP Deprecated: Callables of the form ["TCPDI", "TCPDF::SetFont"] are deprecated in PDFMerger\tcpdf\fpdf_tpl.php on line 278 PHP Deprecated: Callables of the form ["TCPDI", "TCPDF::AddPage"] are deprecated in PDFMerger\tcpdf\fpdf_tpl.php on line 323 PHP Deprecated: Callables of the form ["TCPDI", "TCPDF::SetFont"] are deprecated in PDFMerger\tcpdf\fpdf_tpl.php on line 278 PHP Deprecated: Callables of the form ["TCPDI", "TCPDF::SetFont"] are deprecated in PDFMerger\tcpdf\fpdf_tpl.php on line 278 PHP Deprecated: Callables of the form ["TCPDI", "TCPDF::AddPage"] are deprecated in PDFMerger\tcpdf\fpdf_tpl.php on line 323 PHP Deprecated: Callables of the form ["TCPDI", "TCPDF::SetFont"] are deprecated in PDFMerger\tcpdf\fpdf_tpl.php on line 278 PHP Deprecated: Callables of the form ["TCPDI", "TCPDF::SetFont"] are deprecated in PDFMerger\tcpdf\fpdf_tpl.php on line 278 PHP Deprecated: Callables of the form ["TCPDI", "TCPDF::SetFont"] are deprecated in PDFMerger\tcpdf\fpdf_tpl.php on line 278 PHP Deprecated: Callables of the form ["TCPDI", "TCPDF::AddPage"] are deprecated in PDFMerger\tcpdf\fpdf_tpl.php on line 323 PHP Deprecated: Callables of the form ["TCPDI", "TCPDF::SetFont"] are deprecated in PDFMerger\tcpdf\fpdf_tpl.php on line 278 PHP Deprecated: Callables of the form ["TCPDI", "TCPDF::SetFont"] are deprecated in PDFMerger\tcpdf\fpdf_tpl.php on line 278 PHP Deprecated: Callables of the form ["TCPDI", "TCPDF::SetFont"] are deprecated in PDFMerger\tcpdf\fpdf_tpl.php on line 278 PHP Deprecated: Callables of the form ["TCPDI", "TCPDF::SetFont"] are deprecated in PDFMerger\tcpdf\fpdf_tpl.php on line 278 PHP Deprecated: Callables of the form ["TCPDI", "TCPDF::Link"] are deprecated in PDFMerger\tcpdf\fpdf_tpl.php on line 338 PHP Deprecated: Callables of the form ["TCPDI", "TCPDF::SetFont"] are deprecated in PDFMerger\tcpdf\fpdf_tpl.php on line 278 PHP Deprecated: Callables of the form ["TCPDI", "TCPDF::SetFont"] are deprecated in PDFMerger\tcpdf\fpdf_tpl.php on line 278

RigidCollision avatar Apr 20 '23 15:04 RigidCollision

Got the following email communication from Epic2022:

The deprecated functions mentioned in the warnings are related to the TCPDF library, which is used for generating PDF files. The library has functions with optional parameters that are declared before the required parameters, which is not a good practice. You should update your code to use the latest version of TCPDF or update the deprecated function calls. If you can't update the library or code, you can suppress the warnings by modifying your php.ini file or adding the following line of code to the top of your PHP file: error_reporting(E_ALL ^ E_DEPRECATED); This will turn off the deprecation warnings for the code that you are running. However, this is not recommended as the code may become unusable in future versions of PHP. It's always a good practice to update your code and libraries to their latest versions to avoid such issues.

I will be taking a look at this and when I have a solution will be posting.

RigidCollision avatar Apr 21 '23 17:04 RigidCollision

I am also stuck waiting on this issue

a4992214 avatar Oct 06 '23 11:10 a4992214

for ex. $unicode = self::UTF8StringToArray($str, $isunicode, $currentfont); //don't work Here you have to change the place of the variables: $unicode = self::UTF8StringToArray($str, $currentfont, $isunicode); //workable way or the variable $currentfont should write first: $unicode = self::UTF8StringToArray($currentfont, $str, $isunicode); //workable way

aydos-t avatar Feb 20 '24 18:02 aydos-t

same problem.. anyone solved this issue ?

johnloydlao avatar Mar 08 '24 08:03 johnloydlao

same problem.. anyone solved this issue ?

https://github.com/sinanbekar/pdf-merger this works for me

johnloydlao avatar Mar 08 '24 09:03 johnloydlao

In the end what I have done is get the latest FPDI and FPDF libraries and just re-work the original PHPMerger library to use them. Literally two lines need modifying that are specific to TCPDF (you remove the two lines specifically calling the TCPDF header and footer initialisation).

It works with PHPv8.3.3 and if you buy the official FPDI-Parser will handle pretty much everything. Even without the additional commercial parser it is as robust as the original.

This is pretty much what @johnloydlao has mentioned in the link above. When I drilled into what it was doing the code is really simple.

I am using: FPDF v1.86 FPDI v2.6.0 FPDI-Parser v2.1.2 (not required but for (€100 probably worth it for robustness in a commercial environment).

There looks to be a new version of TCPDF under development which will handle some of the major changes brought about by PHPv8+. Information can be found here (https://tcpdf.org/ )but the link to the new version is: https://github.com/tecnickcom/tc-lib-pdf A new TCPDF will remove the need for the additional FPDI-Parser (I believe) for dealing with PDF's version 1.4 and above.

RigidCollision avatar Mar 08 '24 09:03 RigidCollision