如何在fpdf中的文本后面设置水印
How set watermark behind text in fpdf
谁能帮帮我,我对 fpdf 中的水印有疑问
这是我的代码:
$width_header = array(10,45,25,60,20,15,15);
$set_align = array('L','L','L','L','R','L','R');
$table_head = array('No.','Kelompok','Kode Brg','Nama Barang','QTY','','Cek list');
$page_copy = 0;
$fpdf->SetFont('Arial','B',11);
$lebar = $fpdf->w;
$fpdf->line($fpdf->GetX(), $fpdf->GetY(), $fpdf->GetX()+$lebar-18, $fpdf->GetY());
$fpdf->Ln(2);
$fpdf->SetWidths($width_header);
$fpdf->SetAligns($set_align);
$fpdf->SetFont('Arial','B',9);
for($i=1;$i<=1;$i++) {
$fpdf->Row_Header($table_head);
}
$fpdf->line($fpdf->GetX(), $fpdf->GetY(), $fpdf->GetX()+$lebar-18, $fpdf->GetY());
$no = 1;
$sub_total = 0;
$sql2 = $this->adm_entry_penjualan_model->getDataCetakDetil(" WHERE a.hps<>'*' AND a.no_bukti='$no_bukti_tmp' AND a.tgl='$tgl_tmp' ORDER BY b.acct_no, b.kode_sub");
$fpdf->SetFont('Arial','',10);
foreach ($sql2->result_array() as $key_no => $row2) {
//Put the watermark
$fpdf->SetFont('Arial','B',50);
$fpdf->SetTextColor(255,222,233);
$fpdf->RotatedText(90,90,'COPY',45);
$fpdf->SetFont('Arial','',10);
$fpdf->SetTextColor(0,0,0);
$fpdf->SetFont('Arial','',10);
$fpdf->Row(
array($no++,
$row2['acct_name'],
$row2['kode_sub'],
$row2['nama_sub'],
$row2['qty'].' ',
$row2['satuan'],
'...'
));
$fpdf->line($fpdf->GetX(), $fpdf->GetY(), $fpdf->GetX()+$lebar-18, $fpdf->GetY());
}
我想要这样的结果:
但它看起来像这张图片:
为了得到我想要的结果我应该改变什么
抱歉我的英语不好
将您的水印代码放入Header()
函数中,如this example所示。这样水印就会设置在AddPage()
,也就是在实际内容输出之前,让水印出现在"background".
谁能帮帮我,我对 fpdf 中的水印有疑问
这是我的代码:
$width_header = array(10,45,25,60,20,15,15);
$set_align = array('L','L','L','L','R','L','R');
$table_head = array('No.','Kelompok','Kode Brg','Nama Barang','QTY','','Cek list');
$page_copy = 0;
$fpdf->SetFont('Arial','B',11);
$lebar = $fpdf->w;
$fpdf->line($fpdf->GetX(), $fpdf->GetY(), $fpdf->GetX()+$lebar-18, $fpdf->GetY());
$fpdf->Ln(2);
$fpdf->SetWidths($width_header);
$fpdf->SetAligns($set_align);
$fpdf->SetFont('Arial','B',9);
for($i=1;$i<=1;$i++) {
$fpdf->Row_Header($table_head);
}
$fpdf->line($fpdf->GetX(), $fpdf->GetY(), $fpdf->GetX()+$lebar-18, $fpdf->GetY());
$no = 1;
$sub_total = 0;
$sql2 = $this->adm_entry_penjualan_model->getDataCetakDetil(" WHERE a.hps<>'*' AND a.no_bukti='$no_bukti_tmp' AND a.tgl='$tgl_tmp' ORDER BY b.acct_no, b.kode_sub");
$fpdf->SetFont('Arial','',10);
foreach ($sql2->result_array() as $key_no => $row2) {
//Put the watermark
$fpdf->SetFont('Arial','B',50);
$fpdf->SetTextColor(255,222,233);
$fpdf->RotatedText(90,90,'COPY',45);
$fpdf->SetFont('Arial','',10);
$fpdf->SetTextColor(0,0,0);
$fpdf->SetFont('Arial','',10);
$fpdf->Row(
array($no++,
$row2['acct_name'],
$row2['kode_sub'],
$row2['nama_sub'],
$row2['qty'].' ',
$row2['satuan'],
'...'
));
$fpdf->line($fpdf->GetX(), $fpdf->GetY(), $fpdf->GetX()+$lebar-18, $fpdf->GetY());
}
我想要这样的结果:
但它看起来像这张图片:
为了得到我想要的结果我应该改变什么
抱歉我的英语不好
将您的水印代码放入Header()
函数中,如this example所示。这样水印就会设置在AddPage()
,也就是在实际内容输出之前,让水印出现在"background".