PDA

Archiv verlassen und diese Seite im Standarddesign anzeigen : PDF-Erstellung


Blade1965
08.08.2006, 10:27:35
Hallo,
ich habe ein kleines Problem mit der FPDF-Classe beim Erstellen von Multicell.
Ich möchte mehere dieser Multicell nebeneinander haben und diese durch eine
Schleife laufen lassen.
Nur mit der Positionierung habe ich leider einige Probleme :(
Hier mein Code:



define("FPDF_FONTPATH","font/");
require_once("fpdf.php");

$pdf = new FPDF("L","mm","A4");
$pdf->AddPage();
$pdf->SetFont("Arial", "", 9);


for($i=0;$i<9;$i++){


$pdf->MultiCell(35,5,'Text1',TRUE);
$pdf->MultiCell(15,5, "Text2",TRUE);

}

$pdf->Output();



Wäre über jede Hilfe dankbar :)

yozek
09.08.2006, 11:34:22
Hi,

da hast du aber die Dokumentation nicht vollständig gelesen:

This method allows printing text with line breaks. [...]
Was du suchst ist der einfache Befehl: cell

So wird's gemacht:

<?php
// definitions and requirements
define('FPDF_FONTPATH','font/');
require_once('fpdf.php');

// create a new fpdf object
$oPdf = new FPDF('L','mm','A4');
$oPdf ->AddPage();
$oPdf ->SetFont('Arial', '', 9);

// display cells
for($i=0;$i<9;$i++) {

// move the cell 10mm to the right
$oPdf->Cell(10);

//Centered text in a framed cell and the last cell with line break
$oPdf->Cell(
35, // width
5, // height
'Title1', // text
1, // border
0, // position after cell (0 means right)
'C' // text align (C = center)
);
$oPdf->Cell(15,5,'Title2',1,1,'C');

}

// give me the PDF
$oPdf->Output();
?>

HTH

Blade1965
09.08.2006, 13:51:09
Ja, Cell ist mir schon bekannt.
Aber in den MultCell will ich natürlich Text aus der DB mit Zeilenumbrüchen darstellen und das geht halt nicht mit Cell :(

Andes
09.08.2006, 14:39:48
Ich nehme mal an das du eine Tabellendarstellung erreichen möchtest?
Dafür gibt es Add-Ons auf fpdf.de.

Blade1965
09.08.2006, 16:40:43
Ja :)
Hättest du dafür eine Lösung?

Andes
09.08.2006, 17:04:59
Schau dir mal dieses Add-On an. Table with MultiCell (http://www.fpdf.de/downloads/addons/3/)

Blade1965
09.08.2006, 17:15:04
Ich denke, darauf könnte ich aufbauen.
Danke :)