Replace fopen library for cURL in html2fpdf

[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.

Anuncios

One Response to Replace fopen library for cURL in html2fpdf

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

Responder

Introduce tus datos o haz clic en un icono para iniciar sesión:

Logo de WordPress.com

Estás comentando usando tu cuenta de WordPress.com. Cerrar sesión / Cambiar )

Imagen de Twitter

Estás comentando usando tu cuenta de Twitter. Cerrar sesión / Cambiar )

Foto de Facebook

Estás comentando usando tu cuenta de Facebook. Cerrar sesión / Cambiar )

Google+ photo

Estás comentando usando tu cuenta de Google+. Cerrar sesión / Cambiar )

Conectando a %s

A %d blogueros les gusta esto: