SetCreator(PDF_CREATOR); $pdf->SetAuthor('Your Name'); $pdf->SetTitle('PDF with Watermark'); $pdf->SetSubject('TCPDF Tutorial'); $pdf->SetKeywords('TCPDF, PDF, example, test, guide'); // 设置默认的头信息, 传入空字符串禁用 $pdf->SetHeaderData(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, PDF_HEADER_TITLE.' 001', PDF_HEADER_STRING); // 设置头部和底部字体 $pdf->setHeaderFont([PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN]); $pdf->setFooterFont([PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA]); // 移除默认的页脚 $pdf->setPrintFooter(false); // 设置默认的单元格边距 $pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED); // 设置间距 $pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT); $pdf->SetAutoPageBreak(true, PDF_MARGIN_BOTTOM); // 设置图像比例因子 $pdf->setImageScale(PDF_IMAGE_SCALE_RATIO); // 设置默认的字体,这里设置为DejaVuSans // $pdf->SetFont('dejavusans', '', 14); // 添加页面内容 $pdf->AddPage(); $pdf->Write(0, "I'm a simple text to test the watermark.\n"); // 设置水印文字 $watermarkText = "水印水印水印水印水印"; $pdf->SetFont('msyh', '', 50); // 计算斜着文字的起始坐标 $x = $pdf->getX(); $y = $pdf->getY(); // 设置斜着文字的角度 $angle = 45; // 使用Rotate()函数插入斜着的文字水印 $pdf->StartTransform(); $pdf->Rotate($angle, $x, $y); $pdf->SetTextColor(200, 200, 200); $pdf->Text($x, $y, $watermarkText); $pdf->StopTransform(); // $pdf->SetTextColor(200, 200, 200); // $pdf->SetXY(20, 50); // $pdf->Write(0, 'Watermark'); // $pdf->SetXY(100, 50); // $pdf->Write(0, '水印'); //中文乱码 $pdf->Output(WEB_PATH.'temp'.'/'.'AA.pdf', 'F'); //生成PDF文件到某地 // 输出PDF $pdf->Output('AA.pdf', 'I'); } public function repairTask() { exit(); $model = new Certificate(); $list = $model->with(['file', 'category']) ->where('is_delete', '=', 0)->select(); return $list->each(function ($item) { $item['file_type'] = $item->file['file_type']; $item->save(); }); } }