|
|
|
|
@ -1965,18 +1965,18 @@ class OrdersController extends CommonController
|
|
|
|
|
// 2. 生成图片到临时文件(需要两个参数:html内容和输出路径)
|
|
|
|
|
SnappyImage::setOptions($options)->generateFromHtml($html, $tempPath);
|
|
|
|
|
// 3. 读取临时文件内容并转换为Base64
|
|
|
|
|
$imageContent = file_get_contents($tempPath);
|
|
|
|
|
$base64Image = 'data:image/' . $options['format'] . ';base64,' . base64_encode($imageContent);
|
|
|
|
|
|
|
|
|
|
// 4. 删除临时文件(清理资源)
|
|
|
|
|
unlink($tempPath);
|
|
|
|
|
return response()->json([
|
|
|
|
|
"errorcode" => "200",
|
|
|
|
|
"errormsg" => "success",
|
|
|
|
|
"data" => [
|
|
|
|
|
"base64_image" => $base64Image
|
|
|
|
|
]
|
|
|
|
|
]);
|
|
|
|
|
// $imageContent = file_get_contents($tempPath);
|
|
|
|
|
// $base64Image = 'data:image/' . $options['format'] . ';base64,' . base64_encode($imageContent);
|
|
|
|
|
//
|
|
|
|
|
// // 4. 删除临时文件(清理资源)
|
|
|
|
|
// unlink($tempPath);
|
|
|
|
|
// return response()->json([
|
|
|
|
|
// "errorcode" => "200",
|
|
|
|
|
// "errormsg" => "success",
|
|
|
|
|
// "data" => [
|
|
|
|
|
// "base64_image" => $base64Image
|
|
|
|
|
// ]
|
|
|
|
|
// ]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|