Ver Mensaje Individual
  #3 (permalink)  
Antiguo 09/09/2014, 16:29
Avatar de omar_gutierrez
omar_gutierrez
 
Fecha de Ingreso: febrero-2011
Mensajes: 144
Antigüedad: 14 años
Puntos: 2
Respuesta: Descargar archivo word phpword

Gracias por responder pateketrueke, la strip_tags no la encontraba, como eliminar los html tags.

La html_entity_decode ya lo habia intentado, pero sin tener buenos resultados, no se si tengo que especificar algun header para el charset, aunque este archivo lo unico que hace es el query, crear el archivo .docx, y descargarlo.

Código PHP:
<?php
include 'db.php';
$query $mysqli->query("SELECT * FROM notas WHERE id = '".$_GET['id']."'");
$res $query->fetch_array(MYSQLI_ASSOC);

require_once 
'../PHPWord.php';

// New Word Document
$PHPWord = new PHPWord();

// New portrait section
$section $PHPWord->createSection();

// Add text elements
$section->addText($res['cabeza'], array('name'=>'Verdana'));
$section->addTextBreak(1);

$section->addText(strip_tags(html_entity_decode($res['nota'])), null'pStyle');

// Save File
$objWriter PHPWord_IOFactory::createWriter($PHPWord'Word2007');
$objWriter->save('Text.docx');


header('Content-Description: File Transfer');
header('Content-type: application/force-download');
header('Content-Disposition: attachment; filename='.basename('Text.docx'));
header('Content-Transfer-Encoding: binary');
header('Content-Length: '.filesize('Text.docx'));
readfile('Text.docx');
unlink('Text.docx');
?>