Foro de elhacker.net

Programación => PHP => Mensaje iniciado por: neeeko en 30 Mayo 2015, 03:38 am



Título: Echo en pdf image
Publicado por: neeeko en 30 Mayo 2015, 03:38 am
HOla gente , estaba tratando de meter un codigo QR dinamico en un archivo pdf y no logro hacerlo , a alguno se le ocurre como o ya lo hizo y me da una mano ?

por mi aldo estoy tratando de concatenar lo siguiente
Código:
<?php
require("pdfclase/fpdf.php");
 define('FPDF_FONTPATH','pdfclase/font/');
//CLASECODIGO QR......

    //set it to writable location, a place for temp generated PNG files
    $PNG_TEMP_DIR = dirname(__FILE__).DIRECTORY_SEPARATOR.'temp'.DIRECTORY_SEPARATOR;
 
    //html PNG location prefix
    $PNG_WEB_DIR = 'temp/';

    include "pdfclase/qrlib.php";    
    
    //ofcourse we need rights to create temp dir
    if (!file_exists($PNG_TEMP_DIR))
        mkdir($PNG_TEMP_DIR);
    
    
    $filename = $PNG_TEMP_DIR.'test.png';
    
    //processing form input
    //remember to sanitize user input in real-life solution !!!
    $errorCorrectionLevel = 'L';
    if (isset($_REQUEST['level']) && in_array($_REQUEST['level'], array('L','M','Q','H')))
        $errorCorrectionLevel = $_REQUEST['level'];    

    $matrixPointSize = 4;
    if (isset($_REQUEST['size']))
        $matrixPointSize = min(max((int)$_REQUEST['size'], 1), 10);


    if (isset($_REQUEST['data'])) {
    
        //it's very important!
        if (trim($_REQUEST['data']) == '')
            die('data cannot be empty! <a href="?">back</a>');
            
        // user data
        $filename = $PNG_TEMP_DIR.'test'.md5($_REQUEST['data'].'|'.$errorCorrectionLevel.'|'.$matrixPointSize).'.png';
        QRcode::png($_REQUEST['data'], $filename, 2);    
        
    } else {    
    
        //default data
        echo 'You can provide data in GET parameter: <a href="?data=like_that">like that</a><hr/>';    
        QRcode::png('PHP QR Code :)', $filename, 2);    
        
    }    
        
    
    
//TERMINA CLASE CODIGO QR



$pdf = new FPDF();

$pdf->AddPage();
echo $filename;

$pdf->SetFont('Arial','B',16);
$pdf->Cell(40,10,'Esto es un codigo QR xD');
$pdf->Image('temp/'.echo $filename.'test.png',20,20,100,100);
$pdf->Cell(180,4,"Fecha de Emision :".$cupos,"",0,"C");
$pdf->Output();
?>


Quiero saber si
$pdf->Image('temp/'.echo $filename.'test.png',20,20,100,100);
ACa hay alguna forma de concatenarle a la ruta el nomrbe del archivo asi lo va a buscar ahi ?

GRACIAS espero aver sido claro .
SALUDOS

Mod: Temas sobre PHP van al subforo de PHP.