Using FPDI AND FPDF
I'm trying to use FPDI and FPDF for generating a pdf, but I have a problem when I create a cell. I want to use the fillcolor. So the Cell has a background color.
For now I have like this:
<?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');
?>
I just had the same problem. I found the answer in another topic on this website.
The solution is adding $pdf->setPageMark();
after the $pdf->useTemplate($tplIdx, 0, 0, 0, 0, true);
There are probably more people like me out there who have the same problem and end up here.
$pdf->SetFillColor(227,227,227);
$pdf->Cell(100,10,'bla bla',1,0,'L',TRUE);
精彩评论