Jump to content

Generate pdf in php and mysql


Alicia

Recommended Posts

it is working now but i have problem adjusting the position of the info :

 

- how to add a line break ? is it just adjust the second value in a function ?

- I tried to adjust the x position of the text but why when I adjust the first value in the function, nothinig is changed ? can somebody give me an idea how to accomplish this ?

cell (x, y, 'value', a, b)

 

can somebody double confirm with me the following :

x - position left and right

y - position up and down

a - ???

b - ???

what is this a and b for ? i did read fpdf but dun really understand.. please advise...

 

- why is the description is long, we have to use multicell instead of cell function ?

 

 

$this->SetFont('Arial','B',12);
        $ypos = $this->getY() + 5;
        $this->setY($ypos);
        $this->Cell (100, 6, "$name ($code)", 0, 0);
        $this->Cell (30, 6, "\$$price", 0, 1, 'R');
        $this->SetFont('Arial','I',10);
        $this->Cell (130, 6, 'Description', 0, 1);
        $this->SetFont('Arial','',10);
        $this->Cell(10);      // indent
        $this->Multicell (90, 4, $desc);
        $ypos2 = $this->getY();    // end of text

Link to comment
Share on other sites

Cell

Cell(float w [, float h [, string txt [, mixed border [, int ln [, string align [, int fill [, mixed link]]]]]]])

Version

1.0

Description

Prints a cell (rectangular area) with optional borders, background color and character string. The upper-left corner of the cell corresponds to the current position. The text can be aligned or centered. After the call, the current position moves to the right or to the next line. It is possible to put a link on the text.

If automatic page breaking is enabled and the cell goes beyond the limit, a page break is done before outputting.

Parameters

w

Cell width. If 0, the cell extends up to the right margin.

h

Cell height. Default value: 0.

txt

String to print. Default value: empty string.

border

Indicates if borders must be drawn around the cell. The value can be either a number:

0: no border

1: frame

or a string containing some or all of the following characters (in any order):

L: left

T: top

R: right

B: bottom

Default value: 0.

ln

Indicates where the current position should go after the call. Possible values are:

0: to the right

1: to the beginning of the next line

2: below

Putting 1 is equivalent to putting 0 and calling Ln() just after. Default value: 0.

align

Allows to center or align the text. Possible values are:

L or empty string: left align (default value)

C: center

R: right align

fill

Indicates if the cell background must be painted (1) or transparent (0). Default value: 0.

link

URL or identifier returned by AddLink().

Example

//Set font

$pdf->SetFont('Arial','B',16);

//Move to 8 cm to the right

$pdf->Cell(80);

//Centered text in a framed 20*10 mm cell and line break

$pdf->Cell(20,10,'Title',1,1,'C'); 

 

MultiCell

 

MultiCell(float w, float h, string txt [, mixed border [, string align [, int fill]]])

Version

1.3

Description

This method allows printing text with line breaks. They can be automatic (as soon as the text reaches the right border of the cell) or explicit (via the \n character). As many cells as necessary are output, one below the other.

Text can be aligned, centered or justified. The cell block can be framed and the background painted.

Parameters

w

Width of cells. If 0, they extend up to the right margin of the page.

h

Height of cells.

txt

String to print.

border

Indicates if borders must be drawn around the cell block. The value can be either a number:

0: no border

1: frame

or a string containing some or all of the following characters (in any order):

L: left

T: top

R: right

B: bottom

Default value: 0.

align

Sets the text alignment. Possible values are:

L: left alignment

C: center

R: right alignment

J: justification (default value)

fill

Indicates if the cell background must be painted (1) or transparent (0). Default value: 0.

Link to comment
Share on other sites

yeah.. i did read that from fpdf.org manual and the problem is, what I edited from the script doesnt seem to bring the effect I want..

 

for instance, i want it all to be aligned left with same left margin but failed even i used same value for x

 

please advise./

Link to comment
Share on other sites

will this not work?

 

<?php
$this->SetFont('Arial','B',12);
        $ypos = $this->getY() + 5;
        $this->setY($ypos);
        $this->Cell (100, 6, "$name ($code)", 0, 0,'L');
        $this->Cell (30, 6, "\$$price", 0, 1, 'L');
        $this->SetFont('Arial','I',10);
        $this->Cell (130, 6, 'Description', 0, 1, 'L');
        $this->SetFont('Arial','',10);
        $this->Cell(10);      // indent
        $this->Multicell (90, 4, $desc, 'L');
        $ypos2 = $this->getY();    // end of text
?>

Link to comment
Share on other sites

  • 3 weeks later...

i am going crazy because of the alignment issue..

 

i tried to adjust the x and y in the script but y it is totally different from what it supposed to be ?? i even instered negative value to move the text to left... wondering is that a right way.. now I cant adjust the y alignment for the value $E multicell no matter what value i put for y..

 

can somebody please advise ..

 

		$this->SetFont('Arial','B',12);
        $ypos = $this->getY() + 5;
        $this->setY($ypos);
        $this->Cell (100, 6, "$D($B)", 0, 0,'L');
        $this->SetFont('Arial','',10);
	$this->Cell(-98,-10);      // indent
	// add 0 to remove the left column line
	$this->Multicell (0, 4, $E, 'L');
        $ypos2 = $this->getY();    // end of text

 

thanks

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.