How can I have this generated text appear centered in the page.
Generated = $_POST
method ... so I don't know how long will the text in input be. I need to have a pre-determined center parameter somehow.
Any ideas? Maybe like this:
MultiCell(0,$height,"text",0,'C') ?
1 : -1); $style=''; foreach(array('B','I','U') as $s) if($this->$s>0) $style. =$s; $this->SetFont('',$style); } function PutLink($URL,$txt) { //Put a hyperlink $this->SetTextColor(0,0,255); $this->SetStyle('U',true); $this->Write(5,$txt,$URL); $this->SetStyle('U',false); $this->SetTextColor(0); } } ?>
The MultiCell function facilitates the generation of complex table structures within the FPDF PDF generating library. When used properly, the application can handle variable length data within each cell of the table. Simplistically stated, the MultiCell function is all about geometries.
The PDFlib needs to be installed as an extension in your PHP package, whereas FPDF can just be included in your PHP script and it's ready to use. To get started, you will need to download the FPDF class from the FPDF Web site and include it in your PHP script like this: require('fpdf.
FreeKB - PHP Wrap text in a cell when using FPDF. Create a class to extend FPDF with the vcell function. Use the WrapText class. $pdf = new WrapText();
Normally it's $pdf->Cell(0, $height, "text", 0, 0, 'C');
but if you're doing it in a Header or Footer function it's $this->Cell(0, $height, "text", 0, 0, 'C')
. Don't forget to declare $height
as a global if you're doing this in a function() call.
Thanks taur! This works for me:
$mid_x = 135; // the middle of the "PDF screen", fixed by now.
$text = $userFullName;
$pdf_file->Text($mid_x - ($pdf_file->GetStringWidth($text) / 2), 102, $text);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With