[ir a la versión en castellano]
I received several queries regarding the problem of creating a PDF with images in some servers where the value of the “allow_url_fopen” is set Off in php.ini configuration file.
The classes html2fpdf uses fopen to open the images in the html source that we use to create the PDF and in the cases just commenting will not work correctly. Ie, the images will not appear in the PDF we generate.
The solution is to replace the fopen function for the functions that cURL offers us a platform library that enables the transfer of files from the client side through multiple protocols.
As an example we show a slice of the modified code:
if ( ‘allow_url_fopen’ == ‘Off’)
(
$ f = fopen ($ file, ‘rb’);
else ()
Open with //—– Curl
$ curl_handler = curl_init ();
curl_setopt ($ curl_handler, CURLOPT_URL, $ file);
curl_setopt ($ curl_handler, CURLOPT_RETURNTRANSFER, 1);
curl_setopt ($ curl_handler, CURLOPT_BINARYTRANSFER, 1);
$ f = curl_exec ($ curl_handler);
curl_close ($ curl_handler);
)
I uploaded the files fpdf and html2fpdf, to replace the originals with necessary modifications. You can download it here.
I hope you are helpful.














Junio 4, 2009 a las 9:51 am |
[...] Replace fopen library for cURL in html2fpdf « sobre peachep y eso de la internet Dice: Junio 4, 2009 a las 9:49 am | Responder [...]