Professional Web Applications Themes

[PHP] Using a jpGraph image in an FPDF pdf output...-SOLVED - PHP Development

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

  1. #1

    Default RE: [PHP] Using a jpGraph image in an FPDF pdf output...-SOLVED

    [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.
    Jay Blanchard Guest

  2. #2

    Default Re: [PHP] Using a jpGraph image in an FPDF pdf output...-SOLVED

    fflush did not work?

    Jay Blanchard wrote:
    > [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.
    >
    Marek Kilimajer Guest

  3. #3

    Default RE: [PHP] Using a jpGraph image in an FPDF pdf output...-SOLVED

    [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.
    Jay Blanchard Guest

  4. #4

    Default Re: [PHP] Using a jpGraph image in an FPDF pdf output...-SOLVED

    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.

    Jay Blanchard wrote:
    > [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.
    >
    Marek Kilimajer Guest

Similar Threads

  1. Using a jpGraph image in an FPDF pdf output...
    By Jay Blanchard in forum PHP Development
    Replies: 1
    Last Post: May 16th, 03:53 PM
  2. Multicoloured image into a 3 colour image with numerical output?
    By Montana in forum Adobe Photoshop 7, CS, CS2 & CS3
    Replies: 4
    Last Post: August 14th, 09:01 PM
  3. [PHP] fpdf
    By Andrew Brampton in forum PHP Development
    Replies: 0
    Last Post: July 31st, 05:27 AM
  4. Replies: 1
    Last Post: July 14th, 03:00 PM
  5. Replies: 1
    Last Post: July 14th, 02:34 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139