1
FPDF를 사용하여 텍스트를 워드 랩으로 가져 오는 데 문제가 있습니다. 포장해야 할 유일한 행은 아래 코드에서 볼 수있는 product_description입니다. 나는 성공하지 못한 MultiCell을 시도했다.테이블 셀에서 FPDF를 사용하는 워드 랩
아무도 도와 줄 수 있습니까?
감사합니다.
function CreatePDFQuote($var)
{
require_once(DIR.'/classes/fpdf/fpdf.php');
require_once(DIR.'/classes/fpdi/fpdi.php');
$pdf = new FPDI();
$pdf->AddPage();
$pound_sign = html_entity_decode("£", ENT_COMPAT, 'ISO-8859-1');
/* Image & address */
$pdf->Image('../images/headsup_pdf.jpg', 8,8);
$pdf->Cell(120,5,"",0,0,'',false);
$pdf->SetFillColor(255, 255, 255);
$pdf->SetFont('Arial','B',12);
$pdf->Cell(40,5,"Company Limited",0,0,'',false);
$pdf->Ln();
$pdf->Cell(120,5,"",0,0,'',false);
$pdf->SetFont('Arial','B',9);
$pdf->Cell(40,5,"Address 1",0,0,'',false);
$pdf->Ln();
$pdf->Cell(120,5,"",0,0,'',false);
$pdf->Cell(40,5,"Tel: 09800 000 123",0,0,'',false);
$pdf->Ln();
$pdf->Cell(120,5,"",0,0,'',false);
$pdf->Cell(40,5,"[email protected]",0,0,'',false);
$pdf->Ln();
$pdf->Ln();
$pdf->Ln();
$pdf->Ln();
$pdf->Ln();
/* Invoice number & Date */
$pdf->SetDrawColor(218, 218, 218);
$pdf->SetFillColor(241, 241, 241);
$pdf->SetFont('Arial','B',9);
$pdf->Cell(50,5,"Quote Number",1,0,'',true);
$pdf->Cell(60,5,"Date",1,0,'',true);
$pdf->Ln();
$pdf->SetFillColor(255, 255, 255);
$pdf->SetFont('Arial','',9);
$pdf->Cell(50,5,$var['pdf_quote_id'],1,0,'',true);
$pdf->Cell(60,5,date('j/n/Y', strtotime($var['pdf_date'])),1,0,'',true);
$pdf->Ln();
$pdf->Ln();
/* Company, contact & telephone */
$pdf->SetDrawColor(218, 218, 218);
$pdf->SetFillColor(241, 241, 241);
$pdf->SetFont('Arial','B',9);
$pdf->Cell(60,5,"Company",1,0,'',true);
$pdf->Cell(60,5,"Contact",1,0,'',true);
$pdf->Cell(50,5,"Telephone",1,0,'',true);
$pdf->Ln();
$pdf->SetFillColor(255, 255, 255);
$pdf->SetFont('Arial','',9);
$pdf->Cell(60,5,$var['pdf_company_name'],1,0,'',true);
$pdf->Cell(60,5,$var['pdf_first_name'].' '.$var['pdf_last_name'],1,0,'',true);
$pdf->Cell(50,5,$var['pdf_telephone'],1,0,'',true);
$pdf->Ln();
$pdf->Ln();
$page_height = 286.93; // page height
$height_of_cell = 8;
$offset = 35;
$bottom_margin = 30;
foreach($var['pdf_products'] as $product)
{
$space_left = $page_height - ($pdf->GetY() + $bottom_margin + $offset); // space left on page
if($height_of_cell > $space_left)
{
$pdf->AddPage();
/* Image & address */
$pdf->Cell(120,5,$pdf->Image('../images/headsup_pdf.jpg',4,8),0,0,'',false);
$pdf->SetFillColor(255, 255, 255);
$pdf->SetFont('Arial','B',12);
$pdf->Cell(40,5,"Heads Up PGB Limited",0,0,'',false);
$pdf->Ln();
$pdf->Cell(120,5,"",0,0,'',false);
$pdf->SetFont('Arial','B',9);
$pdf->Cell(40,5,"13 Church Hill, Epping, Essex, CM16 4RA",0,0,'',false);
$pdf->Ln();
$pdf->Cell(120,5,"",0,0,'',false);
$pdf->Cell(40,5,"Tel: 0203 058 2320",0,0,'',false);
$pdf->Ln();
$pdf->Cell(120,5,"",0,0,'',false);
$pdf->Cell(40,5,"[email protected]",0,0,'',false);
$pdf->Ln();
$pdf->Ln();
$pdf->Ln();
$pdf->Ln();
$pdf->Ln();
}
// Product code
$pdf->SetDrawColor(218, 218, 218);
$pdf->SetFillColor(241, 241, 241);
$pdf->SetFont('Arial','B',9);
$pdf->Cell(50,8,"Product Code",1,0,'',true);
$pdf->Cell(60,8,$product['product_code'],1,0,'',true);
$pdf->Cell(60,8, $pdf->Image(SITEURL.'/'.$product['product_image'], $pdf->GetX(), $pdf->GetY(), 33.78),0,0,0,false);
$pdf->Ln();
$pdf->SetFillColor(255, 255, 255);
$pdf->SetFont('Arial','',9);
$pdf->Cell(110,8,$product['product_name'],LR,0,'',true);
$pdf->Ln();
$pdf->SetFillColor(255, 255, 255);
$pdf->SetFont('Arial','',9);
$pdf->Cell(110,5,$product['product_description'],LR,0,'',true);
$pdf->Ln();
$pdf->SetFillColor(255, 255, 255);
$pdf->SetFont('Arial','',9);
$pdf->Cell(110,8,"Price includes a ".$product['logo_colours']." colour print.",LRB,0,'',true);
$pdf->Ln();
$pdf->SetFillColor(241, 241, 241);
$pdf->SetFont('Arial','',9);
$pdf->Cell(50,8,$product['quantity'].' @ '.$pound_sign.$product['unit_cost'].' each',1,0,'',true);
$pdf->Cell(60,8,$pound_sign.$product['line_total'],1,0,'',true);
$pdf->Ln();
$pdf->SetFillColor(255, 255, 255);
$pdf->SetFont('Arial','',9);
$pdf->Cell(50,8,'1 x Origination',1,0,'',true);
$pdf->Cell(60,8,$pound_sign.$product['origination'],1,0,'',true);
$pdf->Ln();
if($product['extra_costs'] > 0)
{
$pdf->SetFillColor(241, 241, 241);
$pdf->SetFont('Arial','',9);
$pdf->Cell(50,8,'Extra Costs',1,0,'',true);
$pdf->Cell(60,8,$pound_sign.$product['extra_costs'],1,0,'',true);
$pdf->Ln();
}
$pdf->SetFillColor(241, 241, 241);
$pdf->SetFont('Arial','',9);
$pdf->Cell(50,8,'Delivery to 1 UK Address',1,0,'',true);
$pdf->Cell(60,8,$pound_sign.$product['delivery_charge'],1,0,'',true);
$pdf->Ln();
$vat = ($product['line_total'] + $product['origination'] + $product['delivery_charge'] + $product['extra_costs']) * 0.2;
$pdf->SetFillColor(255, 255, 255);
$pdf->SetFont('Arial','',9);
$pdf->Cell(50,8,'VAT 20%',1,0,'',true);
$pdf->Cell(60,8,$pound_sign.number_format($vat, 2),1,0,'',true);
$pdf->Ln();
$total = ($product['line_total'] + $product['origination'] + $product['delivery_charge'] + $product['extra_costs'] + $vat);
$pdf->SetFillColor(241, 241, 241);
$pdf->SetFont('Arial','B',9);
$pdf->Cell(50,8,'Total',1,0,'',true);
$pdf->Cell(60,8,$pound_sign.number_format($total, 2),1,0,'',true);
$pdf->Ln();
$pdf->Ln();
}
$pdf->SetFillColor(255, 255, 255);
$pdf->SetFont('Arial','',9);
$pdf->Cell(110,10,"Thank you for your quote request. Please do not hesitate to contact us, should you have any further requirements.",0,0,'',false);
$pdf->Ln();
$pdf->Cell(110,5,"Kind Regards,",0,0,'',false);
$pdf->Ln();
$pdf->Cell(110,5,"Team",0,0,'',false);
$pdf->Ln();
$pdf->Cell(110,5,"020 3058 2320",0,0,'',false);
$pdf->Ln();
$pdf->Cell(110,5,"[email protected]",0,0,'',false);
$pdf->Ln();
/* Save PDF file */
$pdf_filename = str_replace(' ', '', $var['pdf_id']).'_'.strtotime($var['pdf_date']).'_'.uniqid().'.pdf';
$pdf->Output(DIR.'/'.$var['pdf_folder'].'/'.$pdf_filename, 'F');
return $pdf_filename;
}