Me gustaria saber si en lugar de mostrar el pdf que genero por pantalla con pdf->stream();
Me gustaria copiar el pdf en una carpeta del server.. sin mostrar el documento por pantalla.
Navegando he encontrado una función que intenta solucionar el problema... el caso es que no me funciona... no se si llamo bien la función.
A parte tambien he puesto los permisos a 0777 para permitir el acceso.
La función:
Código PHP:
function Output($name='',$dest='')
{
//Output PDF to some destination
//Finish document if necessary
if($this->state<3)
$this->Close();
//Normalize parameters
if(is_bool($dest))
$dest=$dest ? 'D' : 'F';
$dest=strtoupper($dest);
if($dest=='')
{
if($name=='')
{
$name='doc.pdf';
$dest='I';
}
else
$dest='F';
}
switch($dest)
{
case 'I':
//Send to standard output
if(ob_get_contents())
$this->Error('Some data has already been output, can\'t send PDF file');
if(php_sapi_name()!='cli')
{
//We send to a browser
header('Content-Type: application/pdf');
if(headers_sent())
$this->Error('Some data has already been output to browser, can\'t send PDF file');
header('Content-Length: '.strlen($this->buffer));
header('Content-disposition: inline; filename="'.$name.'"');
}
echo $this->buffer;
break;
case 'D':
//Download file
if(ob_get_contents())
$this->Error('Some data has already been output, can\'t send PDF file');
if(isset($_SERVER['HTTP_USER_AGENT']) && strpos($_SERVER['HTTP_USER_AGENT'],'MSIE'))
header('Content-Type: application/force-download');
else
header('Content-Type: application/octet-stream');
if(headers_sent())
$this->Error('Some data has already been output to browser, can\'t send PDF file');
header('Content-Length: '.strlen($this->buffer));
header('Content-disposition: attachment; filename="'.$name.'"');
echo $this->buffer;
break;
case 'F':
//Save to local file
$f=fopen($name,'wb');
if(!$f)
$this->Error('Unable to create output file: '.$name);
fwrite($f,$this->buffer,strlen($this->buffer));
fclose($f);
break;
case 'S':
//Return as a string
return $this->buffer;
default:
$this->Error('Incorrect output destination: '.$dest);
}
return '';
}
Código PHP:
$pdf->ezStream();
$pdf->Output("filename.pdf","D");
o
$pdf->Output("filename.pdf","F");
¡Muchas gracias por adelantado!