生成pdf

This commit is contained in:
chengxl
2025-12-31 16:07:59 +08:00
parent 838e25028f
commit 493d11aee0

View File

@@ -259,11 +259,6 @@ page={{stage_page}},%号
$aWhere = ['ami_id' => ['in',$aAmiId],'state' => 0];
$aArticleMainImage = Db::name('article_main_image')->field('ami_id,url,note')->where($aWhere)->select();
$aArticleMainImage = empty($aArticleMainImage) ? [] : array_column($aArticleMainImage, null,'ami_id');
// //查询表格
// $aAmtId = array_unique(array_column($aArticleMain, 'amt_id'));
// $aWhere = ['amt_id' => ['in',$aAmtId],'state' => 0];
// $aArticleMainTable = Db::name('article_main_table')->field('amt_id,type,table_data,url,title,note')->where($aWhere)->select();
// $aArticleMainTable = empty($aArticleMainTable) ? [] : array_column($aArticleMainTable, null,'amt_id');
//获取图片模版
$sImageTempalte = $this->sImageTempalte;
//数据处理
@@ -329,15 +324,6 @@ page={{stage_page}},%号
$sTableInfo = $oProduction->tableCovertLatex($value['amt_id'],$aReferences);
var_dump($sTableInfo);
$sMain .= $sTableInfo."\\par\n";
// $aTableInfo = empty($aArticleMainTable[$value['amt_id']]) ? [] : $aArticleMainTable[$value['amt_id']];
// if(empty($aTableInfo['table_data'])){
// continue;
// }
// $aTableResult = $oLatexTable->generateTable($aTableInfo);
// var_dump($aTableResult);exit;
// if(empty($aTableResult['data'])){
// continue;
// }
}
}
@@ -550,48 +536,6 @@ page={{stage_page}},%号
}
return trim($dateStr);
}
/**
* 内容处理
*/
// private function dealContent($content = '', $target = 'latex',$iIsDeal = 1) {
// // 空值直接返回
// if (empty($content)) {
// return '';
// }
// //统一编码为UTF-8
// $content = mb_convert_encoding($content, 'UTF-8', mb_detect_encoding($content));
// //过滤不可见/非法字符
// $content = preg_replace('/[\x00-\x1F\x7F]/u', '', $content);
// //整合所有替换规则按优先级排序先处理HTML实体再处理LaTeX特殊字符
// $replaceRules = [
// // ========== HTML实体替换 ==========
// ' ' => '~', // HTML非断行空格 → LaTeX非断行空格
// '&nbsp' => '~', // 兼容无分号的&nbsp
// '&' => '\&', // HTML& → LaTeX转义&
// '&lt;' => '<', // HTML< → 直接保留
// '&gt;' => '>', // HTML> → 直接保留
// // ========== LaTeX特殊字符转义 ==========
// '{' => '\{', // 左花括号转义
// '}' => '\}', // 右花括号转义
// '&' => '\&', // 原生&转义(需在&amp;之后,避免覆盖)
// '%' => '\%', // 百分号转义LaTeX注释符
// '_' => '\_', // 下划线转义LaTeX下标符
// 'κ' => '$\kappa$', // 希腊字母κ → LaTeX数学环境避免乱码
// '-' => '\text{-}', // 短横线强制保留形态
// ':' => ':', // 冒号无需转义(占位,便于统一维护)
// ];
// //执行批量替换
// $content = strtr($content, $replaceRules);
// //清理多余空格/换行
// $content = preg_replace('/\s+/u', ' ', trim($content));
// if($iIsDeal == 1){
// $content = $this->htmlToLaTeX($content);
// }
// return $content;
// }
private function dealContent($content = '',$aReferences = []) {
// 空值直接返回
if(empty($content)){
@@ -607,33 +551,6 @@ page={{stage_page}},%号
$sContent = $oProduction->convertToLatex($content,$aReferences);
$content = $this->htmlToLaTeX($content);
return $sContent;
// //整合所有替换规则按优先级排序先处理HTML实体再处理LaTeX特殊字符
// $replaceRules = [
// // ========== HTML实体替换 ==========
// '&nbsp;' => '~', // HTML非断行空格 → LaTeX非断行空格
// '&nbsp' => '~', // 兼容无分号的&nbsp
// '&amp;' => '\&', // HTML& → LaTeX转义&
// '&lt;' => '<', // HTML< → 直接保留
// '&gt;' => '>', // HTML> → 直接保留
// // ========== LaTeX特殊字符转义 ==========
// '{' => '\{', // 左花括号转义
// '}' => '\}', // 右花括号转义
// '&' => '\&', // 原生&转义(需在&amp;之后,避免覆盖)
// '%' => '\%', // 百分号转义LaTeX注释符
// '_' => '\_', // 下划线转义LaTeX下标符
// 'κ' => '$\kappa$', // 希腊字母κ → LaTeX数学环境避免乱码
// '-' => '\text{-}', // 短横线强制保留形态
// ':' => ':', // 冒号无需转义(占位,便于统一维护)
// ];
// //执行批量替换
// $content = strtr($content, $replaceRules);
// //清理多余空格/换行
// $content = preg_replace('/\s+/u', ' ', trim($content));
// if($iIsDeal == 1){
// $content = $this->htmlToLaTeX($content);
// }
// return $content;
}
private function htmlToLaTeX($text = ''){
if(empty($text)){