0

I can create the chart, display it, generate an image and convert the image using jqplotToImageStr which is then posted to another php page.

I want to be able to convert the string back into an image and display it on the php page which I can then convert to pdf. I've tried using this php code

$img = $_POST['hidImage'];
$img = str_replace('data:image/png;base64,', '', $img);
$img = str_replace(' ', '+', $img);
$data = base64_decode($img);
return $data;

(Using modx 2.5.1 in a snippet)

But it doesn't render as an image - the image shows the top and bottom sections of the source code (345 lines in total) that is generated.

I'd really appreciate any help or advice before my sanity finally leaves me :-(

generated output

1 Answers1

0

You need to set headers for the image type. Check this answer for your reference.

header('Content-type: image/png');

Community
  • 1
  • 1
Saurabh Sharma
  • 2,422
  • 4
  • 20
  • 41