PHP
$pdf = new HTML2FPDF();
$pdf->AddPage();
$pdf->AddGBFont();
$pdf->SetFont('GB','B',12);
$pdf->Cell(90,10, iconv('UTF-8', 'gbk', 'xxx'),0,0,'R');
$pdf->SetFont('Arial','',8);
$pdf->SetTextColor(0,149,205);
$pdf->Cell(80,10, iconv('UTF-8', 'gbk', '('.$vstart.'-'.$vend).')',0,0,'L');
$pdf->Ln();
$pdf->SetFont('GB','',8);
$pdf->SetTextColor(0,0,0);
$width = array(30,20,20,90);
for($i = 0;$i < count($header); $i++){
$pdf->Cell($width[$i],5,iconv('UTF-8','gbk',$header[$i]),1,0,'C');
}
$pdf->Ln();
$dbdata = $this->getListFromDB($start,$end);
foreach ($dbdata as $k => $v){
$pdf->SetFont('GB','B',8);
$pdf->SetTextColor(0,149,205);
$pdf->Cell(30,5,iconv('UTF-8', 'gbk', $v['name']),1,0,'C');
$pdf->SetFont('Arial','B',8);
$pdf->Cell(20,5,$v['keyword_num'],1,0,'C');
$pdf->SetTextColor(191,10,10);
$pdf->Cell(20,5,$v['alarm_num'],1,0,'C');
$pdf->SetFont('GB','',8);
$pdf->SetTextColor(0,0,0);
$pdf->Cell(90,5,iconv('UTF-8', 'GBK', $v['keywords']),1,0,'L');
$pdf->Ln();
}
$pdf->Ln();
$pdf->SetFont('GB','B',10);
$pdf->Cell(170,10,iconv('UTF-8', 'gbk', 'xxx'),0,0,'L');
$pdf->Ln();
$quxianHeight = $pdf->GetY();
$pdf->Image($path.'/'.$pdfname.'.jpg', 25, $quxianHeight,0,0);
$pdf->Ln();
$pdf->SetFont('GB','B',10);
$pdf->Cell(170,10,iconv('UTF-8', 'gbk', 'xxx'),0,0,'L');
$pdf->Ln();
$hotword = $this->hotWord($type);
$html .= '<div style="width:100%;">';
$html .= '<table cellpadding="0" cellspacing="0" width="100%" style="border:1px solid #DDDDDD;">';
foreach ($hotword as $k => $v){
if($k % 5 == 0){
$html .= '</tr><tr>';
}
$html .= '<td width="20%"><font color="#58ADD8">'.$v.'</font></td>';
}
$html .= '</tr>';
$html .= '</table>';
$html .= '</div>';
$pdf->WriteHTML($html);
$jc_event = $this->getEventCount();
$event_data = $this->getEventList($start,$end);
$pdf->SetFont('GB','B','10');
$pdf->Cell(170,10,iconv('UTF-8', 'gbk', '共監測事件 '.$jc_event[0]['num'].'個'),0,0,'L');
$pdf->Ln();
$k = 0;
$startNum = 100;
$topNum = 25;
foreach ($event_data as $v){
$pdf->SetFont('GB','','8');
$pdf->Cell(50,5,iconv('UTF-8', 'GBK', $v['name']),1,0,'C');
$pdf->Cell(25,5,iconv('UTF-8', 'GBK', 'xx'),1,0,'C');
$pdf->SetFont('Arial','B','8');
$pdf->SetTextColor(0,149,205);
$pdf->Cell(30,5,$v['yc_num'],1,0,'L');
$pdf->SetFont('GB','','8');
$pdf->SetTextColor(0,0,0);
$pdf->Cell(25,5,iconv('UTF-8', 'GBK', 'xx'),1,0,'C');
$pdf->SetFont('Arial','B','8');
$pdf->SetTextColor(51,51,51);
$pdf->Cell(30,5,$v['zf_num'],1,0,'L');
$pdf->Ln();
$imgdata = $this->getUser($v['id'], '');
// $imgdata = $this->getUser('1', '');
$mediaArr = $imgdata[0];
$commonArr = $imgdata[1];
$recpoeterArr = $imgdata[2];
if(count($mediaArr)>0){
$pdf->SetFont('GB','B','8');
$pdf->Cell(180,10,iconv('UTF-8', 'GBK', 'xxx'),0,0,'L');
$pdf->Ln();
$mediaHeight = $pdf->GetY();
if($mediaHeight+10 > 280){
$pdf->AddPage();
$mediaHeight = $pdf->GetY();
}
foreach ($mediaArr as $ks => $v){
$verified = $v['verified_type'];
$immg = '';
if($verified >= 1 && $verified <= 7){
$immg = 'lv';
}
if($verified == 0){
$immg = 'hv';
}
if($verified == 200 || $verified == 220){
$immg = 'dr';
}
$hre = $v['profile_image_url'];
$hre = str_replace('/50/', '/30/', $hre);
$img = file_get_contents($hre);
$da = $path.'/'.$v['uid'].'.jpg';
file_put_contents($da, $img);
$screen_name = $v['screen_name'];
if(strlen($screen_name)>15){
$screen_name = substr($screen_name, 0,15);
}
$a=GetImageSize($da);
if($a[2]!=2){
$pdf->Image('./home/images/f.jpg',26+$ks*16,$mediaHeight,0,0);
if($immg != ''){
$pdf->Image('./home/images/'.$immg.'.png', 37+$ks*16, $mediaHeight+8,3,3,'png');
}
$pdf->SetFont('GB','','7');
$pdf->Cell(16,5,iconv('UTF-8', 'GBK', $screen_name),0,0,'L');
}else{
$pdf->Image($da,26+$ks*16,$mediaHeight,0,0);
if($immg != ''){
$pdf->Image('./home/images/'.$immg.'.png', 37+$ks*16, $mediaHeight+8,3,3,'png');
}
$pdf->SetFont('GB','','7');
$pdf->Cell(16,5,iconv('UTF-8', 'GBK', $screen_name),0,0,'L');
}
}
$pdf->Ln();
}
if(count($commonArr)>0){
$pdf->SetFont('GB','B','8');
$pdf->Cell(180,10,iconv('UTF-8', 'GBK', 'xxx'),0,0,'L');
$pdf->Ln();
$commonHeight = $pdf->GetY();
if($commonHeight+10 > 280){
$pdf->AddPage();
$commonHeight = $pdf->GetY();
}
foreach ($commonArr as $ks => $v){
$verified = $v['verified_type'];
$immg = '';
if($verified >= 1 && $verified <= 7){
$immg = 'lv';
}
if($verified == 0){
$immg = 'hv';
}
if($verified == 200 || $verified == 220){
$immg = 'dr';
}
$hre = $v['profile_image_url'];
$hre = str_replace('/50/', '/30/', $hre);
$img = file_get_contents($hre);
$da = $path.'/'.$v['uid'].'.jpg';
file_put_contents($da, $img);
$screen_name = $v['screen_name'];
if(strlen($screen_name)>15){
$screen_name = substr($screen_name, 0,15);
}
$a=GetImageSize($da);
if($a[2]!=2){
$pdf->Image('./home/images/f.jpg',26+$ks*16,$commonHeight,0,0);
if($immg != ''){
$pdf->Image('./home/images/'.$immg.'.png', 37+$ks*16, $commonHeight+8,3,3,'png');
}
$pdf->SetFont('GB','','7');
$pdf->Cell(16,5,iconv('UTF-8', 'GBK', $screen_name),0,0,'L');
}else{
$pdf->Image($da,26+$ks*16,$commonHeight,0,0);
if($immg != ''){
$pdf->Image('./home/images/'.$immg.'.png', 37+$ks*16, $commonHeight+8,3,3,'png');
}
$pdf->SetFont('GB','','7');
$pdf->Cell(16,5,iconv('UTF-8', 'GBK', $screen_name),0,0,'L');
}
}
$pdf->Ln();
}
if(count($recpoeterArr)>0){
$pdf->SetFont('GB','B','8');
$pdf->Cell(180,10,iconv('UTF-8', 'GBK', 'xxxx'),0,0,'L');
$pdf->Ln();
$recpHeight = $pdf->GetY();
if($recpHeight+10 > 280){
$pdf->AddPage();
$recpHeight = $pdf->GetY();
}
foreach ($recpoeterArr as $ks => $v){
$verified = $v['verified_type'];
$immg = '';
if($verified >= 1 && $verified <= 7){
$immg = 'lv';
}
if($verified == 0){
$immg = 'hv';
}
if($verified == 200 || $verified == 220){
$immg = 'dr';
}
$hre = $v['profile_image_url'];
$hre = str_replace('/50/', '/30/', $hre);
$img = file_get_contents($hre);
$da = $path.'/'.$v['uid'].'.jpg';
file_put_contents($da, $img);
$screen_name = $v['screen_name'];
if(strlen($screen_name)>15){
$screen_name = substr($screen_name, 0,15);
}
$a=GetImageSize($da);
if($a[2]!=2){
$pdf->Image('./home/images/f.jpg',26+$ks*16,$recpHeight,0,0);
if($immg != ''){
$pdf->Image('./home/images/'.$immg.'.png', 37+$ks*16, $recpHeight+8,3,3,'png');
}
$pdf->SetFont('GB','','7');
$pdf->Cell(16,5,iconv('UTF-8', 'GBK', $screen_name),0,0,'L');
}else{
$pdf->Image($da,26+$ks*16,$recpHeight,0,0);
if($immg != ''){
$pdf->Image('./home/images/'.$immg.'.png', 37+$ks*16, $recpHeight+8,3,3,'png');
}
$pdf->SetFont('GB','','7');
$pdf->Cell(16,5,iconv('UTF-8', 'GBK', $screen_name),0,0,'L');
}
}
$pdf->Ln();
}
$pdf->Ln();
$k++;
}
// $now = $path .'/'.date('YmdHis',time()).'.pdf';
$now = $path .'/'.$pdfname.'.pdf';
$pdf->Output($now,'F');