PHP - Php7 Problem With Fpdf
Fatal error: Uncaught Error: Call to undefined method FPDF::TextWithRotation() in C:\laragon\www\arx\fpdf\rot.php:8 Stack trace: #0 {main} thrown in C:\laragon\www\arx\fpdf\rot.php on line 8 this issue is coming in my file don't knw i want to rotate my text in pdf
<?php require('rpdf.php');
$pdf=new FPDF();
$pdf->AddPage(); $pdf->SetFont('Arial','',40); $pdf->TextWithRotation(50,65,'Hello',45,-45); $pdf->SetFontSize(30); $pdf->TextWithDirection(110,50,'world!','L'); $pdf->TextWithDirection(110,50,'world!','U'); $pdf->TextWithDirection(110,50,'world!','R'); $pdf->TextWithDirection(110,50,'world!','D'); $pdf->Output(); ?>
please help me Edited August 11, 2020 by Ali9980Similar Tutorials
I have used this program for many years without problems. I have not altered the file in any way, so why is this happening? Is it to do with PHP upgrade?😖 Here is the file: <?php include("connect_Verses4Cards.php"); $conn=get_db_conn_verse(); session_start(); $display_block =""; $color=""; $r =""; $g =""; $b =""; $image =""; //Get the Card Variables $Get_Size_sql = "SELECT * FROM `CSize` WHERE `Size` ='".$_POST["CSize"]."'"; $Get_Size_res = mysqli_query($conn, $Get_Size_sql) or die(mysqli_error($conn)); if (mysqli_num_rows($Get_Size_res) < 1) { //this Card does not exist $display_block = "You have selected an invalid Card size. Please try again."; } else { //get the print variables while ($Size_info = mysqli_fetch_array($Get_Size_res)) { $BoxX = stripslashes($Size_info['BoxX']); $Cellw = stripslashes($Size_info['Cellw']); $Cellh = stripslashes($Size_info['Cellh']); $SizeI = stripslashes($Size_info['Size']); $SID = stripslashes($Size_info['SID']); $floatx = stripslashes($Size_info['floatx']); $floaty = stripslashes($Size_info['floaty']); $floatw = stripslashes($Size_info['floatw']); $floath = stripslashes($Size_info['floath']); $ort = stripslashes($Size_info['ort']); } //create the display string $display_block = "$ort"; } //verify the Event exists //$the_id = mysqli_real_escape_string($mysqli, $_SESSION[VID]); $Get_Verse_sql = "SELECT id, Event, Sub_Type, Verse FROM verses WHERE id='".$_SESSION['Test']."'"; $Get_Verse_res = mysqli_query($conn, $Get_Verse_sql) or die(mysqli_error($conn)); if (mysqli_num_rows($Get_Verse_res) < 1) { //this Event does not exist $display_block = "You have selected an invalid Event. Please try again."; } else { //get the Event ID while ($Verse_info = mysqli_fetch_array($Get_Verse_res)) { $Verse = stripslashes($Verse_info['Verse']); } //create the display string $display_block = "$Verse"; //free results mysqli_free_result($Get_Verse_res); mysqli_free_result($Get_Size_res); //close connection to MySQL } mysqli_close($conn); require('fpdf.php'); class PDF extends FPDF { var $B; var $I; var $U; var $HREF; function PDF($orientation='P', $unit='mm', $size='A4') { // Call parent constructor $this->FPDF($orientation,$unit,$size); // Initialization $this->B = 0; $this->I = 0; $this->U = 0; $this->HREF = ''; } function SetStyle($tag, $enable) { // Modify style and select corresponding font $this->$tag += ($enable ? 1 : -1); $style = ''; foreach(array('B', 'I', 'U') as $s) { if($this->$s>0) $style .= $s; } $this->SetFont('',$style); } } $color = $_POST['color']; $r = substr($color,0,3); $g = substr($color,3,3); $b = substr($color,6,3); $image=$_POST['image']; $pdf = new PDF($ort,'mm','A4'); $pdf->AddPage(); $pdf->AddFont('French Script MT','','/frscript.php'); $pdf->AddFont('Batavia','','Batavia_.php'); $pdf->AddFont('Algerian','','Alger.php'); $pdf->AddFont('Bladerunner','','BLADRMF_.php'); $pdf->AddFont('Brush Script','','BRUSHSCI.php'); $pdf->AddFont('Helterskelter','','Helte___.php'); $pdf->AddFont('Justice','','Justice_.php'); $pdf->AddFont('Magneto','','MAGNETOB.php'); $pdf->AddFont('Old English','','OldEngl.php'); $pdf->AddFont('Sneakerhead Outline','','Sneabo__.php'); $pdf->AddFont('Trendy','','Trendy__.php'); $pdf->AddFont('Vladimir Script','','VLADIMIR.php'); $pdf->SetLeftMargin('float0'); $pdf->SetTextColor($r,$g,$b); $pdf->SetFont($_POST['fontface'],'',$_POST['font']); $pdf->SetXY($BoxX, $_POST['Top']); $pdf->Image($image,$floatx,$floaty,$floatw,$floath,'',''); $pdf->MultiCell($Cellw,$Cellh,$display_block,'' ,'C'); //$pdf->SetDisplayMode('fullpage',''); $pdf->SetFont(''); $pdf->Output('verse.pdf','D'); //end: ?>
This topic has been moved to Other Libraries and Frameworks. http://www.phpfreaks.com/forums/index.php?topic=357112.0 I have an interface with method: public function foo(string $arg1, string $arg2); With PHP7.4, I can have a class relax the type without errors such as Dog::foo(string $arg1, $arg2) ($arg2 is not required to be a string) I incorrectly thought I could even relax the constraint more such as Dog::foo(string $arg1){} and not even pass $arg2 because extra arguments which exceed a method's placeholders are ignored without error but I received error: Declaration of Dog::foo(string $arg1) must be compatible with AnimalInterface::foo(string $arg1, string $arg2). Are my only options to include $arg2=null in the relaxed methods and label the methods something $dummy1, $dummy2..., or pass them in an array (which I don't wish to do)? Is passing extra parameters to the same method as I am doing considered bad practice, and if so what is considered the correct way? Thanks
<?php declare(strict_types=1); ini_set('display_errors', '1'); echo "PHP Version: ".PHP_VERSION.PHP_EOL; // => PHP Version: 7.4.1 interface AnimalInterface { public function foo(string $arg1, string $arg2); } abstract class Animal implements AnimalInterface { protected string $name; public function __construct(string $name) { $this->name = $name; } protected function test($method, $arg1, $arg2) { echo $method.' '.$this->name.' '.gettype($arg1).' '.gettype($arg2).PHP_EOL; } } class Cat extends Animal { public function foo(string $arg1, string $arg2) { $this->test(__FUNCTION__, $arg1, $arg2); } public function bar(string $arg1, string $arg2) { $this->test(__FUNCTION__, $arg1, $arg2); } } class Dog extends Animal { //public function foo(string $arg1){} //generates an error public function foo(string $arg1, $arg2=null) { $this->test(__FUNCTION__, $arg1, $arg2); } public function bar(string $arg1) { $arg2=$arg2??null; $this->test(__FUNCTION__, $arg1, $arg2); } } $kitty = new Cat("Ricky"); $doggy = new Dog("Mavrick"); $kitty->foo('arg1', 'arg2'); $doggy->foo('arg1', [1,2,3]); //$kitty->bar('arg1', (int)222); //will error using strict mode only $doggy->bar('arg1', (int)222); $kitty->bar('arg1', 'arg2'); $doggy->bar('arg1', [1,2,3]);Quote
PHP Version: 7.4.1
Hello
I've heard new PHP version (7) is on its way. Since I didn't found any thread laying around already. I guess, lets discuss it.
Estimated remaining time until early alpha is around a year. And stable release is expected to be in 2016/2017.
Edited by OmegaExtern, 07 August 2014 - 05:02 PM. Hi, In < PHP7.3, is it possible to set the session.cookie_samesite to "none' and secure to do away with the warning messages of chrome ? Thanks.
I have been at this for several hours..
<?php ?> I keep getting: Parse error: syntax error, unexpected '?>', expecting ',' or ')' in C:\Apache24\htdocs\mysql_connect.php on line 4 I have tried copy and paste of mysqli_connect from several different web pages, nothing works. PHP is installed correctly, I have a db in MySQL, and Apache is installed with no errors. what the... Edited March 31, 2019 by eljaydeetypo Please can some one help me. We have upgraded php and not i cant get the php page to correctly redirect the user to the login page if the user has not logged in and the get it to redirect to the index page. So the form sequence is as follows. User connects to index page, user clicks on link to add or delete data in mysql database, page must redirect to login page if user has not logged in, once logged in login page must redirect to add or delete page depending on the link clicked on. Addins and deleting data to the mysql database table works fine.
Below is the add,php page.
<?php
ini_set('display_errors', 1); ini_set('display_startup_errors', 1); error_reporting(E_ALL);
session_start(); //start session. if(!isset($_GET['name'])){//added this to check if name is sent include('database.php'); if (!isset($_SESSION["user.id"]) && $_SESSION["user.id"] !="") { } else{ header("Location: login.php"); }
if($_POST['action']) {
include('email.php'); $address=""; $name=$_POST['name']; $extension=$_POST['extension']; $department=$_POST['department']; $phone=$_POST['phone']; $email=$_POST['email'];
$sql = "INSERT INTO users (ID, Name, Email, Extension, Phone, Department) VALUES (NULL, '$name', '$email', '$extension', '$phone', '$department')";
if ($conn->query($sql) === TRUE) echo "New record added"; else echo "Error: " . $sql . "<br>" . $conn->error; $conn->close(); }
?>
<style type="text/css"> <!-- form { font-family: "Courier New", Courier, mono} body { font-family: "Times New Roman", Times, serif} --> </style>
<center><form action="" method="POST"> Name:<br><input type="text" name="name" required pattern=".*[ ].*" title="Please enter Name and Surname." ><br /> Email:<br><input type="text" name="email" required placeholder="@alpinemotors.co.za" pattern="[a-z0-9._%+-]+@[a-z0-9.-]+\.[a-z]{2,4}$" title="Must be a valid email address, eg: user@mail.co.za" ><br /> Extension:<br><input type="text" name="extension" required pattern="^\d{4}( \/ \d{4})?$" title="Please Enter the Extension Number"><br /> Phone:<br><input type="text" name="phone" pattern="^\d{3} \d{3} \d{4}$" title="Please enter a valid Cellphone Number, eg. 083 511 9213"><br /> Department:<br> <select name ="department"> <option value="ADMIN">ADMIN</option> <option value="FINANCIAL MANAGER">FINANCIAL MANAGER</option> <option value="AFTER-SALES DIRECTOR">AFTER-SALES DIRECTOR</option> <option value="ALPINE SALES DIRECTOR">ALPINE SALES DIRECTOR</option> <option value="DEALER PRINCIPAL">DEALER PRINCIPAL</option> <option value="AUTO ARMOUR/AUTO ENHANCE - FITMENT CENTRE (Smash and Grab)">AUTO ARMOUR/AUTO ENHANCE - FITMENT CENTRE (Smash and Grab)</option> <option value="BANDIT">BANDIT</option> <option value="BIDTRACK">BIDTRACK</option> <option value="WORKSHOP BOOKINGS">WORKSHOP BOOKINGS</option> <option value="CLEANERS">CLEANERS</option> <option value="COMMERCIAL SALES DIRECTOR">COMMERCIAL SALES DIRECTOR</option> <option value="WORKSHOP WASHBAY">WORKSHOP WASHBAY</option> <option value="FINANCE AND INSURANCE OFFICE">FINANCE AND INSURANCE OFFICE</option> <option value="FINANCE AND INSURANCE MANAGER">FINANCE AND INSURANCE MANAGER</option> <option value="IT DEPARTMENT">IT DEPARTMENT</option> <option value="MARKETING DIRECTOR">MARKETING DIRECTOR</option> <option value="MARKETING DEPARTMENT">MARKETING DEPARTMENT</option> <option value="MASTER CARS SALES">MASTER CARS SALES</option> <option value="MASTER CARS SALES MANAGER">MASTER CARS SALES MANAGER</option> <option value="PREP DEPARTMENT">PREP DEPARMENT</option> <option value="NUMBER PLATES">NUMBER PLATES</option> <option value="PANELBEATER - EASIFIX - CAR CARE">PANELBEATER - EASIFIX - CAR CARE</option> <option value="PARTS MANAGER">PARTS MANAGER</option> <option value="PARTS">PARTS</option> <option value="PARTS DISPATCH">PARTS DISPATCH</option> <option value="PARTS TELESALES">PARTS TELESALES</option> <option value="TRADE SALES MANAGER">TRADE SALES MANAGER</option> <option value="WASHBAY">WASHBAY</option> <option value="MASTER CARS PREP AND ORDERS">MASTER CARS PREP AND ORDERS</option> <option value="NEW CARS ADMIN AND STOCK CONTROL">NEW CARS ADMIN AND STOCK CONTROL</option> <option value="NEW CARS SHOWROOM">NEW CARS SHOWROOM</option> <option value="NEW CARS SALES MANAGER">NEW CARS SALES MANAGER</option> <option value="WORKSHOP SERVICE ADVISORS">WORKSHOP SERVICE ADVISORS</option> <option value="WORKSHOP">WORKSHOP</option> <option value="WORKSHOP FOREMEN">WORKSHOP FOREMEN</option> <option value="WAREHOUSE">WAREHOUSE</option> <option value="WARRANTY & CLAIMS">WARRANTY & CLAIMS</option> <option value="WORKSHOP DRIVERS">WORKSHOP DRIVERS</option> <option value="WORKSHOP MANAGER">WORKSHOP MANAGER</option> </select> <br /> <br><input type="submit" name="action" value="Submit"> <input type="reset" value="Reset"> </form> <a href="index.php">Extension List</a> </center> </html> }
Below is the login.php
<?php
ini_set('display_errors', 1); ini_set('display_startup_errors', 1); error_reporting(E_ALL);
session_start(); // Starting Session $error = ''; // Variable To Store Error Message if (isset($_POST['submit'])) { if (empty($_POST['username']) || empty($_POST['password'])) { $error = "Username or Password is invalid"; } else{ // Define $username and $password $username = $_POST['username']; $password = $_POST['password']; // mysqli_connect() function opens a new connection to the MySQL server. $conn = mysqli_connect("localhost", "root", "Pr1v@cY", "T-List_VW"); // SQL query to fetch information of registerd users and finds user match. $query = "SELECT * from UserName where userName=? AND pass=? LIMIT 1"; // To protect MySQL injection for Security purpose $stmt = $conn->prepare($query); $stmt->bind_param("ss", $username, $password); $stmt->execute(); $stmt->bind_result($username, $password); $stmt->store_result(); if($stmt->fetch()) //fetching the contents of the row { $_SESSION['login_user'] = $username; // Initializing Session header("location: index.php"); // Redirecting To Profile Page } mysqli_close($conn); // Closing Connection } ?>
<!DOCTYPE html> <html> <head> <title>Login Form in PHP with Session</title> <link href="style.css" rel="stylesheet" type="text/css"> </head> <body> <div id="login"> <h2>Login Form</h2> <form action="" method="post"> <label>UserName :</label> <input id="name" name="username" placeholder="username" type="text"> <label>Password :</label> <input id="password" name="password" placeholder="**********" type="password"><br><br> <input name="submit" type="submit" value=" Login "> <span><?php echo $error; ?></span> </form> </div> </body> </html>
I have a huge application(multi-year) where I do the normal $varX= $var1 + $var2. I get Warning: A non-numeric value encountered because var1 or var 2 are string. I know the right thing will be to intval(), but I just cant go over so much of the application. I read to just disable warning, but I think thats worst because I will not be able to see new warnings. Is there any php.ini solution were php can work as before on math operations? I guess I can ini_set on all the old files and dont do it on the new ones). If there is another accepted solution, please let me know Thank you
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:) 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..... 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, With my attendance system I generated one fpdf link to generate pdf file. What if I have 50 staff members, Its hard to open the 50 pdf files separately. Is there a away to merge them all in one big pdf file? Edited April 3, 2020 by ramiwahdantypo error 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 '); 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 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. 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. I'm using FPDF to generate dynamic reports. How can I make sure MySQL queried results don't overflow into adjacent cells if the text length is longer then the cells designated width? I once accomplished this by using CSS with white-space:nowrap and overflow:hidden. But I can't think of how to do this with FPDF. Any ideas?? 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?? <?PHP require("../fpdf/fpdf.php"); include("db.classes.php"); $g = new DB(); $g->connection(); class PDF extends FPDF { .....codes..... } $pdf = new PDF(); .....codes..... $pdf->SetFont('Arial','',14); $pdf->AddPage('L', 'Legal'); $pdf->SetXY(20,20); $pdf->image('../images/DCWD Watermark.png'); $pdf->SetY(35); // call the table creation method $pdf->SetFont('Arial','B',16); $pdf->Cell(0,10,$plateNo); $pdf->SetY(45); $pdf->SetFont('Arial','B',16); $pdf->Cell(0,10,$model); $pdf->SetXY(310, 45); $pdf->SetFont('Arial','B',16); $pdf->Cell(0,10,date("m/d/Y")); $pdf->SetY(55); $pdf->BuildTable($header,$data); $pdf->Output(); ?>Why is FPDF's Output not working? or is something wrong with my browser? I already tried putting paramaters on it but still no go I tried Output('foo.pdf','I') not working but if i itegrate my chrome withIDM it just downloads but when i disable integrationnothing happens. |