Foros del Web » Programando para Internet » PHP »

Convertir .doc a html ?

Estas en el tema de Convertir .doc a html ? en el foro de PHP en Foros del Web. Buenas noches, estube buscando un poco para hacer esto, de convertir un documento word a html, y todas las clases que vi flotando por la ...
  #1 (permalink)  
Antiguo 02/01/2009, 19:08
 
Fecha de Ingreso: febrero-2008
Mensajes: 33
Antigüedad: 16 años, 2 meses
Puntos: 1
Convertir .doc a html ?

Buenas noches, estube buscando un poco para hacer esto, de convertir un documento word a html, y todas las clases que vi flotando por la red, no me funcionaron o no la pude hacer funcionar.

Alguien sabe como podria hacer para pasar los documentos .DOC a HTML con php?
Es urgente.
También si alguien sabe como hacer para convertir pdf a html con php me ayudaria mucho.
Muchas gracias.
  #2 (permalink)  
Antiguo 02/01/2009, 23:48
 
Fecha de Ingreso: diciembre-2007
Mensajes: 927
Antigüedad: 16 años, 4 meses
Puntos: 12
Respuesta: Convertir .doc a html ?

Te recomendaria leer el archivo .doc y luego imrpimirlo y guardarlo en un nuevo archivo .html

Code:
Leer .doc
Código PHP:
$word = new COM("word.application") or die("Unable to instantiate Word");
$word->Documents->Open($filename);
$new_filename substr($filename,0,-4) . ".txt";
// the '2' parameter specifies saving in txt format

$word->Documents[1]->SaveAs($new_filename,2);
$word->Documents[1]->Close(false);
$word->Quit();
$word->Release();
$word NULL;
unset(
$word);
$fh fopen($new_filename'r');
// this is where we exit Hell

$contents fread($fhfilesize($new_filename));
fclose($fh);
unlink($new_filename); 
Crear .html
Código PHP:
/* creates an html element, like in js */  
class html_element  
{  
    
/* vars */  
    
var $type;  
    var 
$attributes;  
    var 
$self_closers;  
      
    
/* constructor */  
    
function html_element($type,$self_closers = array('input','img','hr','br','meta','link'))  
    {  
        
$this->type strtolower($type);  
        
$this->self_closers $self_closers;  
    }  
      
    
/* get */  
    
function get($attribute)  
    {  
        return 
$this->attributes[$attribute];  
    }  
      
    
/* set -- array or key,value */  
    
function set($attribute,$value '')  
    {  
        if(!
is_array($attribute))  
        {  
            
$this->attributes[$attribute] = $value;  
        }  
        else  
        {  
            
$this->attributes array_merge($this->attributes,$attribute);  
        }  
    }  
      
    
/* remove an attribute */  
    
function remove($att)  
    {  
        if(isset(
$this->attributes[$att]))  
        {  
            unset(
$this->attributes[$att]);  
        }  
    }  
      
    
/* clear */  
    
function clear()  
    {  
        
$this->attributes = array();  
    }  
      
    
/* inject */  
    
function inject($object)  
    {  
        if(@
get_class($object) == __class__)  
        {  
            
$this->attributes['text'].= $object->build();  
        }  
    }  
      
    
/* build */  
    
function build()  
    {  
        
//start  
        
$build '<'.$this->type;  
          
        
//add attributes  
        
if(count($this->attributes))  
        {  
            foreach(
$this->attributes as $key=>$value)  
            {  
                if(
$key != 'text') { $build.= ' '.$key.'="'.$value.'"'; }  
            }  
        }  
          
        
//closing  
        
if(!in_array($this->type,$this->self_closers))  
        {  
            
$build.= '>'.$this->attributes['text'].'</'.$this->type.'>';  
        }  
        else  
        {  
            
$build.= ' />';  
        }  
          
        
//return it  
        
return $build;  
    }  
      
    
/* spit it out */  
    
function output()  
    {  
        echo 
$this->build();  
    }  

dime que como te va los codes los saque de webs xD
  #3 (permalink)  
Antiguo 18/12/2009, 02:20
Avatar de cubic  
Fecha de Ingreso: febrero-2007
Mensajes: 51
Antigüedad: 17 años, 2 meses
Puntos: 1
Respuesta: Convertir .doc a html ?

Y en ASP alguien tiene un script?
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 14:34.