【问题标题】:How set watermark behind text in fpdf如何在fpdf中的文本后面设置水印
【发布时间】:2016-12-09 18:22:34
【问题描述】:

谁能帮帮我,我遇到了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());

}

我想要这样的结果:

但它看起来像这样的图像:

为了得到我想要的结果我应该改变什么

对不起我的英语不好

【问题讨论】:

    标签: php fpdf watermark


    【解决方案1】:

    将您的水印代码放入Header() 函数中,如this example 所示。这样水印将设置在AddPage(),即在实际内容输出之前,使水印出现在“背景”中。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多