PHP Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsProgramming LanguagesPHP Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old April 13th, 2005, 09:02 AM
jeezus84 jeezus84 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2004
Location: Greater Crater of Sudbury
Posts: 51 jeezus84 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 19 h 38 m 34 sec
Reputation Power: 9
FPDF function MultiCell( ) linewrap problems

good after ladies and gentlemen, most likely gentlemen. that just seems to be the way nowadays.

I'm trying to generate some reports using the FPDF class, and drawing out tables is proving to be difficult.

I have 6 columns, with the second column being the widest. This column also contains text that will most often wrap to the next line. I'm trying to use the MultiCell( ) function to achieve this.

The main problem that I'm having is that MultiCell()'s stack on top of each other. I can't get one MultiCell() to sit beside another MultiCell(). Is there any way to prevent a new line from being inserted after every MultiCell() is drawn?

If not, is there any way I can get text to wrap around inside a normal Cell() ?

Here is my code thusfar:
Code:
            $header= array();
	$header[0] = array('title' => 'Account', 'width' => 40);
	$header[1] = array('title' => 'Description', 'width' => 70);
	$header[2] = array('title' => 'Type', 'width' => 20);
	$header[3] = array('title' => 'Tax', 'width' => 20);
	$header[4] = array('title' => 'Rebate', 'width' => 20);
	$header[5] = array('title' => 'Ret.', 'width' => 10);

            require("../functions/db.inc");
	
	db_connect("gl");
	$query = "select * from v_chartlistqy";
	$result = mysql_query($query);
	
	$rowHeight = 14;
	while ($row = mysql_fetch_array($result))
	{
	
		$pdf->MultiCell($header[0]['width'], $rowHeight, $row['account'], 1);
		$pdf->MultiCell($header[1]['width'], $rowHeight, $row['descr'], 1);
		$pdf->MultiCell($header[2]['width'], $rowHeight, $row['td'], 1);
		$pdf->MultiCell($header[3]['width'], $rowHeight, $row['tc'], 1);
		$pdf->MultiCell($header[4]['width'], $rowHeight, $row['rc'], 1);
		$pdf->Ln();
	
	}
	
	
	$pdf->output();


Thanks.

Reply With Quote
  #2  
Old January 21st, 2008, 01:58 PM
dosslater dosslater is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2008
Posts: 1 dosslater User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 9 m 49 sec
Reputation Power: 0
Use SetX() and SetY()

This post is old, but I came across it while encountering the same issue with wanting my line wraps to behave as cells. The solution I found was on this blog:
http://www.roxxor.co.uk/blog/2007/10/05/wrapping-text-in-fpdf-table-cells/

Basically you find the coordinates before you use the Multicell using GetX and GetY, and then do a little math afterwards and use SetX, and SetY.
Example:
Code:
$x=16;
$y=26;

$width=100;
$height=35;
$leftmargin=16;
for ($r=0;$r<10;$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,$r."-".$c." ".$x.",".$y,1,'L');
	}
	$y+=$height;
	$x=$leftmargin;
	$pdf->SetY($y);
}



Hope this helps anybody else with similar problems

Reply With Quote
  #3  
Old March 15th, 2012, 10:13 PM
houseman74 houseman74 is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2012
Posts: 1 houseman74 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 13 m 17 sec
Reputation Power: 0
If somebody is trying to use it:
The SetY() must set before the SetX() because the SetY() is setting X-Coordinate back to default.

Reply With Quote
  #4  
Old October 30th, 2012, 04:57 AM
nivahar nivahar is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2012
Posts: 1 nivahar User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 9 m 54 sec
Reputation Power: 0
Php Multicell alignment

<---For Word Wrap-->
$project =$row["project_title"]; <--replace project_title with url mysql parameter-->
$project_title = wordwrap($project, 20, "\n");


<--For each Multicells-->
$current_y = $this->GetY();
$current_x = $this->GetX();

$cell_width = 40;
$this->MultiCell($cell_width, 3, $project_title,0,'T', false,'T');

$this->SetXY($current_x + $cell_width, $current_y);


<--end-->
Use these functions for each and every multicells it will but without border lines-->

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesPHP Development > FPDF function MultiCell( ) linewrap problems

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap