I use the pear extension File_PDF in an old PHP app I maintain.
It seems like the last version by that module is version 0.3.3 from and it is not maintained anymore and has been superseded by the package Horde_Pdf
from pear.horde.org.
Can I just change the codebase to the new package? Or do I need to change the function calls?
I started a repository where I convert the old code to the new code at https://github.com/rubo77/File_PDF
The old PDF.php
was renamed to Writer.php
and the fonts are now in another folder. and the class File_PDF
was renamed to class Horde_Pdf_Writer
.
I replaced the code in my scripts:
and changed
require_once('vendors/pear/File_PDF/PDF.php');
$this->pdf = &File_PDF::factory();
to
require_once('vendors/pear/Horde_Pdf_Writer/Writer.php');
$this->pdf = new Horde_Pdf_Writer();
now I get the error
Uncaught Error: Class 'Horde_String' not found in /var/www/app/vendors/pear/Horde_Pdf_Writer/Writer.php
A better solution would be to use a more actively maintained PDF generation library like TCPDF, which doesn't need much changes either, e.g. from file_PDF to TCPDF just:
newLine()
withLn()
getOutput()
withOutput()
SetFont('Arial', ...
doesn't work, so just useSetFont('', ...
If you really need this old Library you need to also download those packages:
To let it run in a local folder, edit some files:
instead of calling File_PDF with
now call
in
Writer.php
the function_getFontFile()
needs these extra lines:in
Exception.php
you need to callin
Wrapped.php
you need