PHP - Moved: Error Generating Pdf With Fpdf Fpdi
This topic has been moved to Other Libraries and Frameworks.
http://www.phpfreaks.com/forums/index.php?topic=357017.0 Similar TutorialsThis topic has been moved to Other Libraries and Frameworks. http://www.phpfreaks.com/forums/index.php?topic=323892.0 This topic has been moved to Other Libraries and Frameworks. http://www.phpfreaks.com/forums/index.php?topic=321311.0 This topic has been moved to Other Libraries and Frameworks. http://www.phpfreaks.com/forums/index.php?topic=357112.0 hi, i'm using the fpdf library to generate PDF's from form input. It all worked well on my local host, but now that i have transferred to a web server it displays the following error when trying to generate a PDF. Warning: require(/fpdf16/fpdf.php) [function.require]: failed to open stream: No such file or directory in /home/ddgq0o2n/public_html/quote_builder/pdf.php on line 2 Fatal error: require() [function.require]: Failed opening required '/fpdf16/fpdf.php' (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/ddgq0o2n/public_html/quote_builder/pdf.php on line 2 i have searched for "include_path", but can't find it anywhere. i'm thinking it's a server problem, where the library may not be compatible or something needs to be switched on, as it worked fine on my local host. any help and suggestions welcome thanks. Hi, I'm creating a PDF document using the FPDF library. All is fine, using a sample image that came with the library. However, I need to get the data for the PDF from a database. The data's fine - the query is performed and the data prints out as I need. However, there's one line which takes a value which is a filepath. When I put that into the following line, I get an error from FPDF: Code: $this->Image($row['imgpath'],10,10,190); Error produced: FPDF error: Image file has no extension and no type was specified: However, if I print out the value of $row['imgpath'] and manually insert it into the code as follows, it works fine: Code: $this->Image('../assets/images/products/5777A.jpg',10,10,190); I've come across this problem once before but can't for the life of me remember what the solution was. It was something to do with how I was reading the value into the code, I think. Can anyone jog my memory, please?? This topic has been moved to Ajax Help. http://www.phpfreaks.com/forums/index.php?topic=354853.0 This topic has been moved to PHP Regex. http://www.phpfreaks.com/forums/index.php?topic=333172.0 This topic has been moved to PHP Applications. http://www.phpfreaks.com/forums/index.php?topic=345334.0 This topic has been moved to Third Party PHP Scripts. http://www.phpfreaks.com/forums/index.php?topic=315281.0 This topic has been moved to PHP Applications. http://www.phpfreaks.com/forums/index.php?topic=344105.0 This topic has been moved to Third Party PHP Scripts. http://www.phpfreaks.com/forums/index.php?topic=323310.0 This topic has been moved to Apache HTTP Server. http://www.phpfreaks.com/forums/index.php?topic=343321.0 This topic has been moved to Other Libraries and Frameworks. http://www.phpfreaks.com/forums/index.php?topic=311225.0 Hi All, New here to PHP. Was designing a pdf file using FPDF. Here is my problem: I want to display a table. I want to have rows and columns. For example the code below gives me one row perfectly: $this->SetFont('Arial','',10); // Logo //$this->Image(SETTING_MAIN_URL . 'images/logo.png',10,19,33); $this->Image($this->image_folder . 'pdf_logo.png',10,5,33); // Right hand header $this->SetFont('Arial','B',13); $this->Text(45,14,"test test test"); $this->SetFont('','',10); $this->Text(10,22,"Account: "); $this->Text(25,22,Sessionmanager::getUser()->getAccount()); $this->Text(10,27,"Date: "); $this->Text(20,27,$today = date("m.d.y")); $this->Ln(20); $this->Cell(30,7,"Number",1,0,'L'); $this->Cell(33,7,"NAME",1); $this->Cell(33,7,"address",1); $this->Cell(33,7,"address2",1); $this->Cell(33,7,"address3",1); $this->Cell(33,7,"country",1); $this->Ln(10); $i=0; $this->SetFont('Arial','B',5); for($i=0;$i<sizeof($this->list);$i++) { $consignment= $this->list[$i]; $this->Cell(33,7,$consignment->getBIll(),1,'L'); $this->Cell(33,7,"asdfasdfasdf",1,'L'); $this->MultiCell(33,7,$consignment->getCom()."\n".$consignment->AddressLine1()."\n".$consignment->getAddressLine2()."\n".$consignment->getCity()."\n".$consignment->getCountry(),1,'L'); $this->Ln(1); Now When I add this line to the code just before $this->Ln(1) $this->Cell(33,7,"test 4",'L'); It goes to a new line for some reason even before i call the $this->Ln(). Any ideas? I want to display the "test4" in the same row too. So i guess my question basically is that i dont understand how fpdf distinguishes between when to switch to a new row and when to keep on adding to the same row. Thank you very much for your help. I would like to create a page in pdf format and I found it possible by using fpdf, but how would I create a page that looks something like this: 1 Flathead nails 3/4" 1,170.00KG @ 60.00 70,200.00 2 Drip edge using plain G.I sheet 3,304.00PCS @ 80.00 264,320.00 4" x 8" x Ga. #24 including cutting and bending (as per drawing). requirements : 472 sheets 1 sheet = 7 pieces 3 Wall flashing using plain G.I sheet 712.00PCS @ 70.00 49,840.00 4" x 8" x Ga. #24 including cutting and bending (as per drawing) requirements : 89 sheets 1 sheet = 8 pieces ********************* NOTHING FOLLOWS ********************* I really need something like this that shows no border because borders are already pre printed. Before posting here I googled it first And found a code that would possibly create my concern but I found some problem of the code and I need some help to make this working. Existing code: Code: [Select] <?php require('fpdf/fpdf.php'); $pdf = new FPDF(); $pdf->AddFont('Bookman','','Bookos.php'); $pdf->AddPage(); $pdf->SetFont('Bookman','',14); $x=16; $y=26; $width=30; $height=35; $leftmargin=16; $content = "content"; //$content = "This is a very long content, this must goes to the next line. "; for ($r=0;$r<5;$r++){ for ($c=0;$c<6;$c++){ $pdf->SetY($y); //set pointer back to previous values $pdf->SetX($x); $x=$pdf->GetX()+$width; $y=$pdf->GetY(); $pdf->MultiCell($width,$height,$content,1,'L'); } $y+=$height; $x=$leftmargin; $pdf->SetY($y); } $pdf->Output(); ?> There are two problems with this code: 1.) Only the first page is working well. 2.) It will not create a newline in each cell if the content is long.... Tnx in advance to everyone..... pls..... I need a little help with fpdf: Code: [Select] <?php include_once("connect.php"); if($_POST['submit']){ $startdate=$_POST['startdate']; $enddate=$_POST['enddate']; $sql = mysql_query("SELECT * FROM transactions where date between '$startdate' and '$enddate' "); while($row = mysql_fetch_array($sql)){{ $date = $row["date"]; $product = $row["product"]; $month = $row["month"]; $day = $row["day"]; $year = $row["year"]; $category = $row["category"]; $academy = $row["academy"]; $price = $row["price"]; $priceunit = $row["priceunit"]; $quantity = $row["quantity"]; } // Query member data from the database and ready it for display require('fpdf.php'); class PDF extends FPDF { function EAN13($x=1, $y, $barcode, $h=16, $w=.35) { $this->Barcode(13,5,$barcode,$h,$w,13); } function UPC_A($x, $y, $barcode, $h=16, $w=.35) { $this->Barcode($x,$y,$barcode,$h,$w,12); } function GetCheckDigit($barcode) { //Compute the check digit $sum=0; for($i=1;$i<=11;$i+=2) $sum+=3*$barcode[$i]; for($i=0;$i<=10;$i+=2) $sum+=$barcode[$i]; $r=$sum%10; if($r>0) $r=10-$r; return $r; } function TestCheckDigit($barcode) { //Test validity of check digit $sum=0; for($i=1;$i<=11;$i+=2) $sum+=3*$barcode[$i]; for($i=0;$i<=10;$i+=2) $sum+=$barcode[$i]; return ($sum+$barcode[12])%10==0; } function Barcode($x, $y, $barcode, $h, $w, $len) { //Padding $barcode=str_pad($barcode,$len-1,'0',STR_PAD_LEFT); if($len==12) $barcode='0'.$barcode; //Add or control the check digit if(strlen($barcode)==12) $barcode.=$this->GetCheckDigit($barcode); elseif(!$this->TestCheckDigit($barcode)) $this->Error('Incorrect check digit'); //Convert digits to bars $codes=array( 'A'=>array( '0'=>'0001101','1'=>'0011001','2'=>'0010011','3'=>'0111101','4'=>'0100011', '5'=>'0110001','6'=>'0101111','7'=>'0111011','8'=>'0110111','9'=>'0001011'), 'B'=>array( '0'=>'0100111','1'=>'0110011','2'=>'0011011','3'=>'0100001','4'=>'0011101', '5'=>'0111001','6'=>'0000101','7'=>'0010001','8'=>'0001001','9'=>'0010111'), 'C'=>array( '0'=>'1110010','1'=>'1100110','2'=>'1101100','3'=>'1000010','4'=>'1011100', '5'=>'1001110','6'=>'1010000','7'=>'1000100','8'=>'1001000','9'=>'1110100') ); $parities=array( '0'=>array('A','A','A','A','A','A'), '1'=>array('A','A','B','A','B','B'), '2'=>array('A','A','B','B','A','B'), '3'=>array('A','A','B','B','B','A'), '4'=>array('A','B','A','A','B','B'), '5'=>array('A','B','B','A','A','B'), '6'=>array('A','B','B','B','A','A'), '7'=>array('A','B','A','B','A','B'), '8'=>array('A','B','A','B','B','A'), '9'=>array('A','B','B','A','B','A') ); $code='101'; $p=$parities[$barcode[0]]; for($i=1;$i<=6;$i++) $code.=$codes[$p[$i-1]][$barcode[$i]]; $code.='01010'; for($i=7;$i<=12;$i++) $code.=$codes['C'][$barcode[$i]]; $code.='101'; //Draw bars for($i=0;$i<strlen($code);$i++) { if($code[$i]=='1') $this->Rect($x+$i*$w,$y,$w,$h,'F'); } //Print text uder barcode $this->SetFont('Arial','B',12); $this->Text($x,$y+$h+11/$this->k,substr($barcode,-$len)); } //Instanciation of inherited class function Header() { global $name; global $date; global $product; global $month; global $day; global $year; global $academy; global $price; global $priceunit; global $category; global $quantity; // get the variable $name1 into the scope of this function //Logo //Arial bold 15 $this->SetFont('Arial','B',15); //Move to the right $this->Cell(70); //Title $this->Cell(0,0,'Please bring this to the next Scout Meeting',0,0,C); // Query member data from the database and ready it for display //Line break $this->Ln(20); $this->Cell(0,0,'',1,0); $this->Ln(20); $this->cell(50,10, 'Product:', 1,0); $this->cell(50,10, 'Category:', 1,0); $this->cell(50,10, 'Price:', 1,0); $this->Ln(10); $this->cell(50,10,$product, 'L,R',0); $this->cell(50,10, $category, 'L',0); $this->cell(50,10, $price, 'L,R',0); } //Page footer function Footer() { //Position at 1.5 cm from bottom $this->SetY(-15); //Arial italic 8 $this->SetFont('Arial','B',8); //Page number $this->Cell(0,10,'Page '.$this->PageNo().'/{nb}',0,0,'C'); } }} //Instanciation of inherited class $pdf=new PDF(); $pdf->AliasNbPages(); $pdf->AddPage(); $pdf->SetFont('Arial','B',12); $pdf->Output('ticket.pdf', 'I');}?> Problem I am having is running the code through a loop. I need the products and such to run through the loop of querying the database so that all the entries in database meet the specs. please help:) Hello,
I am trying to print the invoice in pdf, using fpdf. i am not getting how to do it. I am able to display line items , but its not in proper format. I tried changing X, Y positions, but its not going into my head . Also i want to display Logo and address in left side, invoice number and order date in right side.
Here is the code i have done so far... Please please help me in this
<?php require('includes/fpdf/fpdf.php'); //Connect to your database include("connect/DB_Connect.php"); $id = $_GET['id']; //Select the Products you want to show in your PDF file $result=mysql_query("select invoice_no, order_no, order_date, completion_date, artwork, customer_po, order_quantity, comments, order_amount from invoice where invoice_no='".$id."' ") or die(mysql_error()); $number_of_products = mysql_numrows($result); //Initialize the 3 columns and the total $column_order_date = ""; $column_order_no = ""; $column_artwork = ""; $column_cpo = ""; $column_order_quantity = ""; $column_order_amount = ""; $column_comments = ""; $total = 0; //For each row, add the field to the corresponding column while($row = mysql_fetch_array($result)) { $order_date = $row["order_date"]; $order_no = $row["order_no"]; $artwork = $row['artwork']; $cpo = $row['customer_po']; $oquantity = $row['order_quantity']; $oamount = $row['order_amount']; $comments = $row['comments']; //$price_to_show = number_format($row["Price"],',','.','.'); $column_order_date = $column_order_date.$order_date."\n"; $column_order_no = $column_order_no.$order_no."\n"; $column_artwork = $column_artwork.$artwork."\n"; $column_cpo = $column_cpo.$cpo."\n"; $column_order_quantity = $column_order_quantity.$oquantity."\n"; $column_order_amount = $column_order_amount.$oamount."\n"; $column_comments = $column_comments.$comments."\n"; //Sum all the Prices (TOTAL) $total = $total+$oamount; } mysql_close(); //Create a new PDF file $pdf=new FPDF(); $pdf->AddPage(); //Fields Name position $Y_Fields_Name_position = 20; //Table position, under Fields Name $Y_Table_Position = 26; //First create each Field Name //Gray color filling each Field Name box $pdf->SetFillColor(232,232,232); //Bold Font for Field Name $pdf->SetFont('Arial','B',12); $pdf->SetY($Y_Fields_Name_position); $pdf->SetX(5); $pdf->Cell(25,6,'Order Date',1,0,'L',1); $pdf->SetX(30); $pdf->Cell(50,6,'Graphixide Order No',1,0,'L',1); $pdf->SetX(75); $pdf->Cell(40,6,'Artwork',1,0,'L',1); $pdf->SetX(110); $pdf->Cell(20,6,'PO #',1,0,'L',1); $pdf->SetX(130); $pdf->Cell(20,6,'Quantity',1,0,'L',1); $pdf->SetX(150); $pdf->Cell(25,6,'Amount',1,0,'L',1); $pdf->SetX(175); $pdf->Cell(25,6,'Comments',1,0,'L',1); //Now show the 3 columns $pdf->SetFont('Arial','',12); $pdf->SetY($Y_Table_Position); $pdf->SetX(5); $pdf->MultiCell(25,6,$column_order_date,1); $pdf->SetY($Y_Table_Position); $pdf->SetX(30); $pdf->MultiCell(80,6,$column_order_no,1); $pdf->SetY($Y_Table_Position); $pdf->SetX(75); $pdf->MultiCell(40,6,$column_artwork,1); $pdf->SetY($Y_Table_Position); $pdf->SetX(110); $pdf->MultiCell(20,9,$column_cpo,1); $pdf->SetY($Y_Table_Position); $pdf->SetX(130); $pdf->MultiCell(20,6,$column_order_quantity,1); $pdf->SetY($Y_Table_Position); $pdf->SetX(150); $pdf->MultiCell(75,6,$column_order_amount,1); $pdf->SetY($Y_Table_Position); $pdf->SetX(175); $pdf->MultiCell(25,10,$column_comments,1); $pdf->SetY($Y_Table_Position); $pdf->SetX(150); $pdf->MultiCell(130,6,'$ '.$total,1,'R'); //Create lines (boxes) for each ROW (Product) //If you don't use the following code, you don't create the lines separating each row $i = 0; while ($i < $number_of_products) { $pdf->SetX(45); $pdf->MultiCell(120,6,'',1); $i = $i +1; } $pdf->Output(); ?>Here is the output of this code ss.PNG 32.3KB 7 downloads Hi I am using the Quote fpdf library to generate a PDF. What I'm looking to do, is to possibly 'nest' cells inside another cell. Code: [Select] ============================ | Main Cell | | ============= =========== | | Cell 2 | | Cell 3 | | ============= =========== | | ============================ So you can see I have one, main cell, and inside this I have Cell 2 and Cell 3, which I'd like inside/nested the main cell. Is this possible using the fpdf library? Thanks 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: Code: [Select] <?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: Code: [Select] <?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. Does anyone knows if FPDF supports Norwegian letters or not? When I write codes of letters it is not showing letter. Are there any command to specify charset? For example in this code is it possible to specify charset? $pdf=new FPDF(); $pdf->AddPage(); $pdf->SetFont('Arial','',14); $pdf->Write(5,'Følgende '); |