wchamber22 Posted February 29, 2012 Share Posted February 29, 2012 Hello freaks, I am using the FPDF class to generate PDF's on the fly, and I needed a way to generate multiline (flowing) text with specific widths. I found this FPDF extension function from FPDF's website, but can't seem to call it properly. I recieve an undefined function error! The function with in my script is as follows: <?php include_once "fpdf16/fpdf.php"; class PDF extends FPDF { function WordWrap(&$text, $maxwidth) { $text = trim($text); if ($text==='') return 0; $space = $this->GetStringWidth(' '); $lines = explode("\n", $text); $text = ''; $count = 0; foreach ($lines as $line) { $words = preg_split('/ +/', $line); $width = 0; foreach ($words as $word) { $wordwidth = $this->GetStringWidth($word); if ($wordwidth > $maxwidth) { // Word is too long, we cut it for($i=0; $i<strlen($word); $i++) { $wordwidth = $this->GetStringWidth(substr($word, $i, 1)); if($width + $wordwidth <= $maxwidth) { $width += $wordwidth; $text .= substr($word, $i, 1); } else { $width = $wordwidth; $text = rtrim($text)."\n".substr($word, $i, 1); $count++; } } } elseif($width + $wordwidth <= $maxwidth) { $width += $wordwidth + $space; $text .= $word.' '; } else { $width = $wordwidth + $space; $text = rtrim($text)."\n".$word.' '; $count++; } } $text = rtrim($text)."\n"; $count++; } $text = rtrim($text); return $count; } } ?> My call to this function with in my script is as follows: <?php $text = $useDesc1; $pdf -> WordWrap($text, $useDescTextWidth); $pdf -> Write(10, $text); ?> Does anyone have a reccommendations as to why this is happening? Thanks in advance. Link to comment https://forums.phpfreaks.com/topic/257993-fpdf-class-extension/ Share on other sites More sharing options...
KevinM1 Posted February 29, 2012 Share Posted February 29, 2012 Do you actually instantiate a PDF object? Link to comment https://forums.phpfreaks.com/topic/257993-fpdf-class-extension/#findComment-1322426 Share on other sites More sharing options...
wchamber22 Posted February 29, 2012 Author Share Posted February 29, 2012 Hello KevinM1, I do instantiate a PDF object in my full script. It is very long so I cut and pasted the sections to limit the length. I will post the whole script now though. The WordWrap class extension is located at the top of the script just after the if $_GET condition. Several calls to the function are made toward the bottom of the script. Does the function need to be after the instantiation of a new(FDPF), maybe? Code Below: <?php if(isset($_GET['cmd']) && $_GET['cmd'] == "compilebook") { $sql = mysql_query("INSERT INTO books (memberID, plant_use, customerName, customerAddress, customerCity, customerState, customerZip, customerPhone, book_template) VALUES ('$memberID', '$plantUse', '$customerName', '$customerAddress', '$customerCity', '$customerState', '$customerZip', '$customerPhone', '$book_template')"); include_once "fpdf16/fpdf.php"; class PDF extends FPDF { function WordWrap(&$text, $maxwidth) { $text = trim($text); if ($text==='') return 0; $space = $this->GetStringWidth(' '); $lines = explode("\n", $text); $text = ''; $count = 0; foreach ($lines as $line) { $words = preg_split('/ +/', $line); $width = 0; foreach ($words as $word) { $wordwidth = $this->GetStringWidth($word); if ($wordwidth > $maxwidth) { // Word is too long, we cut it for($i=0; $i<strlen($word); $i++) { $wordwidth = $this->GetStringWidth(substr($word, $i, 1)); if($width + $wordwidth <= $maxwidth) { $width += $wordwidth; $text .= substr($word, $i, 1); } else { $width = $wordwidth; $text = rtrim($text)."\n".substr($word, $i, 1); $count++; } } } elseif($width + $wordwidth <= $maxwidth) { $width += $wordwidth + $space; $text .= $word.' '; } else { $width = $wordwidth + $space; $text = rtrim($text)."\n".$word.' '; $count++; } } $text = rtrim($text)."\n"; $count++; } $text = rtrim($text); return $count; } } $plantUse = rtrim($plantUse, ","); $plantID_str_array = explode(",", $plantUse); if ($book_template = "1") { //////MODERN BOOK STYLE/////////////////////////////////////////// //BUILD COVER PAGE ------------------------------------------- $textColor = array(100, 100, 100); $headerTextColor = array(50, 50, 50); $footerTextColor = array(16, 177, 77); $backgroundImageCover = "images/modern/coverbackground1.jpg"; $backgroundImageCoverXPos = 0; $backgroundImageCoverYPos = 0; $backgroundImageCoverWidth = 612; $backgroundImageCoverHeight = 792; $companyLogo = "memberFiles/$memberID/logo.jpg"; $logoCoverXPos = 41; $logoCoverYPos = 58; $logoCoverWidth = 65; //$logoCoverHeight = 65; $companyNameCoverXPos = 119; $companyNameCoverYPos = 58; $companyNameCoverWidth = 435; $companyNameCoverHeight = 20; $companyCityStateZip = '' . $companyCity . ', ' . $companyState . ' ' . $companyZip . ''; $companyPhone = 'Tel: ' . $companyPhone . ''; $companyWeb = 'Web: ' . $companyWeb . ''; //$companyInfoCoverXPos = 119; //$companyInfoCoverYPos = 78; $companyInfoCoverWidth = 300; $companyInfoCoverHeight = 12; $customerPhoto = "memberFiles/$memberID/$customerName/customerphoto.jpg"; $customerPhotoXPos = 225; $customerPhotoYPos = 328; //$customerPhotoWidth = 335; $customerPhotoHeight = 223; $customerNameCoverXPos = 225; $customerNameCoverYPos = 566; $customerNameCoverWidth = 335; $customerNameCoverHeight = 28; $customerCityStateZip = '' . $customerCity . ', ' . $customerState . ' ' . $customerZip . ''; $customerPhone = 'Tel: ' . $customerPhone . ''; //$customerInfoCoverXPos = 225; //$customerInfoCoverYPos = 614; $customerInfoCoverWidth = 335; $customerInfoCoverHeight = 12; $pdf = new FPDF('P', 'pt', 'Letter'); $pdf -> AddPage(); //Cover Background $pdf -> Image($backgroundImageCover, $backgroundImageCoverXPos, $backgroundImageCoverYPos, $backgroundImageCoverWidth, $backgroundImageCoverHeight); //Cover Company Logo $pdf -> Image($companyLogo, $logoCoverXPos, $logoCoverYPos, $logoCoverWidth); //Cover Company Name $pdf -> SetTextColor($headerTextColor[0], $headerTextColor[1], $headerTextColor[2]); $pdf -> SetFont('Arial', 'B', '18'); $pdf -> SetXY($companyNameCoverXPos, $companyNameCoverYPos); $pdf -> Cell($companyNameCoverWidth, $companyNameCoverHeight, $companyName); //Cover Company Info $pdf -> SetTextColor($textColor[0], $textColor[1], $textColor[2]); $pdf -> SetFont('Arial', '', '12'); $pdf -> SetXY(119, 78); $pdf -> Cell($companyInfoCoverWidth, $companyInfoCoverHeight, $companyAddress); $pdf -> SetXY(119, 90); $pdf -> Cell($companyInfoCoverWidth, $companyInfoCoverHeight, $companyCityStateZip); $pdf -> SetXY(119, 102); $pdf -> Cell($companyInfoCoverWidth, $companyInfoCoverHeight, $companyPhone); $pdf -> SetXY(119, 114); $pdf -> Cell($companyInfoCoverWidth, $companyInfoCoverHeight, $companyWeb); //Cover Customer Photo $pdf -> Image($customerPhoto, $customerPhotoXPos, $customerPhotoYPos, '', $customerPhotoHeight); //Cover Customer Name $pdf -> SetTextColor($headerTextColor[0], $headerTextColor[1], $headerTextColor[2]); $pdf -> SetFont('Arial', 'B', '24'); $pdf -> SetXY($customerNameCoverXPos, $customerNameCoverYPos); $pdf -> Cell($customerNameCoverWidth, $customerNameCoverHeight, $customerName, 0, 0, 'R'); //Cover Customer Info $pdf -> SetTextColor($textColor[0], $textColor[1], $textColor[2]); $pdf -> SetFont('Arial', '', '12'); $pdf -> SetXY(225, 614); $pdf -> Cell($customerInfoCoverWidth, $customerInfoCoverHeight, $customerAddress, 0, 0, 'R'); $pdf -> SetXY(225, 626); $pdf -> Cell($customerInfoCoverWidth, $customerInfoCoverHeight, $customerCityStateZip, 0, 0, 'R'); $pdf -> SetXY(225, 638); $pdf -> Cell($customerInfoCoverWidth, $customerInfoCoverHeight, $customerPhone, 0, 0, 'R'); // BUILD TOC PAGE-------------------------------------------------- // LIMIT 25 PAGES!!! $backgroundImageToc = "images/modern/tocbackground1.jpg"; $backgroundImageTocXPos = 0; $backgroundImageTocYPos = 0; $backgroundImageTocWidth = 612; $backgroundImageTocHeight = 792; $plantToc1XPos = 53; $plantToc1YPos = 250; $plantToc1Width = 315; $plantToc1Height = 18; $landscapeUseToc1XPos = 381; $landscapeUseToc1YPos = 250; $landscapeUseToc1Width = 105; $landscapeUseToc1Height = 18; $pageNumToc = "3"; $pageNumToc1XPos = 516; $pageNumToc1YPos = 250; $pageNumToc1Width = 60; $pageNumToc1Height = 18; $pdf -> AddPage(); //TOC Background Image $pdf -> Image($backgroundImageToc, $backgroundImageTocXPos, $backgroundImageTocYPos, $backgroundImageTocWidth, $backgroundImageTocHeight); $p = $plantToc1YPos; $l = $landscapeUseToc1YPos; $pn = $pageNumToc1YPos; $pni = $pageNumToc; foreach ($plantID_str_array as $key => $value) { $plantID_use_pair = explode("-", $value); $plantID = $plantID_use_pair[0]; $use = $plantID_use_pair[1]; $sql = "SELECT botanicalName FROM plants WHERE plantID='$plantID' LIMIT 1"; $result = mysql_query($sql); while ($row = mysql_fetch_array($result)) { $botanicalName = $row["botanicalName"]; } //TOC Plant Botanical Name Column $pdf -> SetTextColor($textColor[0], $textColor[1], $textColor[2]); $pdf -> SetFont('Arial', '', '11'); $pdf -> SetXY($plantToc1XPos, $p); $pdf -> Cell($plantToc1Width, $plantToc1Height, $botanicalName, 0, 0, 'L'); //TOC Landscape Use Column $pdf -> SetTextColor($textColor[0], $textColor[1], $textColor[2]); $pdf -> SetFont('Arial', '', '11'); $pdf -> SetXY($landscapeUseToc1XPos, $l); $pdf -> Cell($landscapeUseToc1Width, $landscapeUseToc1Height, $use, 0, 0, 'L'); //TOC Page Number Column $pdf -> SetTextColor($textColor[0], $textColor[1], $textColor[2]); $pdf -> SetFont('Arial', '', '11'); $pdf -> SetXY($pageNumToc1XPos, $pn); $pdf -> Cell($pageNumToc1Width, $pageNumToc1Height, $pni, 0, 0, 'C'); $p = $p + 18; $l = $l + 18; $pn = $pn + 18; $pni++; } //BUILD PLANT PAGES ----------------------------------------------- $logoXPos = 36; $logoYPos = 36; $logoWidth = 55; //$logoHeight = 55; $companyNameXPos = 95; $companyNameYPos = 38; $companyNameWidth = 471; $companyNameHeight = 14; $companyInfoWidth = 202; $companyInfoHeight = 10; $customerNameXPos = 389; $customerNameYPos = 52; $customerNameWidth = 187; $customerNameHeight = 11; $customerInfoWidth = 187; $customerInfoHeight = 10; $useImageBackground = "images/modern/use1.jpg"; //$useImageBackgroundXPos decided in Foreach loop $useImageBackgroundYPos = 100; $useImageBackgroundWidth = 108; $useImageBackgroundHeight = 108; $use1TextXPos = 46; $use1TextYPos = 111; $use1TextWidth = 88; $use1TextHeight = 12; $useDesc1TextXPos = 46; $useDesc1TextYPos = 131; $useDescTextWidth = 88; //$useDesc1TextHeight = 70; $use2TextXPos = 154; $use2TextYPos = 111; $use2TextWidth = 88; $use2TextHeight = 12; $useDesc2TextXPos = 154; $useDesc2TextYPos = 131; //$useDesc2TextWidth = 88; //$useDesc2TextHeight = 70; $use3TextXPos = 262; $use3TextYPos = 111; $use3TextWidth = 88; $use3TextHeight = 12; $useDesc3TextXPos = 262; $useDesc3TextYPos = 131; //$useDesc3TextWidth = 88; //$useDesc3TextHeight = 70; $use4TextXPos = 370; $use4TextYPos = 111; $use4TextWidth = 88; $use4TextHeight = 12; $useDesc4TextXPos = 370; $useDesc4TextYPos = 131; //$useDesc4TextWidth = 88; //$useDesc4TextHeight = 70; $use5TextXPos = 478; $use5TextYPos = 111; $use5TextWidth = 88; $use5TextHeight = 12; $useDesc5TextXPos = 478; $useDesc5TextYPos = 131; //$useDesc5TextWidth = 88; //$useDesc5TextHeight = 70; $backgroundImage = "images/modern/usebackground1.jpg"; $backgroundImageXPos = 0; $backgroundImageYPos = 0; $backgroundImageWidth = 612; $backgroundImageHeight = 792; //$image decided in Foreach Loop $imageXPos = 46; $imageYPos = 218; $imageWidth = 255; $imageHeight = 170; $imageDescHeader = "Image Description:"; $imageDescHeaderXPos = 56; $imageDescHeaderYPos = 398; $imageDescHeaderWidth = 235; $imageDescHeaderHeight = 10; //$imageDesc decided in Foreach Loop $imageDescXPos = 56; $imageDescYPos = 416; $imageDescWidth = 235; //$imageDescHeight = 246; $plantNamesHeaderBot = "Botanical Name:"; $plantNamesHeaderCom = "Common Name:"; $plantNamesHeaderWidth = 84; $plantNamesHeaderHeight = 16; $plantNamesWidth = 153; $plantNamesHeight = 16; $hardinessZonesHeader = "Hardiness Zones:"; $plantTypeHeader = "Plant Type:"; $heightHeader = "Plant Height:"; $spreadHeader = "Plant Spread:"; $flowerHeader = "Flower:"; $bloomTimeHeader = "Bloom Time:"; $foliageHeader = "Foliage:"; $fallColorHeader = "Fall Color:"; $fruitHeader = "Fruit:"; $barkHeader = "Bark:"; $lightReqHeader = "Light Req.:"; $soilHeader = "Soil:"; $growthHeader = "Growth Rate:"; $plantDetailsHeaderWidth = 84; $plantDetailsHeaderHeight = 15; $plantDetailsWidth = 153; $plantDetailsHeight = 15; $maintenanceHeader = "Maintenance Information:"; $maintenanceHeaderXPos = 321; $maintenanceHeaderYPos = 488; $maintenanceHeaderWidth = 235; $maintenanceHeaderHeight = 10; $trimmingHeader = "Trimming:"; $trimmingHeaderXPos = 321; $trimmingHeaderYPos = 506; $trimmingHeaderWidth = 63; $trimmingHeaderHeight = 12; $trimmingTextXPos = 384; $trimmingTextYPos = 506; $trimmingTextWidth = 172; //$trimmingTextHeight = 36; $fertilizationHeader = "Fertilization:"; $fertilizationHeaderXPos = 321; $fertilizationHeaderYPos = 548; $fertilizationHeaderWidth = 63; $fertilizationHeaderHeight = 12; $fertilizationTextXPos = 384; $fertilizationTextYPos = 548; $fertilizationTextWidth = 172; //$fertilizationTextHeight = 36; $otherHeader = "Other:"; $otherHeaderXPos = 321; $otherHeaderYPos = 591; $otherHeaderWidth = 63; $otherHeaderHeight = 12; $otherTextXPos = 384; $otherTextYPos = 591; $otherTextWidth = 172; //$otherTextHeight = 72; $pageNo = "3"; $pageNoXPos = 513; $pageNoYPos = 743; $pageNoWidth = 18; $pageNoHeight = 13; foreach ($plantID_str_array as $key => $value) { $plantID_use_pair = explode("-", $value); $plantID = $plantID_use_pair[0]; $use = $plantID_use_pair[1]; $sql = "SELECT * FROM plants WHERE plantID='$plantID' LIMIT 1"; $result = mysql_query($sql); while ($row = mysql_fetch_array($result)) { $botanicalName = $row["botanicalName"]; $commonName = $row["commonName"]; $hardinessZones = $row["hardinessZones"]; $plantType = $row["plantType"]; $height = $row["height"]; $spread = $row["spread"]; $flower = $row["flower"]; $bloomTime = $row["bloomTime"]; $foliage = $row["foliage"]; $fallColor = $row["fallColor"]; $fruit = $row["fruit"]; $bark = $row["bark"]; $lightReq = $row["lightReq"]; $soil = $row["soil"]; $growth = $row["growth"]; $trimming = $row["trimming"]; $fertilization = $row["fertilization"]; $otherMaintenance = $row["otherMaintenance"]; $use1 = $row["use1"]; $use2 = $row["use2"]; $use3 = $row["use3"]; $use4 = $row["use4"]; $use5 = $row["use5"]; $useDesc1 = $row["useDesc1"]; $useDesc2 = $row["useDesc2"]; $useDesc3 = $row["useDesc3"]; $useDesc4 = $row["useDesc4"]; $useDesc5 = $row["useDesc5"]; $imageDesc1 = $row["imageDesc1"]; $imageDesc2 = $row["imageDesc2"]; $imageDesc3 = $row["imageDesc3"]; $imageDesc4 = $row["imageDesc4"]; $imageDesc5 = $row["imageDesc5"]; } if ($use == $use1) { $useImageBackgroundXPos = 36; $image = "images/plants/$botanicalName/LU-1.jpg"; $imageDesc = $imageDesc1; } elseif ($use == $use2) { $useImageBackgroundXPos = 144; $image = "images/plants/$botanicalName/LU-2.jpg"; $imageDesc = $imageDesc2; } elseif ($use == $use3) { $useImageBackgroundXPos = 252; $image = "images/plants/$botanicalName/LU-3.jpg"; $imageDesc = $imageDesc3; } elseif ($use == $use4) { $useImageBackgroundXPos = 360; $image = "images/plants/$botanicalName/LU-4.jpg"; $imageDesc = $imageDesc4; } elseif ($use == $use5) { $useImageBackgroundXPos =468; $image = "images/plants/$botanicalName/LU-5.jpg"; $imageDesc = $imageDesc5; } $pdf -> AddPage(); //Company Logo Header $pdf -> Image($companyLogo, $logoXPos, $logoYPos, $logoWidth, ''); //Company Name Header $pdf -> SetTextColor($headerTextColor[0], $headerTextColor[1], $headerTextColor[2]); $pdf -> SetFont('Arial', 'B', '14'); $pdf -> SetXY($companyNameXPos, $companyNameYPos); $pdf -> Cell($companyNameWidth, $companyNameHeight, $companyName, 0, 0, 'L'); //Company Info Header $pdf -> SetTextColor($textColor[0], $textColor[1], $textColor[2]); $pdf -> SetFont('Arial', '', '10'); $pdf -> SetXY(95, 52); $pdf -> Cell($companyInfoWidth, $companyInfoHeight, $companyAddress, 0, 0, 'L'); $pdf -> SetXY(95, 62); $pdf -> Cell($companyInfoWidth, $companyInfoHeight, $companyCityStateZip, 0, 0, 'L'); $pdf -> SetXY(95, 72); $pdf -> Cell($companyInfoWidth, $companyInfoHeight, $companyPhone, 0, 0, 'L'); $pdf -> SetXY(95, 82); $pdf -> Cell($companyInfoWidth, $companyInfoHeight, $companyWeb, 0, 0, 'L'); //Customer Name Header $pdf -> SetTextColor($headerTextColor[0], $headerTextColor[1], $headerTextColor[2]); $pdf -> SetFont('Arial', 'B', '11'); $pdf -> SetXY($customerNameXPos, $customerNameYPos); $pdf -> Cell($customerNameWidth, $customerNameHeight, $customerName, 0, 0, 'L'); //Customer Info Header $pdf -> SetTextColor($textColor[0], $textColor[1], $textColor[2]); $pdf -> SetFont('Arial', '', '10'); $pdf -> SetXY(389, 63); $pdf -> Cell($customerInfoWidth, $customerInfoHeight, $customerAddress, 0, 0, 'L'); $pdf -> SetXY(389, 73); $pdf -> Cell($customerInfoWidth, $customerInfoHeight, $customerCityStateZip, 0, 0, 'L'); $pdf -> SetXY(389, 83); $pdf -> Cell($customerInfoWidth, $customerInfoHeight, $customerPhone, 0, 0, 'L'); //Use Background Image (Dynamic from If Else) $pdf -> Image($useImageBackground, $useImageBackgroundXPos, $useImageBackgroundYPos, $useImageBackgroundWidth, $useImageBackgroundHeight); //Use 1 $pdf -> SetTextColor($headerTextColor[0], $headerTextColor[1], $headerTextColor[2]); $pdf -> SetFont('Arial', 'B', '14'); $pdf -> SetXY($use1TextXPos, $use1TextYPos); $pdf -> Cell($use1TextWidth, $use1TextHeight, $use1, 0, 0, 'L'); //Use 1 Description $pdf -> SetTextColor($headerTextColor[0], $headerTextColor[1], $headerTextColor[2]); $pdf -> SetFont('Arial', '', '10'); $pdf -> SetXY($useDesc1TextXPos, $useDesc1TextYPos); $text = $useDesc1; $pdf -> WordWrap($text, $useDescTextWidth); $pdf -> Write(10, $text); //Use 2 $pdf -> SetTextColor($headerTextColor[0], $headerTextColor[1], $headerTextColor[2]); $pdf -> SetFont('Arial', 'B', '14'); $pdf -> SetXY($use2TextXPos, $use2TextYPos); $pdf -> Cell($use2TextWidth, $use2TextHeight, $use2, 0, 0, 'L'); //Use 2 Description $pdf -> SetTextColor($headerTextColor[0], $headerTextColor[1], $headerTextColor[2]); $pdf -> SetFont('Arial', '', '10'); $pdf -> SetXY($useDesc2TextXPos, $useDesc2TextYPos); $text = $useDesc2; $pdf -> WordWrap($text, $useDescTextWidth); $pdf -> Write(10, $text); //Use 3 $pdf -> SetTextColor($headerTextColor[0], $headerTextColor[1], $headerTextColor[2]); $pdf -> SetFont('Arial', 'B', '14'); $pdf -> SetXY($use3TextXPos, $use3TextYPos); $pdf -> Cell($use3TextWidth, $use3TextHeight, $use3, 0, 0, 'L'); //Use 3 Description $pdf -> SetTextColor($headerTextColor[0], $headerTextColor[1], $headerTextColor[2]); $pdf -> SetFont('Arial', '', '10'); $pdf -> SetXY($useDesc3TextXPos, $useDesc3TextYPos); $text = $useDesc3; $pdf -> WordWrap($text, $useDescTextWidth); $pdf -> Write(10, $text); //Use 4 $pdf -> SetTextColor($headerTextColor[0], $headerTextColor[1], $headerTextColor[2]); $pdf -> SetFont('Arial', 'B', '14'); $pdf -> SetXY($use4TextXPos, $use4TextYPos); $pdf -> Cell($use4TextWidth, $use4TextHeight, $use4, 0, 0, 'L'); //Use 4 Description $pdf -> SetTextColor($headerTextColor[0], $headerTextColor[1], $headerTextColor[2]); $pdf -> SetFont('Arial', '', '10'); $pdf -> SetXY($useDesc4TextXPos, $useDesc4TextYPos); $text = $useDesc4; $pdf -> WordWrap($text, $useDescTextWidth); $pdf -> Write(10, $text); //Use 5 $pdf -> SetTextColor($headerTextColor[0], $headerTextColor[1], $headerTextColor[2]); $pdf -> SetFont('Arial', 'B', '14'); $pdf -> SetXY($use5TextXPos, $use5TextYPos); $pdf -> Cell($use5TextWidth, $use5TextHeight, $use5, 0, 0, 'L'); //Use 5 Description $pdf -> SetTextColor($headerTextColor[0], $headerTextColor[1], $headerTextColor[2]); $pdf -> SetFont('Arial', '', '10'); $pdf -> SetXY($useDesc5TextXPos, $useDesc5TextYPos); $text = $useDesc5; $pdf -> WordWrap($text, $useDescTextWidth); $pdf -> Write(10, $text); //Page Background Image $pdf -> Image($backgroundImage, $backgroundImageXPos, $backgroundImageYPos, $backgroundImageWidth, $backgroundImageHeight); //Plant Image (Dynamic from If Else) $pdf -> Image($image, $imageXPos, $imageYPos, $imageWidth, $imageHeight); //Image Desc Header $pdf -> SetTextColor($headerTextColor[0], $headerTextColor[1], $headerTextColor[2]); $pdf -> SetFont('Arial', 'B', '11'); $pdf -> SetXY($imageDescHeaderXPos, $imageDescHeaderYPos); $pdf -> Cell($imageDescHeaderWidth, $imageDescHeaderHeight, $imageDescHeader, 0, 0, 'L'); //Image Desc (Dynamic from If Else) $pdf -> SetTextColor($textColor[0], $textColor[1], $textColor[2]); $pdf -> SetFont('Arial', '', '10'); $pdf -> SetXY($imageDescXPos, $imageDescYPos); $text = $imageDesc; $pdf -> WordWrap($text, $imageDescWidth); $pdf -> Write(10, $text); //Plant Names Header $pdf -> SetTextColor($headerTextColor[0], $headerTextColor[1], $headerTextColor[2]); $pdf -> SetFont('Arial', 'B', '10'); $pdf -> SetXY(321, 228); $pdf -> Cell($plantNamesHeaderWidth, $plantNamesHeaderHeight, $plantNamesHeaderBot, 0, 0, 'L'); $pdf -> SetXY(321, 244); $pdf -> Cell($plantNamesHeaderWidth, $plantNamesHeaderHeight, $plantNamesHeaderCom, 0, 0, 'L'); //Plant Names $pdf -> SetTextColor($textColor[0], $textColor[1], $textColor[2]); $pdf -> SetFont('Arial', '', '10'); $pdf -> SetXY(405, 228); $pdf -> Cell($plantNamesWidth, $plantNamesHeight, $botanicalName, 0, 0, 'L'); $pdf -> SetXY(405, 244); $pdf -> Cell($plantNamesWidth, $plantNamesHeight, $commonName, 0, 0, 'L'); //Plant Details Header $pdf -> SetTextColor($headerTextColor[0], $headerTextColor[1], $headerTextColor[2]); $pdf -> SetFont('Arial', 'B', '10'); $pdf -> SetXY(321, 261); $pdf -> Cell($plantDetailsHeaderWidth, $plantDetailsHeaderHeight, $hardinessZonesHeader, 0, 0, 'L'); $pdf -> SetXY(321, 276); $pdf -> Cell($plantDetailsHeaderWidth, $plantDetailsHeaderHeight, $plantTypeHeader, 0, 0, 'L'); $pdf -> SetXY(321, 291); $pdf -> Cell($plantDetailsHeaderWidth, $plantDetailsHeaderHeight, $heightHeader, 0, 0, 'L'); $pdf -> SetXY(321, 306); $pdf -> Cell($plantDetailsHeaderWidth, $plantDetailsHeaderHeight, $spreadHeader, 0, 0, 'L'); $pdf -> SetXY(321, 321); $pdf -> Cell($plantDetailsHeaderWidth, $plantDetailsHeaderHeight, $flowerHeader, 0, 0, 'L'); $pdf -> SetXY(321, 336); $pdf -> Cell($plantDetailsHeaderWidth, $plantDetailsHeaderHeight, $bloomTimeHeader, 0, 0, 'L'); $pdf -> SetXY(321, 351); $pdf -> Cell($plantDetailsHeaderWidth, $plantDetailsHeaderHeight, $foliageHeader, 0, 0, 'L'); $pdf -> SetXY(321, 366); $pdf -> Cell($plantDetailsHeaderWidth, $plantDetailsHeaderHeight, $fallColorHeader, 0, 0, 'L'); $pdf -> SetXY(321, 381); $pdf -> Cell($plantDetailsHeaderWidth, $plantDetailsHeaderHeight, $fruitHeader, 0, 0, 'L'); $pdf -> SetXY(321, 396); $pdf -> Cell($plantDetailsHeaderWidth, $plantDetailsHeaderHeight, $barkHeader, 0, 0, 'L'); $pdf -> SetXY(321, 411); $pdf -> Cell($plantDetailsHeaderWidth, $plantDetailsHeaderHeight, $lightReqHeader, 0, 0, 'L'); $pdf -> SetXY(321, 426); $pdf -> Cell($plantDetailsHeaderWidth, $plantDetailsHeaderHeight, $soilHeader, 0, 0, 'L'); $pdf -> SetXY(321, 441); $pdf -> Cell($plantDetailsHeaderWidth, $plantDetailsHeaderHeight, $growthHeader, 0, 0, 'L'); //Plant Details $pdf -> SetTextColor($textColor[0], $textColor[1], $textColor[2]); $pdf -> SetFont('Arial', '', '10'); $pdf -> SetXY(405, 261); $pdf -> Cell($plantDetailsWidth, $plantDetailsHeight, $hardinessZones, 0, 0, 'L'); $pdf -> SetXY(405, 276); $pdf -> Cell($plantDetailsWidth, $plantDetailsHeight, $plantType, 0, 0, 'L'); $pdf -> SetXY(405, 291); $pdf -> Cell($plantDetailsWidth, $plantDetailsHeight, $height, 0, 0, 'L'); $pdf -> SetXY(405, 306); $pdf -> Cell($plantDetailsWidth, $plantDetailsHeight, $spread, 0, 0, 'L'); $pdf -> SetXY(405, 321); $pdf -> Cell($plantDetailsWidth, $plantDetailsHeight, $flower, 0, 0, 'L'); $pdf -> SetXY(405, 336); $pdf -> Cell($plantDetailsWidth, $plantDetailsHeight, $bloomTime, 0, 0, 'L'); $pdf -> SetXY(405, 351); $pdf -> Cell($plantDetailsWidth, $plantDetailsHeight, $foliage, 0, 0, 'L'); $pdf -> SetXY(405, 366); $pdf -> Cell($plantDetailsWidth, $plantDetailsHeight, $fallColor, 0, 0, 'L'); $pdf -> SetXY(405, 381); $pdf -> Cell($plantDetailsWidth, $plantDetailsHeight, $fruit, 0, 0, 'L'); $pdf -> SetXY(405, 396); $pdf -> Cell($plantDetailsWidth, $plantDetailsHeight, $bark, 0, 0, 'L'); $pdf -> SetXY(405, 411); $pdf -> Cell($plantDetailsWidth, $plantDetailsHeight, $lightReq, 0, 0, 'L'); $pdf -> SetXY(405, 426); $pdf -> Cell($plantDetailsWidth, $plantDetailsHeight, $soil, 0, 0, 'L'); $pdf -> SetXY(405, 441); $pdf -> Cell($plantDetailsWidth, $plantDetailsHeight, $growth, 0, 0, 'L'); //Maintenance Info Header $pdf -> SetTextColor($headerTextColor[0], $headerTextColor[1], $headerTextColor[2]); $pdf -> SetFont('Arial', 'B', '11'); $pdf -> SetXY($maintenanceHeaderXPos, $maintenanceHeaderYPos); $pdf -> Cell($maintenanceHeaderWidth, $maintenanceHeaderHeight, $maintenanceHeader, 0, 0, 'L'); //Trimming Header $pdf -> SetTextColor($headerTextColor[0], $headerTextColor[1], $headerTextColor[2]); $pdf -> SetFont('Arial', 'B', '10'); $pdf -> SetXY($trimmingHeaderXPos, $trimmingHeaderYPos); $pdf -> Cell($trimmingHeaderWidth, $trimmingHeaderHeight, $trimmingHeader, 0, 0, 'L'); //Trimming $pdf -> SetTextColor($textColor[0], $textColor[1], $textColor[2]); $pdf -> SetFont('Arial', '', '10'); $pdf -> SetXY($trimmingTextXPos, $trimmingTextYPos); $text = $trimming; $pdf -> WordWrap($text, $trimmingTextWidth); $pdf -> Write(10, $text); //Fertilization Header $pdf -> SetTextColor($headerTextColor[0], $headerTextColor[1], $headerTextColor[2]); $pdf -> SetFont('Arial', 'B', '10'); $pdf -> SetXY($fertilizationHeaderXPos, $fertilizationHeaderYPos); $pdf -> Cell($fertilizationHeaderWidth, $fertilizationHeaderHeight, $fertilizationHeader, 0, 0, 'L'); //Fertilization $pdf -> SetTextColor($textColor[0], $textColor[1], $textColor[2]); $pdf -> SetFont('Arial', '', '10'); $pdf -> SetXY($fertilizationTextXPos, $fertilizationTextYPos); $text = $fertilization; $pdf -> WordWrap($text, $fertilizationTextWidth); $pdf -> Write(10, $text); //Other Maintenance Header $pdf -> SetTextColor($headerTextColor[0], $headerTextColor[1], $headerTextColor[2]); $pdf -> SetFont('Arial', 'B', '10'); $pdf -> SetXY($otherHeaderXPos, $otherHeaderYPos); $pdf -> Cell($otherHeaderWidth, $otherHeaderHeight, $otherHeader, 0, 0, 'L'); //Other Maintenance $pdf -> SetTextColor($textColor[0], $textColor[1], $textColor[2]); $pdf -> SetFont('Arial', '', '10'); $pdf -> SetXY($otherTextXPos, $otherTextYPos); $text = $otherMaintenance; $pdf -> WordWrap($text, $otherTextWidth); $pdf -> Write(10, $text); //Page Number Footer $pdf -> SetTextColor($footerTextColor[0], $footerTextColor[1], $footerTextColor[2]); $pdf -> SetFont('Arial', '', '8'); $pdf -> SetXY($pageNoXPos, $pageNoYPos); $pdf -> Cell($pageNoWidth, $pageNoHeight, $pageNo, 0, 0, 'R'); $pageNo++; } //OUTPUT PDF $pdf -> Output("$customerName.pdf", "I"); unset($_SESSION["book_array"]); unset($_SESSION["plantUse"]); unset($_SESSION["customerName"]); unset($_SESSION["customerAddress"]); unset($_SESSION["customerCity"]); unset($_SESSION["customerState"]); unset($_SESSION["customerZip"]); unset($_SESSION["customerPhone"]); unset($_SESSION["book_template"]); } elseif ($book_template = "2") { //////FLORAL BOOK STYLE/////////////////////////////////////////// //BUILD COVER PAGE ------------------------------------------- //BUILD TOC PAGE ------------------------------------------- //BUILD PLANT PAGES ------------------------------------------- } elseif ($book_template == "3") { //////NOTES BOOK STYLE/////////////////////////////////////////// //BUILD COVER PAGE ------------------------------------------- //BUILD TOC PAGE ------------------------------------------- //BUILD PLANT PAGES ------------------------------------------- } } ?> Link to comment https://forums.phpfreaks.com/topic/257993-fpdf-class-extension/#findComment-1322498 Share on other sites More sharing options...
KevinM1 Posted February 29, 2012 Share Posted February 29, 2012 Okay, so what line is throwing the error? Link to comment https://forums.phpfreaks.com/topic/257993-fpdf-class-extension/#findComment-1322523 Share on other sites More sharing options...
wchamber22 Posted February 29, 2012 Author Share Posted February 29, 2012 Kevin the line is as follows: $pdf -> WordWrap($text, $useDescTextWidth); This is the first call to the WordWrap function, I can fix the rest after we get this squared away! Thanks again. Link to comment https://forums.phpfreaks.com/topic/257993-fpdf-class-extension/#findComment-1322527 Share on other sites More sharing options...
wchamber22 Posted February 29, 2012 Author Share Posted February 29, 2012 In case you forgot the error message is as follows: Fatal error: Call to undefined method FPDF::WordWrap() Thanks Link to comment https://forums.phpfreaks.com/topic/257993-fpdf-class-extension/#findComment-1322531 Share on other sites More sharing options...
trq Posted March 1, 2012 Share Posted March 1, 2012 Your $pdf variable holds an instance of FPDF not PDF. Change this line: $pdf = new FPDF('P', 'pt', 'Letter'); to $pdf = new PDF('P', 'pt', 'Letter'); Link to comment https://forums.phpfreaks.com/topic/257993-fpdf-class-extension/#findComment-1322556 Share on other sites More sharing options...
wchamber22 Posted March 1, 2012 Author Share Posted March 1, 2012 Thorpe is >= THE MAN, thanks, SOLVED! Link to comment https://forums.phpfreaks.com/topic/257993-fpdf-class-extension/#findComment-1322561 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.