Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /*
- * Jorge Martínez Mauricio <gz@tar.mx> http://tar.mx
- * reemplaza variables definidas en la generación de PDF con FPDF http://www.fpdf.org/
- */
- require_once("fpdf17/fpdf.php"); //requiere la biblioteca FPDF.
- class PDF extends FPDF {
- /* parseVar(key string, value string)*/
- function parseVar($key='',$value='') {
- if(empty($key) or empty($value)) return;
- $nb = $this->page;
- for($n=1;$n<=$nb;$n++) {
- $this->pages[$n] = str_replace($key,$value,$this->pages[$n]);
- }
- }
- }
- /*
- * Ejemplo, generamos documento tamaño carta,
- */
- $pdf = new PDF('P','mm','Letter');
- $pdf->AddPage();
- $pdf->SetFont('arial','B',36); //fuente
- $pdf->SetFillColor(169,214,194); //fondo
- $pdf->MultiCell(0,20,"Hola mundo, cruel y perverso\n\n{fechaHora}",0,1,'C',1); //texto + variable
- $pdf->parseVar('{fechaHora}',strftime("%c")); // convertimos la variable.
- $pdf->SetFont('arial','',12); //fuente
- $pdf->ln(5);
- $pdf->Cell(0,5,"#oribeliever",0,1);
- $pdf->Image("http://tar.mx/log/hermosoPeralta.jpg"); //imagen
- $pdf->Output("ejemploVariablesPDF.pdf",'D');
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement