修改生成长表格返回
This commit is contained in:
@@ -3590,12 +3590,23 @@ class Production extends Base
|
|||||||
|
|
||||||
$success = $this->generatePdfFromTex($tex_file, $pdfFilePath);
|
$success = $this->generatePdfFromTex($tex_file, $pdfFilePath);
|
||||||
|
|
||||||
if($success){
|
// if($success){
|
||||||
|
// $this->production_article_obj->where("p_article_id",$production_info['p_article_id'])->update(['file_sub_table'=>'tex_'.$article_id.DS."table.pdf"]);
|
||||||
|
// }
|
||||||
|
// $frag['success'] = $success;
|
||||||
|
// $frag['file'] = $pdfFilePath;
|
||||||
|
// return $frag;
|
||||||
|
$iStatus = empty($success['status']) ? 0 : $success['status'];
|
||||||
|
if($iStatus != 1){
|
||||||
|
return json_encode($success);
|
||||||
|
}
|
||||||
|
if($iStatus == 1){
|
||||||
$this->production_article_obj->where("p_article_id",$production_info['p_article_id'])->update(['file_sub_table'=>'tex_'.$article_id.DS."table.pdf"]);
|
$this->production_article_obj->where("p_article_id",$production_info['p_article_id'])->update(['file_sub_table'=>'tex_'.$article_id.DS."table.pdf"]);
|
||||||
}
|
}
|
||||||
$frag['success'] = $success;
|
$frag['success'] = $success;
|
||||||
$frag['file'] = $pdfFilePath;
|
$frag['file'] = $pdfFilePath;
|
||||||
return $frag;
|
// return $frag;
|
||||||
|
return json_encode(['status' => 1,'msg' => 'Table generated successfully']);
|
||||||
|
|
||||||
// if ($success) {
|
// if ($success) {
|
||||||
// return jsonSuccess([
|
// return jsonSuccess([
|
||||||
@@ -3622,12 +3633,13 @@ class Production extends Base
|
|||||||
* @param string $pdfFilePath 输出PDF文件路径
|
* @param string $pdfFilePath 输出PDF文件路径
|
||||||
* @return bool 是否生成成功
|
* @return bool 是否生成成功
|
||||||
*/
|
*/
|
||||||
public function generatePdfFromTex($texFilePath, $pdfFilePath)
|
public function generatePdfFromTex($texFilePath, $pdfFilePath)
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
// 检查.tex文件是否存在
|
// 检查.tex文件是否存在
|
||||||
if (!file_exists($texFilePath)) {
|
if (!file_exists($texFilePath)) {
|
||||||
throw new Exception("LaTeX文件不存在: " . $texFilePath);
|
// throw new Exception("LaTeX文件不存在: " . $texFilePath);
|
||||||
|
return ['status' => 2,'msg' => "LaTeX文件不存在: " . $texFilePath];
|
||||||
}
|
}
|
||||||
|
|
||||||
// 确保输出目录存在
|
// 确保输出目录存在
|
||||||
@@ -3636,9 +3648,9 @@ class Production extends Base
|
|||||||
mkdir($pdfDir, 0755, true);
|
mkdir($pdfDir, 0755, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 方法1: 使用pdflatex命令(推荐)lualatex -output-directory=/path/to/output /path/to/input.tex
|
// 方法1: 使用pdflatex命令(推荐)
|
||||||
// $command = "pdflatex -include-directory=" . dirname($texFilePath) .
|
// $command = "{$sLatexDir}pdflatex -include-directory=" . dirname($texFilePath) .
|
||||||
// " -output-directory=" . $pdfDir . " " . escapeshellarg($texFilePath);
|
// " -output-directory=" . $pdfDir . " " . escapeshellarg($texFilePath);
|
||||||
$command = "lualatex -output-directory=" . $pdfDir . " " . escapeshellarg($texFilePath);
|
$command = "lualatex -output-directory=" . $pdfDir . " " . escapeshellarg($texFilePath);
|
||||||
|
|
||||||
$output = [];
|
$output = [];
|
||||||
@@ -3647,21 +3659,25 @@ class Production extends Base
|
|||||||
|
|
||||||
// 检查命令执行结果
|
// 检查命令执行结果
|
||||||
if ($returnVar !== 0) {
|
if ($returnVar !== 0) {
|
||||||
error_log("LaTeX to PDF conversion failed: " . implode("\n", $output));
|
// error_log("LaTeX to PDF conversion failed: " . implode("\n", $output));
|
||||||
return false;
|
// return false;
|
||||||
|
return ['status' => 3,'msg' => "LaTeX to PDF conversion failed: " . implode("\n", $output)];
|
||||||
}
|
}
|
||||||
|
|
||||||
// 检查PDF文件是否生成成功
|
// 检查PDF文件是否生成成功
|
||||||
if (!file_exists($pdfFilePath)) {
|
if (!file_exists($pdfFilePath)) {
|
||||||
error_log("PDF文件未生成: " . $pdfFilePath);
|
// error_log("PDF文件未生成: " . $pdfFilePath);
|
||||||
return false;
|
// return false;
|
||||||
|
return ['status' => 3,'msg' => "PDF文件未生成: " . $pdfFilePath];
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
// return true;
|
||||||
|
return ['status' => 1,'msg' => "PDF文件生成成功: " . $pdfFilePath];
|
||||||
|
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
error_log("生成PDF失败: " . $e->getMessage());
|
// error_log("生成PDF失败: " . $e->getMessage());
|
||||||
return false;
|
// return false;
|
||||||
|
return ['status' => 3,'msg' => "PDF文件未生成: " . $pdfFilePath];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user