tcpdf位置在页面底部添加白色块

时间:2014-07-21 18:23:41

标签: tcpdf

正如您在此屏幕截图中看到的那样,页面底部会添加一个大约100 px高的白色区域,该区域也会将整个页面向上推离页面顶部。我正在尝试将文本放在页面页脚的蓝色区域,白色文本。我已经尝试了几个相关的建议,无法让他们工作。非常感谢任何帮助!

屏幕截图:http://screencast.com/t/lt3J1Wle76Dm

代码:

function downloadFile($rid,$count,$userid,$orderid,$email,$user_password,$owner_password) {
    global $wpdb;

    $rid = intval($rid);
    $query = "
        SELECT 
        filehash,filename,filesize,productid
        FROM {$this->dbtable}_product
        WHERE rid = {$rid}
    ";
    $res = $wpdb->get_results($query);
    $r = $res[0];

    $file_location = $this->getplugindir()."uploads/".$r->filehash.".file";
    if (!file_exists($file_location)) { exit('File does not exist.'); }

    if ($count === true) {
        $res = $wpdb->query("UPDATE {$this->dbtable}_product SET download_count = download_count+1 WHERE rid = {$rid}");
        $this->auditLog($r->productid, $rid, $userid, 'Downloaded');
    }

    $filename = str_replace(' ', '_', $r->filename);

    require_once($this->getplugindir() . 'fpdf/tcpdf/tcpdf.php');
    require_once($this->getplugindir() . 'fpdf/tcpdf/tcpdi.php');
    //require_once($this->getplugindir() . 'fpdf/tcpdf/wpds.php');

    if ($orderid === false) { $orderid = '12345'; }

    $pdf = new TCPDI();
    $pagecount = $pdf->setSourceFile($file_location);
    $pdf->SetAutoPageBreak(false);

    for ($i = 1; $i <= $pagecount; $i++){
        $pdf->addPage();
        $tplidx = $pdf->importPage($i);
        $pdf->useTemplate($tplidx);

        $pdf->SetAlpha(0.5);
        $pdf->SetFont('Courier', 'I', 6);
        $pdf->SetTextColor(255,0,0);
        $pdf->SetXY(5, -5);
        /*
        $pdf->StartTransform();
        $pdf->Rotate(5);
        */
        $pdf->Write(0, "This guide individually licensed to $email ($orderid)");
        /*
        $pdf->Rotate(0);
        $pdf->StopTransform();
        */
        $pdf->SetAlpha(1);
    }

    $pdf->SetProtection(array(
        'modify','copy','annot-forms','fill-forms','extract','assemble'
    ),$user_password,$owner_password,3);
    $pdf->Output($filename,'D');

    exit();

}

1 个答案:

答案 0 :(得分:0)

要移动文字,请使用setXY()

更改其位置

替换:

$pdf->SetXY(5, -5);

通过:

$pdf->SetXY(5, -100); // change Y value to be on blue area