Is somebody know how to show on browser and save on server in the same time a pdf file? I use PHP and PDFLIB to generate the pdf, and in the beginning i do :
PDF_open_file ($p, $DocFile);
Where $DocFile indicate the place on server where i write the pdf. And at the end , when i finished generating the pdf, in order to save the pdf somewhere on the server ,i do :
$b = PDF_close ($p);
$b = PDF_delete ($p);
I can save the file on the server but what i want to do now is to be able to save the pdf on the server and the same time display it on the browser. How can i do that? Im using Pdflib v7 with php v5.
I found myself the solution, i put it here if somebody need:
<? PDF_open_file ($p, "/tmp/test.pdf"); $pdf = pdf_new(); pdf_open_file($pdf, "/tmp/test.pdf"); pdf_set_info($pdf, "Author", "Horvath Tamas"); pdf_set_info($pdf, "Title", "Szamla"); pdf_set_info($pdf, "Creator", "ARBOMedia.net Kft"); pdf_set_info($pdf, "Subject", "Szamla"); pdf_begin_page($pdf, 595, 842); pdf_add_outline($pdf, "Page 1"); pdf_set_font($pdf, "Times-Roman", 30, "host"); pdf_set_value($pdf, "textrendering", 1); pdf_show_xy($pdf, "Hello world", 50, 750); pdf_moveto($pdf, 50, 740); pdf_lineto($pdf, 330, 740); pdf_stroke($pdf); pdf_end_page($pdf); pdf_close($pdf); pdf_delete($pdf); $len = filesize("/tmp/test.pdf"); header("Content-type: application/pdf"); header("Content-Length: $len"); header("Content-Disposition: inline; filename=test.pdf"); readfile("/tmp/test.pdf"); ?>