Any way to loop through FPDF code with proper XY coordinates?

Posted by JM4 on Stack Overflow See other posts from Stack Overflow or by JM4
Published on 2010-05-27T01:25:34Z Indexed on 2010/05/27 1:31 UTC
Read the original article Hit count: 707

Filed under:
|
|

At the end of a form collection, I provide the consumer a printable PDF with the information they just entered. I already run through a loop to store the variables themselves but am wondering if it is at all possible to build a loop that builds on itself for FPDF.

The catch is this, each new variable (#1, #2, #3) will change location by a determined amount of space. For example:

I print the Member #1 First name at coordinate at coordinate (95, 101). I print Member #2 First name at coordinate (95, 110)... and so on. Each known variable will be 9.5mm greater than its previous entry (therefor Member #9 will be 40mm higher than Member 6)

My sample code for the FPDF itself is:

$pdf->SetFont('Arial','', 7);
$pdf->SetXY(8,76.5);
$pdf->Cell(20,0,$f1name);

$pdf->SetFont('Arial','', 5);
$pdf->SetXY(50.5,76.5);
$pdf->Cell(20,0,$f1address);

$pdf->SetFont('Arial','', 7);
$pdf->SetXY(95.7,76.5);
$pdf->Cell(20,0,$f1city);

$pdf->SetXY(129.5,76.5);
$pdf->Cell(20,0,$f1state);

$pdf->SetXY(139.1,76.5);
$pdf->Cell(20,0,$f1zip);

$pdf->SetXY(151,76.5);
$pdf->Cell(20,0,$f1dob);

$pdf->SetXY(168,76.5);
$pdf->Cell(20,0,$f1ssn);

$pdf->SetXY(186,76.5);
$pdf->Cell(20,0,$f1phone);

$pdf->SetXY(55,81.1);
$pdf->Cell(20,0,$f1email);

$pdf->SetXY(129,81.1);
$pdf->Cell(20,0,$f1fednum);

Ideally, all Y variables with $f2 would be 9.5mm greater than f1's Y values.

© Stack Overflow or respective owner

Related posts about php

Related posts about for-loop