簡體   English   中英

使用FPDI和FPDF

[英]Using FPDI AND FPDF

我正在嘗試使用FPDI和FPDF來生成pdf,但是當我創建一個單元格時我遇到了問題。 我想使用fillcolor。 因此,單元格具有背景色。

現在,我已經這樣:

<?php
require_once('fpdf/fpdf.php'); 
require_once('pdf/fpdi.php'); 
$pdf = new FPDI();

$pdf->AddPage(); 

$pdf->setSourceFile('anolis_dopis_a4.pdf'); 
// import page 1 
$tplIdx = $pdf->importPage(1); 
//use the imported page and place it at point 0,0; calculate width and height
//automaticallay and ajust the page size to the size of the imported page 
$pdf->useTemplate($tplIdx, 0, 0, 0, 0, true); 

// now write some text above the imported page 
$pdf->SetFont('Arial', '', '13'); 
$pdf->SetTextColor(0,0,0);
//set position in pdf document
$pdf->SetXY(40, 50);
//first parameter defines the line height
$pdf->Write(0, 'gift code');

$pdf->SetXY(40, 55);
$pdf->Write(0, 'gift code');

//HERE I WANT TO HAVE BACKGROUND COLOR
$pdf->Cell(100,10,"bla bla",1,"left","");

//force the browser to download the output
$pdf->Output('test.pdf', 'D');

?>

我剛遇到同樣的問題。 我在該網站的另一個主題中找到了答案。

解決方案是添加$pdf->setPageMark(); $pdf->useTemplate($tplIdx, 0, 0, 0, 0, true);

可能有更多像我這樣的人有同樣的問題並最終到此為止。

$pdf->SetFillColor(227,227,227);
$pdf->Cell(100,10,'bla bla',1,0,'L',TRUE);

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM