Recently there is an export requirement that requires highchart pictures and data reports to be generated together.
After struggling for a few days, I finally got it done.
1. First you need to install the JAVA environment. No need to set environment variables or anything.
2. Download the relevant batik jar package. I downloaded this many times but it was wrong. The attachment is what I compiled.
3. To call the officially written PHP program, I organized it into a function.
function svgToImg($type, $svg, $filename){ clearFile(SAVE_PATH);//删除过期文件 ini_set('magic_quotes_gpc', 'off'); $svg = (string) $svg; $filename = (string) $filename; // prepare variables if (!$filename or !preg_match('/^[A-Za-z0-9\-_ ]+$/', $filename)) { $filename = 'chart'; } if (get_magic_quotes_gpc()) { $svg = stripslashes($svg); } // check for malicious attack in SVG if(strpos($svg,"$output
Save the file locally, and then you can do whatever you want.
If you really find it troublesome to install the JAVA environment, you can directly simulate and submit a request for the official export address.