$param = request()->all();
$id = getter($param, "id", 0);
if (!isset($id[0]) || empty($id[0])) {
return message("请选择需要生成PDF文档的学生", false);
}
$sMode = new StudentModel();
$sinfo= $sMode->getInfo($id[0]);
Log::debug($sinfo);
if($sinfo){
$pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);
$pdf->SetCreator('湖南匠领科技有限公司');
$pdf->SetAuthor('湖南匠领科技有限公司');
$pdf->SetTitle($sinfo['name']);
$pdf->SetSubject('湖南匠领科技有限公司');
$pdf->SetKeywords('湖南匠领科技有限公司');
$pdf->SetHeaderData('123', 30, 'www.bekingai.com', '湖南匠领科技有限公司', [0, 64, 255], [0, 64, 128]);
$pdf->setFooterData([0, 64, 0], [0, 64, 128]);
$pdf->setHeaderFont(['stsongstdlight', '', '10']);
$pdf->setFooterFont(['helvetica', '', '8']);
$pdf->SetDefaultMonospacedFont('courier');
$pdf->SetMargins(15, 15, 0);
$pdf->SetHeaderMargin(5);
$pdf->SetFooterMargin(10);
$pdf->SetAutoPageBreak(true, 25);
$pdf->setFontSubsetting(true);
$pdf->SetFont('stsongstdlight', '', 14);
$pdf->AddPage();
$html = '
<table width="90%" border="1" cellpadding="15">
<tr>
<td colspan="2" height="220"></td>
<td colspan="2"></td>
</tr>
<tr>
<td width="25%">姓名</td>
<td width="25%">'.$sinfo['name'].'</td>
<td width="25%">性别</td>
<td width="25%">'.$sinfo['gender_name'].'</td>
</tr>
<tr>
<td>学号</td>
<td>'.$sinfo['code'].'</td>
<td>身份号码</td>
<td>'.$sinfo['id_code'].'</td>
</tr>
<tr>
<td>班级</td>
<td>'.$sinfo['class_name'].'</td>
<td>年级</td>
<td>'.$sinfo['grade_name'].'</td>
</tr>
<tr>
<td>出生日期</td>
<td>'.$sinfo['birthday_out'].'</td>
<td>有效状态</td>
<td>'.$sinfo['status_name'].'</td>
</tr>
<tr>
<td>联系电话</td>
<td>'.$sinfo['telephone'].'</td>
<td>结业状态</td>
<td>'.$sinfo['finish_status'].'</td>
</tr>
<tr>
<td>详细住址</td>
<td colspan="3">'.$sinfo['address'].'</td>
</tr>
<tr>
<td>备注</td>
<td colspan="3">'.$sinfo['intro'].'</td>
</tr>
</table>
';
$pdf->writeHTML('<div style="text-align: center"><h1>'.$sinfo["name"].'</h1></div>');
$pdf->writeHTML($html);
if($sinfo['avatar']){
$pdf->SetXY(20, 50);
$pdf->Image($sinfo['avatar'], '', '', 0, 0, '', '', '', false, 300, '', false, false, 0, false, false, false);
}
Log::debug('头像地址:'.$sinfo['avatar']);
if($sinfo['logo']){
$pdf->SetXY(110, 50);
$pdf->Image($sinfo['logo'], '', '', 0, 0, '', '', '', false, 300, '', false, false, 0, false, false, false);
}
$pdf->Ln(1);
$fileName = date('YmdHms').'.pdf';
$pdf->Output(UPLOAD_TEMP_PATH . "/" .$fileName, 'F');
$fileUrl = get_image_url(str_replace(ATTACHMENT_PATH, "", UPLOAD_TEMP_PATH) . "/" . $fileName);
Log::debug('下载地址:'.$fileUrl);
return message(MESSAGE_OK, true, $fileUrl);
}
return message("操作失败", false);
|