Foros del Web » Programando para Internet » PHP »

Libreria dompdf - generar pdf de una imagen almacenada en mysql

Estas en el tema de Libreria dompdf - generar pdf de una imagen almacenada en mysql en el foro de PHP en Foros del Web. Hola que tal, miren tengo una pagina llamada perfiles, en la cual el usuario puede realizar una busqueda y los datos de este se muestran ...
  #1 (permalink)  
Antiguo 18/09/2012, 19:08
 
Fecha de Ingreso: mayo-2012
Ubicación: Distrito Federal
Mensajes: 49
Antigüedad: 11 años, 11 meses
Puntos: 9
Pregunta Libreria dompdf - generar pdf de una imagen almacenada en mysql

Hola que tal, miren tengo una pagina llamada perfiles, en la cual el usuario puede realizar una busqueda y los datos de este se muestran (todos en su campo de texto correspondiente, menos la imagen la cual la muestro mediante una imagen dinamica). Aqui tambien hay un boton que permite generar un pdf con los resultados de la busqueda.

Esta conversion la hago por medio de la la libreria dompdf.

El problema reside en que me convierte los datos que se muestran dentro de un campo de texto, pero la imagen al no encontrarse dentro de un campo de texto, esta no me aparece a la hora generar el pdf y no se como mandarla a llamar para que sea convertida.

Podrian decirme como solucionar este problema, dejo en la parte de abajo en forma de comentario debido a que el texto es muy largo el codigo de los archivos que utilizo
  #2 (permalink)  
Antiguo 18/09/2012, 19:12
 
Fecha de Ingreso: mayo-2012
Ubicación: Distrito Federal
Mensajes: 49
Antigüedad: 11 años, 11 meses
Puntos: 9
Pregunta Respuesta: Libreria dompdf - generar pdf de una imagen almacenada en mysql

Aqui los codigos

pdf_send.php
Código PHP:
    <?php 
    
    
require_once("dompdf/dompdf_config.inc.php");
    
    
$conexion mysql_connect("SERVIDOR""USUARIO""CONTRASEÑA");

    
mysql_select_db("sistema"$conexion);

$html ='

<html>
<head>
<title>Ficha Tecnica</title>
<style type="text/css">
<!--
#datos {
    position:absolute;
    width:780px;
    left: 164px;
    top: 316px;
    text-align: center;
}
#apDiv1 #form1 table tr td {
    text-align: center;
    font-weight: bold;
}
#apDiv2 {
    position:absolute;
    width:49px;
    height:45px;
    z-index:2;
    left: 12px;
    top: 11px;
}
#apDiv1 #notificacion table tr td {
    text-align: center;
}
#apDiv1 #notificacion table tr td {
    text-align: left;
}
#apDiv1 #notificacion table tr td {
    text-align: center;
    font-family: Arial, Helvetica, sans-serif;
}
#apDiv3 {
    position:absolute;
    width:814px;
    height:115px;
    z-index:1;
    left: 34px;
    text-align: center;
    top: 11px;
}
-->
</style>
</head>

<body>
<div id="apDiv3">
  <table width="81%" border="1" cellpadding="0" cellspacing="0" bordercolor="#000000">
    <tr>
      <td><table width="100%" border="0">
        <tr>
          <td style="text-align: center"><img src="imagenes/logo_soccer.jpg" alt="" width="480" height="333"></td>
        </tr>
        <tr>
          <td><p>&nbsp;</p>
            <p style="font-family: Helvetica LT Condensed; color: #008895; font-weight: bold; font-size: 22px; text-align: center;">FICHA TECNICA</p></td>
        </tr>
        <tr>
          <td>&nbsp;</td>
        </tr>
        <tr>
          <td>&nbsp;</td>
        </tr>
        <tr>
          <td style="font-family: Helvetica LT Condensed; font-size: 18px;"><spanHelvetica LT Condensed"; font-size: 18px;">
            <span style="font-family: Arial, Helvetica, sans-serif; font-size: 20px; font-weight: bold; color: #000;">Nombre: '
.$_POST["nombre"].'</span></td>
        </tr>
        <tr>
          <td style="font-family: Helvetica LT Condensed; font-size: 18px;"><span style="font-family: Arial, Helvetica, sans-serif; font-size: 20px; font-weight: bold; color: #000;">Edad: '
.$_POST["edad"].' A&ntilde;os</span></td>
        </tr>
        <tr>
          <td style="font-family: Helvetica LT Condensed; font-size: 18px;"><span style="font-family: Arial, Helvetica, sans-serif; font-size: 20px; font-weight: bold; color: #000;">Altura: '
.$_POST["altura"].' m</span></td>
        </tr>
        <tr>
          <td style="font-family: Helvetica LT Condensed; font-size: 18px;"><span style="font-family: Arial, Helvetica, sans-serif; font-size: 20px; font-weight: bold; color: #000;">Peso: '
.$_POST["peso"].' Kg.</span></td>
        </tr>
        <tr>
          <td style="font-family: Helvetica LT Condensed; font-size: 18px;"><span style="font-family: Arial, Helvetica, sans-serif; font-size: 20px; font-weight: bold; color: #000;">Pais: '
.$_POST["nacionalidad"].'</span></td>
        </tr>
        <tr>
          <td style="font-family: Helvetica LT Condensed; font-size: 18px;"><span style="font-family: Arial, Helvetica, sans-serif; font-size: 20px; font-weight: bold; color: #000;">Numero: '
.$_POST["numero"].'</span></td>
        </tr>
        <tr>
          <td style="font-family: Helvetica LT Condensed; font-size: 18px;"><span style="font-family: Arial, Helvetica, sans-serif; font-size: 20px; font-weight: bold; color: #000;">Posicion: '
.$_POST["posicion"].'</span></td>
        </tr>
        <tr>
          <td style="font-family: Helvetica LT Condensed; font-size: 18px;"><span style="font-family: Arial, Helvetica, sans-serif; font-size: 20px; font-weight: bold; color: #000;">Apodo: '
.$_POST["apodo"].'</span></td>
        </tr>
        <tr>
          <td style="font-family: Helvetica LT Condensed; font-size: 18px;"><span style="font-family: Arial, Helvetica, sans-serif; font-size: 20px; font-weight: bold; color: #000;">Habilidad: '
.$_POST["habilidad"].'</span></td>
        </tr>
        <tr>
          <td><p>&nbsp;</p>
            <p><span style="font-family: Arial, Helvetica, sans-serif; font-size: 20px; font-weight: bold; color: #000;">Comentarios: '
.$_POST["comentarios"].'</span></p>
            <p>&nbsp;</p>
            <p>&nbsp;</p></td>
        </tr>
        <tr>
          <td>&nbsp;</td>
        </tr>
      </table></td>
    </tr>
  </table>
</div>
</body>
</html>

'


    
$dompdf = new DOMPDF();
    
$dompdf->load_html($html);
    
$dompdf->render();
    
$dompdf->stream("Ficha_Tecnica.pdf", array('Attachment'=>'0'));
    
?>
  #3 (permalink)  
Antiguo 18/09/2012, 19:14
 
Fecha de Ingreso: mayo-2012
Ubicación: Distrito Federal
Mensajes: 49
Antigüedad: 11 años, 11 meses
Puntos: 9
Pregunta Respuesta: Libreria dompdf - generar pdf de una imagen almacenada en mysql

Este lo tuve que dividir en dos partes por que se pasa de caracteres permitidos, disculpen las molestias


perfiles.php parte 1

Código PHP:
<?php require_once('Connections/bd_futbol.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function 
GetSQLValueString($theValue$theType$theDefinedValue ""$theNotDefinedValue ""
{
  if (
PHP_VERSION 6) {
    
$theValue get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
  }

  
$theValue function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);

  switch (
$theType) {
    case 
"text":
      
$theValue = ($theValue != "") ? "'" $theValue "'" "NULL";
      break;    
    case 
"long":
    case 
"int":
      
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
      break;
    case 
"double":
      
$theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
      break;
    case 
"date":
      
$theValue = ($theValue != "") ? "'" $theValue "'" "NULL";
      break;
    case 
"defined":
      
$theValue = ($theValue != "") ? $theDefinedValue $theNotDefinedValue;
      break;
  }
  return 
$theValue;
}
}

$currentPage $_SERVER["PHP_SELF"];

$colname_mostrar_datos "-1";
if (isset(
$_GET['busqueda'])) {
  
$colname_mostrar_datos $_GET['busqueda'];
}
mysql_select_db($database_bd_futbol$bd_futbol);
$query_mostrar_datos sprintf("SELECT * FROM datos_jugador WHERE posicion = %s"GetSQLValueString($colname_mostrar_datos"text"));
$mostrar_datos mysql_query($query_mostrar_datos$bd_futbol) or die(mysql_error());
$row_mostrar_datos mysql_fetch_assoc($mostrar_datos);
$maxRows_mostrar_datos 1;
$pageNum_mostrar_datos 0;
if (isset(
$_GET['pageNum_mostrar_datos'])) {
  
$pageNum_mostrar_datos $_GET['pageNum_mostrar_datos'];
}
$startRow_mostrar_datos $pageNum_mostrar_datos $maxRows_mostrar_datos;

$colname2_mostrar_datos "-1";
if (isset(
$_GET['busqueda2'])) {
  
$colname2_mostrar_datos $_GET['busqueda2'];
}
$colname_mostrar_datos "-1";
if (isset(
$_GET['busqueda'])) {
  
$colname_mostrar_datos $_GET['busqueda'];
}
mysql_select_db($database_bd_futbol$bd_futbol);
$query_mostrar_datos sprintf("SELECT * FROM datos_jugador WHERE posicion = %s OR nombre LIKE %s"GetSQLValueString($colname_mostrar_datos"text"),GetSQLValueString($colname2_mostrar_datos"text"));
$query_limit_mostrar_datos sprintf("%s LIMIT %d, %d"$query_mostrar_datos$startRow_mostrar_datos$maxRows_mostrar_datos);
$mostrar_datos mysql_query($query_limit_mostrar_datos$bd_futbol) or die(mysql_error());
$row_mostrar_datos mysql_fetch_assoc($mostrar_datos);

if (isset(
$_GET['totalRows_mostrar_datos'])) {
  
$totalRows_mostrar_datos $_GET['totalRows_mostrar_datos'];
} else {
  
$all_mostrar_datos mysql_query($query_mostrar_datos);
  
$totalRows_mostrar_datos mysql_num_rows($all_mostrar_datos);
}
$totalPages_mostrar_datos ceil($totalRows_mostrar_datos/$maxRows_mostrar_datos)-1;

$queryString_mostrar_datos "";
if (!empty(
$_SERVER['QUERY_STRING'])) {
  
$params explode("&"$_SERVER['QUERY_STRING']);
  
$newParams = array();
  foreach (
$params as $param) {
    if (
stristr($param"pageNum_mostrar_datos") == false && 
        
stristr($param"totalRows_mostrar_datos") == false) {
      
array_push($newParams$param);
    }
  }
  if (
count($newParams) != 0) {
    
$queryString_mostrar_datos "&" htmlentities(implode("&"$newParams));
  }
}
$queryString_mostrar_datos sprintf("&totalRows_mostrar_datos=%d%s"$totalRows_mostrar_datos$queryString_mostrar_datos);
?>
  #4 (permalink)  
Antiguo 18/09/2012, 19:16
 
Fecha de Ingreso: mayo-2012
Ubicación: Distrito Federal
Mensajes: 49
Antigüedad: 11 años, 11 meses
Puntos: 9
Respuesta: Libreria dompdf - generar pdf de una imagen almacenada en mysql

perfiles.php parte 2
Código PHP:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Perfiles</title>

</head>

<body>

<div id="buscar">
  <form id="formbusqueda" name="formbusqueda" method="get" action="perfiles.php">
    <label>
      POSICION
      <select name="busqueda" id="busqueda" style=" font-size:14px; font-family: Arial, Helvetica, sans-serif; border-radius:7px; border-color:#666;">
        <option selected="selected">Seleccione una posicion</option>
        <option value="PORTERO">PORTERO</option>
        <option value="DEFENSA">DEFENSA</option>
        <option value="MEDIO">MEDIO</option>
        <option value="DELANTERO">DELANTERO</option>
      </select> 
      Ó NOMBRE:
    </label>
 &nbsp; 
 <label>
   <input type="text" name="busqueda2" id="busqueda2" size="32" placeholder="Escriba el nombre" style=" font-size:14px; font-family: Arial, Helvetica, sans-serif; border-radius:7px; border-color:#666;" />
   <br />
   <br />
<input type="submit" name="enviar" id="enviar" value="BUSCAR" />
 </label>
  <br />
  </form>
  <?php if (array_key_exists('busqueda'$_GET) && $totalRows_mostrar_datos == 0){?>
           </strong></strong></strong></strong></strong></strong></strong> <span style="color: #F00">No se encontraron datos</span></strong> 
           <?php //Este pedazo de codigo sirve para mostrar un mensaje de que no se encontraron resultados?>
</div>

<div id="apDiv2">
  <form id="formperfiles" name="formperfiles" method="post" action="pdf_send.php" enctype="multipart/form-data" target="_blank">
    <?php do { ?>
      <table width="588" height="407" border="1" bordercolor="#333333">
        <tr>
          <td height="23" colspan="3" bgcolor="#666666" style="text-align: center"><label>&nbsp;&nbsp;
            <input name="nombre" type="text" id="nombre" class="transparente" style="text-align:center; border:0px; font-size:20px; font-family: 'Arial Black', Gadget, sans-serif; color:#FFF" value="<?php echo $row_mostrar_datos['nombre']; ?> <?php echo $row_mostrar_datos['ap_pat']; ?> <?php echo $row_mostrar_datos['ap_mat']; ?>" size="50" readonly="readonly" />
          </label></td>
        </tr>
        <tr>
          <td width="206" rowspan="9" style="text-align: center;"><img src="imagenes/imagenes_jugadores/<?php echo $row_mostrar_datos['imagen']; ?>" width="206" height="206" /></td>
          <td width="109" rowspan="4" style="text-align: center" background="imagenes/jersey_3.png"><input name="numero" type="text" id="numero" class="transparente" style="text-align:center; border:0px; font-size:30px; font-family: 'Arial Black', Gadget, sans-serif; color: #FFF" value="<?php echo $row_mostrar_datos['numero']; ?>" size="3" maxlength="3" /></td>
          <td width="251" style="border:0px"><input name="edad" class="transparente" type="text" id="edad" style="text-align:center; border:0px; font-size:15px; font-family: 'Arial Black', Gadget, sans-serif; color: #000" value="<?php echo $row_mostrar_datos['edad']; ?>" size="3" maxlength="3" readonly="readonly" />          
          <span style="font-family: Arial, Helvetica, sans-serif; font-size: 18px; color: #666;">Años</span></td>
        </tr>
        <tr>
          <td style="border:0px">
            <input name="altura" type="text" id="altura" class="transparente" style="text-align:center; border:0px; font-size:15px; font-family: 'Arial Black', Gadget, sans-serif; color: #000" value="<?php echo $row_mostrar_datos['altura']; ?>" size="3" maxlength="3" readonly="readonly" />
            <span style="font-weight: bold; font-family: Arial, Helvetica, sans-serif; font-size: 18px; color: #666;">m. </span></td>
        </tr>
        <tr>
          <td style="border:0px">
            <input name="peso" type="text" id="peso" class="transparente" style="text-align:center; border:0px; font-size:15px; font-family: 'Arial Black', Gadget, sans-serif; color: #000" value="<?php echo $row_mostrar_datos['peso']; ?>" size="3" maxlength="3" readonly="readonly" />
            <span style="font-family: Arial, Helvetica, sans-serif; font-size: 18px; font-weight: bold; color: #666;">Kg.</span></td>
        </tr>
        <tr>
          <td style="border:0px">
            <span style="font-family: Arial, Helvetica, sans-serif; font-weight: bold; color: #666;">Pais:</span>
            <input name="nacionalidad" type="text" id="nacionalidad" class="transparente" style="border:0px; font-size:15px; font-family: 'Arial Black', Gadget, sans-serif; color: #000" value="<?php echo $row_mostrar_datos['nacionalidad']; ?>" readonly="readonly" />
          </td>
        </tr>
        <tr>
          <td colspan="2" style="border:0px">
            <label></label>
            <span style="text-align: left"><span style="font-family: Arial, Helvetica, sans-serif; font-weight: bold; color: #666;">Posición:</span><span>
  <label>
  <input name="posicion" type="text" class="transparente" id="posicion" style="border:0px; font-size:15px; font-family: 'Arial Black', Gadget, sans-serif; color: #000" value="<?php echo $row_mostrar_datos['posicion']; ?>" readonly="readonly" />
    </label>
            </span></span></td>
        </tr>
        <tr>
          <td colspan="2" style="border:0px"> <span style="font-weight: bold; font-family: Arial, Helvetica, sans-serif; color: #666;">Apodo:</span>
            <input name="apodo" type="text" id="apodo" class="transparente" style="border:0px; font-size:15px; font-family: 'Arial Black', Gadget, sans-serif; color: #000" value="<?php echo $row_mostrar_datos['apodo']; ?>" readonly="readonly" />
          </td>
        </tr>
        <tr>
          <td colspan="2" style="border:0px"><span style="font-family: Arial, Helvetica, sans-serif; font-weight: bold; color: #666;">Habilidad:</span>          <input name="habilidad" type="text" class="transparente" id="habilidad" style="border:0px; font-size:15px; font-family: 'Arial Black', Gadget, sans-serif; color: #000" value="<?php echo $row_mostrar_datos['habilidad']; ?>" readonly="readonly" /></td>
        </tr>
        <tr>
          <td colspan="2" style="font-family: Arial, Helvetica, sans-serif; font-weight: bold; border:0px; color: #666;">Comentarios:</td>
        </tr>
        <tr>
          <td colspan="2"><textarea name="comentarios" cols="40" rows="3" readonly="readonly" class="transparente" id="comentarios" style="border:0px; font-size:15px; font-family: 'Arial Black', Gadget, sans-serif; color: #000"><?php echo $row_mostrar_datos['comentarios']; ?></textarea></td>
        </tr>
        <tr>
          <td colspan="3" bgcolor="#333333"><label>
            <input type="submit" name="generar" id="generar" value="GENERAR PDF" />
          </label>            &nbsp; &nbsp;&nbsp; &nbsp;</td>
        </tr>
      </table>
      <?php } while ($row_mostrar_datos mysql_fetch_assoc($mostrar_datos)); ?>
  </form>
</div>
<div id="marco" class="CuadroBlanco"></div>

<div id="titulo">PERFILES DE  JUGADORES</div>

<div id="paginacion">
  <table width="200" border="0">
    <tr>
      <td colspan="2" style="text-align:center"><?php
// Recordset Navigator by Felixone.it
$fx_start 0;
$fx_numOfPages ceil($totalRows_mostrar_datos/$maxRows_mostrar_datos);
if (
$fx_numOfPages 1) {
  echo 
"Resultados <select name=\"navmenu\" onChange=\"javascript: if (options[selectedIndex].value) window.location.href = (options[selectedIndex].value)\">\n";
  while (
$fx_start $fx_numOfPages) {
    
$fx_preStr "";
    if (
$fx_start != $pageNum_mostrar_datos) { // fx navbar
      
$fx_preStr $currentPage."?pageNum_mostrar_datos=".$fx_start.$queryString_mostrar_datos;
    }
    
$selected $fx_preStr == "" " selected" "";
    
// set mode ordinal
    
$fx_total $fx_numOfPages;
    echo 
"<option value=\"".$fx_preStr."\"".$selected.">".($fx_start+1)."</option>\n";
    
$fx_start++;
  }
  echo 
"</select> de $fx_total\n";
}
?></td>
    </tr>
    <tr>
      <td style="text-align:center"><a href="<?php printf("%s?pageNum_mostrar_datos=%d%s"$currentPagemax(0$pageNum_mostrar_datos 1), $queryString_mostrar_datos); ?>">Anterior</a></td>
      <td style="text-align:center"><a href="<?php printf("%s?pageNum_mostrar_datos=%d%s"$currentPagemin($totalPages_mostrar_datos$pageNum_mostrar_datos 1), $queryString_mostrar_datos); ?>">Siguiente</a></td>
    </tr>
  </table>
</div>
</body>
</html>
<?php
mysql_free_result
($mostrar_datos);
?>
  #5 (permalink)  
Antiguo 23/08/2013, 09:50
Avatar de rachpts  
Fecha de Ingreso: febrero-2012
Mensajes: 117
Antigüedad: 12 años, 1 mes
Puntos: 0
Generar pdf a partir de variables enviadas por url

Hola que tal necesito pedirles ayuda para generar un pdf el problema es que paso las variables por url y a partir de estas variables que envio tengo q crear mi pdf alguien me podria ayudar de favor

Etiquetas: dompdf, libreria, mysql, pdf, almacenadas, usuarios
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 08:20.