tags:

views:

46

answers:

2

Hi,

I am facing a problem with FPDF while generating the PDF file with images as explained here. Finally I found the reason for this issue but I am not sure how to fix that one, can anybody suggest some good solution to handle that issue.

This problem is due to the allow_url_fopen setting of my server, if I enable that setting then the FPDF library is generating the PDF file with images also without any errors.

I am using this FPDF library for one of my client sites, he(client) disabled the 'allow_url_fopen' setting for security reasons and he is not intersted to enable that setting. how can I solve this issue with out enabling that setting of my server.

Any solution for this issue is appreciable, please help me to solve this issue.

Thanks in advance ...

A: 

You can use CURL to open remote resources.

$curlHandler=curl_init();

curl_setopt($curlHandler, CURLOPT_URL, "http://youurl.com");

curl_setopt($curlHandler, CURLOPT_HEADER,0);

curl_setopt($curlHandler, CURLOPT_RETURNTRANSFER, 1);

$output =curl_exec($curlHandler);

....

curl_close($curlHandler);
Luis Melgratti
Yeah thanks Luis Melgratti, CURL may do the trick to handle this issue. I am planing to get the image using CURL and store that in a temporary file before adding that image to PDF file using FPDF.
Siva
Yes Luis Melgratti, I've used the CURL to fix this issue. To solve my problem I'm creating a temporary file in my local system using the CURL and sending that local file path to the FPDF function. Even your code snippet is not useful exactly for fixing this issue, I got an idea to solve my problem after seeing your answer. Once again thanks for your response...
Siva
A: 

Honestly, your best bet is going to finding another way to generate PDFs. FPDF has had only one update since 2004, and no longer seems to be actively maintained.

Some other pure-PHP options include TCPDF and Zend_PDF, both of which seem to be actively maintained and supported.

You should also give some consideration to other PDF generation techniques. For example, there are quite a few HTML-to-PDF converters, some commercial, some open source. wkhtmltopdf, for example, uses the WebKit rendering engine (the one that Safari and Chrome use) to create PDFs.

Charles
Thanks Charles, I am also thinking to use some other PDF generator instead of FPDF library, but my client preferred to use the FPDF. Anyway I will try to convence him(client) to go for some other libary, can you please suggest me one good PDF generator so that I can replace the FPDF.
Siva
I recommended no less than three above. :)
Charles
Furthermore, if your client is both telling you what libraries to use and also telling you what configuration the server must have, despite the library he told you to use *requiring* a different configuration, I expect that you may wish to either educate or stop working with the client. He or she is probably more trouble than he or she is worth.
Charles