Google Charts + Dompdf

2,123 views
Skip to first unread message

Gorka Leguina

unread,
Jun 8, 2010, 12:25:52 PM6/8/10
to dompdf
Hi,

I'm using dompdf0.6.

Trying to integrate Google Chart generated image:

<img src="url_for_google_chart"></img>

I get the "red cross" image instead the right image. In the http://bit.ly/bEms8b
thread, I didn't found the answer...

Someone has any idea??

Thnx!!!

BrianS

unread,
Jun 8, 2010, 9:45:52 PM6/8/10
to dompdf
It should work ok in 0.6.0 beta 1 (the latest release). I created a
simple document that loads the a google chart and didn't notice any
problems. I can think of three possible configuration issues that
could cause this:

1) Your web server does not have write access to the temporary folder
specified by DOMPDF_TEMP_DIR. This is necessary in order to use remote
images.

2) DOMPDF_ENABLE_REMOTE is set to false. DOMPDF will not access web-
based resources in this case.

3) allow_url_fopen is disabled in PHP. If this is the case DOMPDF will
be unable to access remote images because PHP does not allow it.

If none of these issues are the cause of your problems then make sure
error logging is enabled and see if PHP reports any errors or notices.


On Jun 8, 12:25 pm, Gorka Leguina <gorkalegu...@gmail.com> wrote:
> Hi,
>
> I'm using dompdf0.6.
>
> Trying to integrate Google Chart generated image:
>
> <img src="url_for_google_chart"></img>
>
> I get the "red cross" image instead the right image. In thehttp://bit.ly/bEms8b

Gorka Leguina

unread,
Jun 9, 2010, 4:15:16 AM6/9/10
to dompdf

Thanks BrianS, it was the second option.

But now... the document didn't show all the Google Charts, some of
them continue to be a "red cross". Should I force any wait time among
the gChart calling??

BrianS

unread,
Jun 9, 2010, 12:28:03 PM6/9/10
to dompdf
I would guess that either Google had an error (possibly temporary)
generating the image or the download timed out. Are the missing images
the same ones each time?

Gorka Leguina

unread,
Jun 9, 2010, 12:49:55 PM6/9/10
to dompdf
Hope so... I'm getting that bug since the last message!!

Yes, they're always the same.

Gorka Leguina

unread,
Jun 9, 2010, 1:09:57 PM6/9/10
to dompdf

I'm using PHP Output Control functions and saving all the html code in
a variable: if I echo my variable, all the google chats are perfectly
generated.

Checking what u said about missing images, the problem should be the
image size. I give u some examples:

Pie charts:
NOK: http://chart.apis.google.com/chart?cht=p3&chs=360x150&chl=Movistar,
27.08 %|Orange, 30.38 %|Vodafone, 19.55 %|Fijos, 3.48 %|Servicios
Esp., 7.47 %|Yoigo, 6.78 %|MASmovil, 4.45 %|Simyo, 0.80 %&chd=t:
27.0750,30.3810,19.5510,3.4770,7.4670,6.7830,4.4460,0.7980&chco=1874CD|
FF8C00|FF0000|66CD00|CCCC99|EEEE00|CCCC99|CCCC99
OK:
http://chart.apis.google.com/chart?cht=p3&chs=360x150&chl=Int_Andorra|Int_Holanda&chd=t:57.1432,42.8574&chco=aecae0|dfb740|95b536|e9a376|439f9f|a03434|885188|567a2e|989000|077cb7|ba6669

Bar charts:
NOK: http://chart.apis.google.com/chart?cht=bhs&chs=400x130&chxt=x,y&chxr=0,0,2&chxl=1:|Menos
de 20|De 20 a 40|De 40 a 60|De 60 a 100|De 100 a 200|Mas de
200&chxs=1,1N*cEUR*,505050&chd=t:
0,0,0,0,0,1&chds=0,2&chbh=10,5&chf=c,lg,0,bbc0b5,0,ecf0e8,1|b0,lg,
90,728da2,1,d0e7f8,0&chg=20,1000,1,0&chco=dfb740&chma=5,5,5,5
OK:
http://chart.apis.google.com/chart?cht=bhs&chs=400x130&chxt=x,y&chxr=0,0,104.6104&chxl=1:|Dom|Sab|Vie|Jue|Mie|Mar|Lun&chxs=1,1N*cEUR*,505050&chd=t:103.61040,81.35140,79.17290,102.85700,102.15320,71.73660,81.14170&chds=0,104.6104&chbh=10,5&chf=c,lg,0,bbc0b5,0,ecf0e8,1|b0,lg,90,728da2,1,d0e7f8,0&chg=20,1000,1,0&chco=dfb740&chma=5,5,5,5

Any other idea??

Fabien Ménager

unread,
Jun 9, 2010, 2:45:20 PM6/9/10
to dompdf
Hello, it doesn't work because of space, percent and other special
characters in the URLs, you need to encode them using the urlencode
function from PHP.

On 9 juin, 19:09, Gorka Leguina <gorkalegu...@gmail.com> wrote:
> I'm using PHP Output Control functions and saving all the html code in
> a variable: if I echo my variable, all the google chats are perfectly
> generated.
>
> Checking what u said about missing images, the problem should be the
> image size. I give u some examples:
>
> Pie charts:
> NOK:http://chart.apis.google.com/chart?cht=p3&chs=360x150&chl=Movistar,
> 27.08 %|Orange, 30.38 %|Vodafone, 19.55 %|Fijos, 3.48 %|Servicios
> Esp., 7.47 %|Yoigo, 6.78 %|MASmovil, 4.45 %|Simyo, 0.80 %&chd=t:
> 27.0750,30.3810,19.5510,3.4770,7.4670,6.7830,4.4460,0.7980&chco=1874CD|
> FF8C00|FF0000|66CD00|CCCC99|EEEE00|CCCC99|CCCC99
> OK:http://chart.apis.google.com/chart?cht=p3&chs=360x150&chl=Int_Andorra|Int_Holanda&chd=t:57.1432,42.8574&chco=aecae0|dfb740|95b536|e9a376|439f9f|a 03434|885188|567a2e|989000|077cb7|ba6669
>
> Bar charts:
> NOK:http://chart.apis.google.com/chart?cht=bhs&chs=400x130&chxt=x,y&chxr=...Menos
> de 20|De 20 a 40|De 40 a 60|De 60 a 100|De 100 a 200|Mas de
> 200&chxs=1,1N*cEUR*,505050&chd=t:
> 0,0,0,0,0,1&chds=0,2&chbh=10,5&chf=c,lg,0,bbc0b5,0,ecf0e8,1|b0,lg,
> 90,728da2,1,d0e7f8,0&chg=20,1000,1,0&chco=dfb740&chma=5,5,5,5
> OK:http://chart.apis.google.com/chart?cht=bhs&chs=400x130&chxt=x,y&chxr=...Dom|Sab|Vie|Jue|Mie|Mar|Lun&chxs=1,1N*cEUR*,505050&chd=t:103.61040,81.35140 ,79.17290,102.85700,102.15320,71.73660,81.14170&chds=0,104.6104&chbh=10,5&c hf=c,lg,0,bbc0b5,0,ecf0e8,1|b0,lg,90,728da2,1,d0e7f8,0&chg=20,1000,1,0&chco =dfb740&chma=5,5,5,5

Gorka Leguina

unread,
Jun 10, 2010, 5:53:54 AM6/10/10
to dompdf
Merci Fabien!!!!

In my case, the problem was due to the space character. Percents,
ampersands,... works correctly.
To solve it, tried to use urlencode but the generated url didn't work
on google... maybe I didn't use the method in a right way.

Anyway, removing space characters from my urls I solved the problem.

Thank u both!!!

On 9 jun, 20:45, Fabien Ménager <fabien.mena...@gmail.com> wrote:
> Hello, it doesn't work because of space, percent and other special
> characters in the URLs, you need to encode them using the urlencode
> function from PHP.
>
> On 9 juin, 19:09, Gorka Leguina <gorkalegu...@gmail.com> wrote:
>
> > I'm using PHP Output Control functions and saving all the html code in
> > a variable: if I echo my variable, all the google chats are perfectly
> > generated.
>
> > Checking what u said about missing images, the problem should be the
> > image size. I give u some examples:
>
> > Pie charts:
> > NOK:http://chart.apis.google.com/chart?cht=p3&chs=360x150&chl=Movistar,
> > 27.08 %|Orange, 30.38 %|Vodafone, 19.55 %|Fijos, 3.48 %|Servicios
> > Esp., 7.47 %|Yoigo, 6.78 %|MASmovil, 4.45 %|Simyo, 0.80 %&chd=t:
> > 27.0750,30.3810,19.5510,3.4770,7.4670,6.7830,4.4460,0.7980&chco=1874CD|
> > FF8C00|FF0000|66CD00|CCCC99|EEEE00|CCCC99|CCCC99
> > OK:http://chart.apis.google.com/chart?cht=p3&chs=360x150&chl=Int_Andorra|Int_Holanda&chd=t:57.1432,42.8574&chco=aecae0|dfb740|95b536|e9a376|439f9f|a 03434|885188|567a2e|989000|077cb7|ba6669
>
> > Bar charts:
> > NOK:http://chart.apis.google.com/chart?cht=bhs&chs=400x130&chxt=x,y&chxr=...
> > de 20|De 20 a 40|De 40 a 60|De 60 a 100|De 100 a 200|Mas de
> > 200&chxs=1,1N*cEUR*,505050&chd=t:
> > 0,0,0,0,0,1&chds=0,2&chbh=10,5&chf=c,lg,0,bbc0b5,0,ecf0e8,1|b0,lg,
> > 90,728da2,1,d0e7f8,0&chg=20,1000,1,0&chco=dfb740&chma=5,5,5,5
> > OK:http://chart.apis.google.com/chart?cht=bhs&chs=400x130&chxt=x,y&chxr=...Sab|Vie|Jue|Mie|Mar|Lun&chxs=1,1N*cEUR*,505050&chd=t:103.61040,81.35140 ,79.17290,102.85700,102.15320,71.73660,81.14170&chds=0,104.6104&chbh=10,5&c hf=c,lg,0,bbc0b5,0,ecf0e8,1|b0,lg,90,728da2,1,d0e7f8,0&chg=20,1000,1,0&chco =dfb740&chma=5,5,5,5
Reply all
Reply to author
Forward
0 new messages