This commit is contained in:
wangjinlei
2022-12-15 10:22:01 +08:00
parent c7cdf8a31f
commit e05a3d163a

View File

@@ -2,6 +2,8 @@
namespace app\api\controller;
use Mpdf\Config\ConfigVariables;
use Mpdf\Config\FontVariables;
use Mpdf\Mpdf;
use think\Controller;
use think\Db;
@@ -175,7 +177,8 @@ class Production extends Controller
}
public function mytest(){
public function mytest()
{
$p_info = $this->production_article_obj->where('p_article_id', 10)->find();
dump(json_decode($p_info['main']));
}
@@ -243,7 +246,8 @@ class Production extends Controller
/**
* 获取文章排版结果列表
*/
public function getArticleFrags(){
public function getArticleFrags()
{
$data = $this->request->post();
$rule = new Validate([
'p_article_id' => 'require|number'
@@ -255,13 +259,13 @@ class Production extends Controller
$re['frags'] = $list;
return jsonSuccess($re);
}
/**
* 编辑文章主要内容
*/
public function editMainContent(){
public function editMainContent()
{
$data = $this->request->post();
$rule = new Validate([
'p_article_id' => 'require|number',
@@ -292,7 +296,8 @@ class Production extends Controller
/**
* 获取引用文献列表
*/
public function getReferList(){
public function getReferList()
{
$data = $this->request->post();
$rule = new Validate([
'p_article_id' => 'require|number'
@@ -360,7 +365,8 @@ class Production extends Controller
/**
* 编辑文章信息在排版之后
*/
public function editArticleLast(){
public function editArticleLast()
{
$data = $this->request->post();
$rule = new Validate([
'p_article_id' => 'require|number',
@@ -381,7 +387,8 @@ class Production extends Controller
/**
* 推送文章到官网系统
*/
public function pushArticleToSystem(){
public function pushArticleToSystem()
{
$data = $this->request->post();
$rule = new Validate([
'p_article_id' => 'require'
@@ -461,7 +468,8 @@ class Production extends Controller
}
public function eeeccc(){
public function eeeccc()
{
// $str = "Critical Care Medicine 2022;50 (6):955-63";
// dump($this->bekjournal($str));
$str = "Pandey S, Kumar P, Niranjan A, Verma H, Kumar M. Targeting biosignatures of hyperglycemia and oxidative stress in diabetes comorbid depressive rats: effectiveness of hydroethanolic extract of the whole plant of Ludwigia octovalvis. Tradit Med Res 2023;8 (2):9.";
@@ -469,7 +477,54 @@ class Production extends Controller
echo $this->prgeAuthor($res[0]);
}
public function creatpdf(){
public function getPdfByHtml(){
$data = $this->request->post();
$html = $data['html'];
$path = ROOT_PATH . 'public' . DS . 'testpdf' . DS;
$intFontSize = 10.5;
// $defaultConfig = (new Mpdf\Config\ConfigVariables())->getDefaults();
$defaultConfig = (new ConfigVariables())->getDefaults();
$fontDirs = $defaultConfig['fontDir'];
// $defaultFontConfig = (new Mpdf\Config\FontVariables())->getDefaults();
$defaultFontConfig = (new FontVariables())->getDefaults();
$fontData = $defaultFontConfig['fontdata'];
$mpdf = new \Mpdf\Mpdf([
'mode' => 'utf-8',
'format' => 'A4',
'default_font_size' => $intFontSize,
'useSubstitutions' => true, //中文支持关键
'useAdobeCJK' => true,
'margin_left' => 0,
'margin_right' => 0,
'margin_top' => 0,
'margin_bottom' => 0,
'margin_header' => 0,
'margin_footer' => 0,
'fontDir' => array_merge($fontDirs, [
__DIR__ . '/custom/font/directory',
]),
'fontdata' => $fontData + [
'宋体' => [
'R' => 'Sun-ExtA.ttf',
'I' => 'Sun-ExtB.ttf',
]
],
'default_font' => '宋体' //CSS中写的汉字宋体就这么写要是别的自定义的就写自己的 自定义字体关键
]);
$strContent = $html;
$mpdf->WriteHTML($strContent);
$strFileName_New = time() . rand(100, 999) . '.pdf';
$mpdf->Output($path .$strFileName_New, 'f');
return jsonSuccess(['url'=>$strFileName_New]);
}
public function creatpdf()
{
$path = ROOT_PATH . 'public' . DS . 'testpdf' . DS;
$mpdf = new Mpdf(['mode' => 'utf-8', 'format' => 'A4']);
$mpdf->SetDisplayMode('fullpage');
@@ -481,7 +536,72 @@ class Production extends Controller
}
public function bekjournal($str){
public function creatpdf1()
{
$path = ROOT_PATH . 'public' . DS . 'testpdf' . DS;
$intFontSize = 10.5;
// $defaultConfig = (new Mpdf\Config\ConfigVariables())->getDefaults();
$defaultConfig = (new ConfigVariables())->getDefaults();
$fontDirs = $defaultConfig['fontDir'];
// $defaultFontConfig = (new Mpdf\Config\FontVariables())->getDefaults();
$defaultFontConfig = (new FontVariables())->getDefaults();
$fontData = $defaultFontConfig['fontdata'];
$mpdf = new \Mpdf\Mpdf([
'mode' => 'utf-8',
'format' => 'A4',
'default_font_size' => $intFontSize,
'useSubstitutions' => true, //中文支持关键
'useAdobeCJK' => true,
'margin_left' => 0,
'margin_right' => 0,
'margin_top' => 0,
'margin_bottom' => 0,
'margin_header' => 0,
'margin_footer' => 0,
'fontDir' => array_merge($fontDirs, [
__DIR__ . '/custom/font/directory',
]),
'fontdata' => $fontData + [
'宋体' => [
'R' => 'Sun-ExtA.ttf',
'I' => 'Sun-ExtB.ttf',
]
],
'default_font' => '宋体' //CSS中写的汉字宋体就这么写要是别的自定义的就写自己的 自定义字体关键
]);
//自定义标签样式设置也可以直接修改DefaultCss.php中的默认设置
// $mpdf->defaultCSS["BODY"]['FONT-SIZE'] = '10.5pt';
// $mpdf->defaultCSS["BODY"]['LINE-HEIGHT'] = '1.6em';
// $mpdf->defaultCSS["P"]['MARGIN'] = '0 0';
// $mpdf->defaultCSS["P"]['PADDING'] = '0';
// $mpdf->defaultCSS["H1"]['FONT-SIZE'] = '16pt';
// $mpdf->defaultCSS["H1"]['MARGIN'] = '0 0';
// $mpdf->defaultCSS["H2"]['FONT-SIZE'] = '10.5pt';
// $mpdf->defaultCSS["H2"]['MARGIN'] = '0em 0';
// $mpdf->defaultCSS["H4"]['FONT-SIZE'] = '14pt';
// $mpdf->defaultCSS["H4"]['MARGIN'] = '0 0';
// $mpdf->defaultCSS["H5"]['FONT-SIZE'] = '10.5pt';
// $mpdf->defaultCSS["H5"]['FONT-WEIGHT'] = 'normal';
// $mpdf->defaultCSS["H5"]['MARGIN'] = '-3.4em 0 0 0';
// $mpdf->defaultCSS['SPAN'] = [
// 'PADDINT-LEFT' => '14px',
// 'PADDINT-RIGHT' => '14px',
// 'PADDINT-TOP' => '0px',
// 'PADDINT-BOTTOM' => '0px'
// ];
$strContent =file_get_contents($path . 'meaut33.html');
$mpdf->WriteHTML($strContent);
$strFileName_New = $path .time() . rand(100, 999) . '.pdf';
$mpdf->Output($strFileName_New, true); //第二个参数true是直接下载 不设置默认仅保存
}
public function bekjournal($str)
{
preg_match("/[0-9]{4}/", $str, $math);
$year = $math[0];
$frag[0] = trim(substr($str, 0, stripos($str, $year)));
@@ -489,7 +609,8 @@ class Production extends Controller
return $frag;
}
public function prgeAuthor($author){
public function prgeAuthor($author)
{
$a = explode(',', $author);
if (count($a) < 7) {
return $author . '.';
@@ -626,7 +747,8 @@ class Production extends Controller
}
public function getProductionPreview(){
public function getProductionPreview()
{
$data = $this->request->post();
$rule = new Validate([
'p_article_id' => 'require|number'
@@ -711,7 +833,8 @@ class Production extends Controller
/**
* 编辑作者信息
*/
public function editAuthor(){
public function editAuthor()
{
$data = $this->request->post();
$rule = new Validate([
'p_article_author_id' => 'require',
@@ -878,7 +1001,8 @@ class Production extends Controller
/**
* 合并到上个文献中
*/
public function referHB(){
public function referHB()
{
$data = $this->request->post();
$rule = new Validate([
'p_refer_id' => 'require'
@@ -948,7 +1072,8 @@ class Production extends Controller
}
public function mytest11(){
public function mytest11()
{
$r = $this->production_article_refer_obj->where('p_refer_id', 8)->find();
my_doiToFrag2($r);
}
@@ -1105,7 +1230,8 @@ class Production extends Controller
/**
* 开始proof
*/
public function pushProof(){
public function pushProof()
{
$data = $this->request->post();
$rule = new Validate([
'p_article_id' => 'require'
@@ -1145,7 +1271,6 @@ class Production extends Controller
} else {
$file[] = ROOT_PATH . 'public' . DS . 'articleSUB' . DS . $p_info['file_sub'];
}
} else {
$file = ROOT_PATH . 'public' . DS . 'proofPDF' . DS . $p_info['article_id'] . '.pdf';
}
@@ -1162,7 +1287,8 @@ class Production extends Controller
/**
* 自动执行
*/
public function proofState(){
public function proofState()
{
$this->production_article_obj->where('proof_state', 1)->where('proof_etime', '<', time())->update(['proof_state' => 2]);
}
@@ -1171,7 +1297,8 @@ class Production extends Controller
/**
* 作者反馈proof
*/
public function editProof(){
public function editProof()
{
$data = $this->request->post();
$rule = new Validate([
'article_id' => 'require',
@@ -1199,7 +1326,8 @@ class Production extends Controller
/**
* 同意proof通过邮件链接
*/
public function editProofFromEmail($articleId){
public function editProofFromEmail($articleId)
{
$this->production_article_obj->where('article_id', $articleId)->where('state', 0)->update(['proof_state' => 2, 'proof_rtime' => time()]);
echo 'Commit Succeeded';
}
@@ -1356,7 +1484,8 @@ class Production extends Controller
/**
* 更改文章pdf文件
*/
public function updateArticlePDF(){
public function updateArticlePDF()
{
$data = $this->request->post();
$rule = new Validate([
'p_article_id' => 'require',
@@ -1385,5 +1514,4 @@ class Production extends Controller
}
}
}
}