Files
tougao/application/api/controller/Pdf.php
wangjinlei 34cf638c15 1
2022-04-06 18:47:21 +08:00

81 lines
3.1 KiB
PHP

<?php
namespace app\api\controller;
use think\Controller;
use think\Db;
use think\Queue;
use TCPDF;
/**
* Description of Auto
*
* @author jgll2
*/
class Pdf extends Controller {
//put your code here
protected $article_obj = '';
protected $article_reviewer_obj = '';
protected $user_obj = '';
protected $rev_to_jour_obj = '';
protected $reviewer_obj = '';
protected $journal_obj = '';
protected $article_msg_obj = '';
protected $user_log_obj = '';
protected $reviewer_info_obj = '';
public function __construct(\think\Request $request = null) {
parent::__construct($request);
$this->article_obj = Db::name('article');
$this->article_reviewer_obj = Db::name('article_reviewer');
$this->user_obj = Db::name('user');
$this->rev_to_jour_obj = Db::name('reviewer_to_journal');
$this->journal_obj = Db::name('journal');
$this->reviewer_obj = Db::name('article_reviewer');
$this->article_msg_obj = Db::name('article_msg');
$this->user_log_obj = Db::name('user_log');
$this->reviewer_info_obj = Db::name('user_reviewer_info');
}
public function pdftest() {
$pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);
$pdf->SetHeaderData('logo.png', 25, '', '', array(0, 64, 255), array(0, 64, 128));
$pdf->setFooterData(array(0, 64, 0), array(0, 64, 128));
$pdf->setHeaderFont(Array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN));
$pdf->setFooterFont(Array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA));
$pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);
$pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT);
$pdf->SetHeaderMargin(PDF_MARGIN_HEADER);
$pdf->SetFooterMargin(PDF_MARGIN_FOOTER);
$pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM);
$pdf->setImageScale(PDF_IMAGE_SCALE_RATIO);
if (@file_exists(dirname(__FILE__) . '/lang/eng.php')) {
require_once(dirname(__FILE__) . '/lang/eng.php');
$pdf->setLanguageArray($l);
}
$pdf->setFontSubsetting(true);
$pdf->SetFont('times', '', 14, '', true);
$pdf->AddPage();
$pdf->setTextShadow(array('enabled' => true, 'depth_w' => 0.2, 'depth_h' => 0.2, 'color' => array(196, 196, 196), 'opacity' => 1, 'blend_mode' => 'Normal'));
$html ='<div style="margin-top:300px;font-size:16px;"><h3>To whom it may concern</h3>'
. 'You have reviewed 1 submission in the journal Traditional Medicine Research during 2020.
Thank you for your support to our journal. This contribution is greatly appreciated.'
.'<p>Regards<br>
Editorial Office<br>
Traditional Medicine Research</p>'
.'<p><h3>Contact us</h3>
TMR Publishing Group Address: 11 Cockle Bay Rd, Cockle Bay, Auckland 2014, New Zealand<br>
Telephone: +64 02108293806<br>
E-mail: publisher@tmrjournals.com</p></div>';
$pdf->writeHTMLCell(0, 0, '', '', $html, 0, 1, 0, true, '', true);
$pdf->Output('d:/example_001.pdf', 'F');
}
}