Ver Mensaje Individual
  #1 (permalink)  
Antiguo 19/01/2011, 23:13
manudferreiro
 
Fecha de Ingreso: enero-2007
Mensajes: 135
Antigüedad: 17 años, 3 meses
Puntos: 1
Les pido idea sobre como solucionar esto (html a pdf)

como andan?
yo mal volviéndome loco..
hace unos dias incursione en html2pdf creando pdf con imágenes para una vidriera de una inmobiliaria de un amigo, todo muy bien..
pero se me complico ahora...
la cuestion es que quiero crear una pagina sobre cada codigo que ingrese por un formulario.
el problema?
no se me ocurre como, basicamente creo que es porque conozco poco de php y mucho menos sobre estas "librerias" de manejo de pdf.
a grandes razgos explico un poco:
Código PHP:
$content ob_get_clean(); 
"chupa" todo el contenido, html con php embebido (mi caso) y lo guarda en content.
ahora, el tema es el siguiente, lo primero que me vino a la cabeza es generar un archivo includ.php (por decir) que tenga el html, el problema (por lo menos para mi) es que no se como pasarle los parametros para que vaya cambiando dinamicamente con cada codigo. se entiende?
algo mas rudimentario, fue tratar de meter todo el "html" dentro del $content , pero se me complica con las comillas (claro desconocimiento sobre el lenguaje).
llegue a pensar hasta en grabar en un archivo el html mediante manejo de ficheros..
pero ya es todo mucho divague.
acepto, sugerencias, insultos, y todo lo que tenga algo de ayuda..
por las dudas paso el codigo.
Código PHP:
<?php
/**
 * Logiciel : exemple d'utilisation de HTML2PDF
 * 
 * Convertisseur HTML => PDF
 * Distribué sous la licence LGPL. 
 *
 * @author        Laurent MINGUET <[email protected]>
 * 
 * isset($_GET['vuehtml']) n'est pas obligatoire
 * il permet juste d'afficher le résultat au format HTML
 * si le paramètre 'vuehtml' est passé en paramètre _GET
 */
     // récupération du contenu HTML
     
ob_start();
     
$num 'CMD01-'.date('ymd');
     
$nom 'DUPONT Alphonse';
     
$date '01/01/2010';
    
   
// $a = $_POST['codigo'];
    
$a '17';
    
$arrcod explode("-"$a);    
    
count($arrcod);
   
    
$vectorbd($a);
    
$row$vector[0];
    
$row2=$vector[1];                      


    function 
bd($a){
    include(
"conex.phtml"); 
       
$link=Conectarse(); 
    
$result=mysql_query("select * from galeria where codigo='$a'",$link); 
       
$row[0] = mysql_fetch_array($result); 
       
$result2 =mysql_query("select * from propiedades where codigo='$a'",$link);         
       
$row[1] = mysql_fetch_array($result2); 
     return 
$row;        
    }


?>
<style type="text/css">
<!--
.Estilo1 {
    color: #FFFF00;
    font-size: 36px;
}
.Estilo2 {
    color: #FFFF00;
    font-size: 24px;
}
.Estilo4 {
    color: #FFFFFF;
    font-size: 36px;
}
-->
</style>

 <page backtop="0mm" backbottom="0mm" backleft="0mm" backright="0mm" backtop ="0mm"  backimg="casas.jpg" backimgw="816px" > 
<table width="849" height="620" border="0" cellpadding="0" cellspacing="0" background="casas.jpg" >
  <tr> 
    <th height="91" colspan="6"  scope="row"><table width="816" border="0" cellspacing="0" cellpadding="0">
      <tr>
        <th width="333" scope="row">&nbsp;</th>
        <td width="426"><span class="Estilo1"><?php echo strtoupper ($row["operacion"]);?></span></td>
        <td width="57">&nbsp;</td>
      </tr>
    </table>      </th>
    <th height="91"  scope="row">&nbsp;</th>
  </tr>
  <tr>
    <th height="78" colspan="7"  scope="row"><table width="816" border="0" cellspacing="0" cellpadding="0">
      <tr>
        <th width="197" scope="row">&nbsp;</th>
        <td width="516"><span class="Estilo2">EXELENTE CHALET Y DEPTO. EN COSQUIN </span></td>
        <td width="103">&nbsp;</td>
      </tr>
    </table>      </th>
  </tr>
  <tr>
    <th width="25" height="291"  scope="row">&nbsp;</th>
    <th colspan="3"  scope="row"><?php echo ' <img src="'$row["foto1"].' " width="366" height="285" />';?></th>
    <th width="414"  scope="row"><p align="center"><span class="Estilo5"><br />
          <span class="Estilo1"><?php echo $row2["descripcion"]; ?><br />
38 <br />
SUP TERRENO: 432<br />
SUP TTADADAS:<br />
CONSULTE </span></span><br />
        <br />
    </p>    </th>
    <th width="4"  scope="row">&nbsp;</th>
    <th width="31"  scope="row">&nbsp;</th>
  </tr>
  <tr>
    <th rowspan="3"  scope="row">&nbsp;</th>
    
    <th width="124" rowspan="3"  scope="row"><span class="Estilo1">N&ordm; <?php echo $row["codigo"]; ?></span></th>
    <th width="122" rowspan="3"  scope="row">&nbsp;</th>
    <th width="129" rowspan="3"  scope="row">&nbsp;</th>
    <th rowspan="3"  scope="row">&nbsp;</th>
    <th rowspan="3"  scope="row">&nbsp;</th>
  </tr>
  <tr>
    <th  scope="row">&nbsp;</th>
  </tr>
  <tr>
    <th  scope="row">&nbsp;</th>
  </tr>
</table>


</page>

<?php
     $content 
ob_get_clean();
    
    
// conversion HTML => PDF
    
require_once(dirname(__FILE__).'/html2pdf.class.php');
    try
    {
        
$html2pdf = new HTML2PDF('L','A4','es'false'ISO-8859-15',array(42,22,1,1));
        
//$html2pdf->pdf->SetDisplayMode('real');
        
$html2pdf->writeHTML($content, isset($_GET['vuehtml']));
         
$html2pdf->writeHTML($content, isset($_GET['vuehtml']));
        
$out 'vidriera'.$row["codigo"].'.pdf';        
        
$html2pdf->Output($out);
    }
    catch(
HTML2PDF_exception $e) { echo $e; }