Determine the destination of a generated PDF

1

Good community, I ask for your help again, this time it is about the generation of a PDF document with the mPDF library.

The query is as follows: How do I determine the destination of my PDF generated? That is, I know that when the document is generated, the user is given the option to save or open, but regardless of these options I want to save it in a specific folder when it is generated. It would be something like 2 documents, one that I keep through the code, and another that the user decides whether to open it or save it. Here I leave a portion of my code in case it is useful. Thanks in advance.

$mpdf = new mPDF('c', 'A5');$css= file_get_contents("recursos/estilos/estilo_reporte.css");
$mpdf->WriteHTML($css,1);
$mpdf->writeHTML($HTML,2);
$mpdf->Output('Reporte.pdf','I');
    
asked by Jalkhov 27.12.2017 в 23:38
source

1 answer

3

You can use two methods Output , one to save it inside your server and another one to show it in the browser, example:

$mpdf = new mPDF('c', 'A5');$css= file_get_contents("recursos/estilos/estilo_reporte.css");
$mpdf->WriteHTML($css,1);
$mpdf->writeHTML($HTML,2);
$mpdf->Output('/ruta/para/guardar/tu/Reporte.pdf', 'F'); //guarda a ruta
$mpdf->Output('Reporte.pdf','I'); //muestra a usuario
//$mpdf->Output('Reporte.pdf','D'); //descargar directamente

You can use two html buttons, one to show and another to save to the server and / or download the pdf with the previous code.

    
answered by 27.12.2017 / 23:55
source