hola comunidad estoy tratando de usar la libreria HTML_ToPDF pero me da un problemita, cuando le doy en el boton exportar me sale en el firefox, la opcion de abrir o guardar el pdf pero me sale dos veces, en la primera dice "de: localhost" y en la segunda "de: /temp" he tratado de arreglar esto pero no se como hacerlo, si alguien puede mirarme el codigo a ver que tengo mal se lo agradecere.
esta es la clase prueba.php
Código:
<?php
require_once '/../HTML_ToPDF/HTML_ToPDF.php';
class HTML_PDF
{
public static function Rerderizar()
{
$html = $_POST['html'];
$linkToPDFFull = $linkToPDF = tempnam(dirname(__FILE__), 'PDF-');
unlink($linkToPDFFull);
$linkToPDFFull .= '.pdf';
$defaultDomain = 'localhost';
$pdf = new HTML_ToPDF($html, $defaultDomain);
$result = $pdf->convert();
if (is_a($result, 'HTML_ToPDFException'))
{
die($result->getMessage());
}
else
{
copy($result, $linkToPDFFull);
unlink($result);
}
header("Cache-control: private");
header("Expires: ".gmdate("D, d M Y H:i:s", mktime(date("H")+2, date("i"), date("s"), date("m"), date("d"), date("Y")))." GMT");
header("Cache-Control: no-cache, must-revalidate");
header("Pragma: no-cache");
header('Content-Type: application/pdf');
header('Content-Disposition: attachment; filename="example.pdf"');
readfile($linkToPDFFull);
unlink($linkToPDFFull);
}
}
?>
esta es la pagina que queremos exportar
Código:
<?php ob_start() ?>
<html>
<head>
<title>Testing HTML_ToPDF</title>
<style type="text/css">
div.noprint {
display: none;
}
h6 {
font-style: italic;
font-weight: bold;
font-size: 14pt;
font-family: Courier;
color: blue;
}
/** Change the paper size, orientation, and margins */
@page {
size: 8.5in 14in;
orientation: landscape;
}
/** This is a bit redundant, but its works ;) */
/** odd pages */
@page:right {
margin-right: 1.0cm;
margin-left: 1.0cm;
margin-top: 1.0cm;
margin-bottom: 1.0cm;
}
/** even pages */
@page:left {
margin-right: 1.0cm;
margin-left: 1.0cm;
margin-top: 1.0cm;
margin-bottom: 1.0cm;
}
</style>
</head>
<body>
An example dynamic page that is converted to PDF on 8x14 paper,
in landscape mode, with 1.0cm margins!<br />
And what about <sub>subscript</sub> or <sup>superscript</sup>?<br />
Hmmm...one last test, special characters: α © »<br /><br />
This document has been encrypted with the helper PDFEncryptor class so you will need to
enter "foobar" for the password<br />
This should open straight into your PDF reader,
but, if not, click to view the PDF file.<br />
<div class="noprint">This should not show up.</div>
<h6>
This demonstrates the use of CSS classes for an element.<br />
What CSS properties and blocks can be used can be found at
<a href="http://www.tdb.uu.se/~jan/html2psug.html">http://www.tdb.uu.se/~jan/html2psug.html</a>
</h6>
Inserting a page break..<br /><br />
<!--NewPage-->
Now on to page 2!
A linked image with a relative path:<br />
<a href="http://rustyparts.com/pb"><img src="tuckered.jpg" /></a>
<?php $bufer = ob_get_contents() ?>
<?php ob_end_flush() ?>
<form id="form1" action="pdf.php" method="post">
<?php echo form_tag('actaInspeccion/exportarPDF') ?>
<input type="hidden" name="html" value="<?php $bufer?>" />
<input type="hidden" name="sf_method" value="put" />
<input type="hidden" name="sf_method" value="put" />
<input type="hidden" name="sf_method" value="put" />
<input type="submit" name="enviar" value="exportar" />
</form>
</body>
</html>