Discussion:
Using a jpGraph image in an FPDF pdf output...-SOLVED
Jay Blanchard
2003-09-16 11:52:07 UTC
Permalink
[snip]
Has anyone ever suceesfully embedded a jpGraph image in an FPDF output?

FPDF uses this function for an image

$pdfGraph->Image('grfx/image.jpg', 15, 20, 50, 0, 'JPG');

but when image.jpg is created with jpgraph it throws errors. I am sure
that I am missing something quite obvious, but alas I cannot see it.
[/snip]

It appears that the image was not getting fully processed and that the
PDF was completing prior to the image itself. Solved this by
two-stepping, when the PDF is requested the graph image is processed and
saved to the server before a redirect to the PDF. Works like a chaem and
the user sees no degredation in performance.
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Marek Kilimajer
2003-09-16 12:31:07 UTC
Permalink
fflush did not work?
Post by Jay Blanchard
[snip]
Has anyone ever suceesfully embedded a jpGraph image in an FPDF output?
FPDF uses this function for an image
$pdfGraph->Image('grfx/image.jpg', 15, 20, 50, 0, 'JPG');
but when image.jpg is created with jpgraph it throws errors. I am sure
that I am missing something quite obvious, but alas I cannot see it.
[/snip]
It appears that the image was not getting fully processed and that the
PDF was completing prior to the image itself. Solved this by
two-stepping, when the PDF is requested the graph image is processed and
saved to the server before a redirect to the PDF. Works like a chaem and
the user sees no degredation in performance.
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Jay Blanchard
2003-09-16 12:39:11 UTC
Permalink
[snip]
fflush did not work?
[/snip]

No, because the graph image was not complete before the PDF was
complete. Flushing the JPG would display (if no errors occured) an
partial JPG within the PDF.
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Marek Kilimajer
2003-09-16 13:16:14 UTC
Permalink
If your are using $graph->Stroke('sometempfile'); before
$pdf->Image('sometempfile'); (I bet you do), then the image should be
completed.

Is it happening always or just now and then? What if you wait a few
seconds between the two calls? Do you call clearstatcache()?

I'm asking this because I once had a similar problem. My code created a
file and included it right away. But sometimes (about 10%) the file was
empty or incomplete. I never managed to reproduce this in a small
example, only in my few 100 line script. I also noticed other people had
this problem.
Post by Jay Blanchard
[snip]
fflush did not work?
[/snip]
No, because the graph image was not complete before the PDF was
complete. Flushing the JPG would display (if no errors occured) an
partial JPG within the PDF.
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Jay Blanchard
2003-09-16 13:22:01 UTC
Permalink
[snip]
If your are using $graph->Stroke('sometempfile'); before
$pdf->Image('sometempfile'); (I bet you do), then the image should be
completed.

Is it happening always or just now and then? What if you wait a few
seconds between the two calls? Do you call clearstatcache()?

I'm asking this because I once had a similar problem. My code created a
file and included it right away. But sometimes (about 10%) the file was
empty or incomplete. I never managed to reproduce this in a small
example, only in my few 100 line script. I also noticed other people had

this problem.
[/snip]

It was intermittent as described by you. We tried sleep() and
clearstatcache() and still found intermittent problems....especially
with data intensive graphs. Using the redirect actually seems faster
(not tested) than the direct embed. Perhaps it is because of the sizes
of both classes in combination.
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Marek Kilimajer
2003-09-16 13:35:30 UTC
Permalink
Did you also noticed the partial image files are always in multiple of
4096 in size? There must be some inner php caching that just does not
work right. This bug should be fixed.
Post by Jay Blanchard
[snip]
If your are using $graph->Stroke('sometempfile'); before
$pdf->Image('sometempfile'); (I bet you do), then the image should be
completed.
Is it happening always or just now and then? What if you wait a few
seconds between the two calls? Do you call clearstatcache()?
I'm asking this because I once had a similar problem. My code created a
file and included it right away. But sometimes (about 10%) the file was
empty or incomplete. I never managed to reproduce this in a small
example, only in my few 100 line script. I also noticed other people had
this problem.
[/snip]
It was intermittent as described by you. We tried sleep() and
clearstatcache() and still found intermittent problems....especially
with data intensive graphs. Using the redirect actually seems faster
(not tested) than the direct embed. Perhaps it is because of the sizes
of both classes in combination.
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Loading...