L
L
leni_m2017-06-23 13:36:20
PHP
leni_m, 2017-06-23 13:36:20

After downloading pdf how to translate to another page?

header("Content-Type: application/pdf");
        header("Content-Disposition:inline;filename=\"invoice.pdf\"");
        header("Content-Transfer-Encoding: binary");

        ob_start();
        include 'pdfInvoice.php';
        $html = ob_get_contents();
        ob_end_clean();

        include("mpdf60/mpdf.php");

        $mpdf = new mPDF('utf-8', 'A4', '12', '', 10, 10, 7, 7, 10, 10);

        $stylesheet = file_get_contents('css/invoice.css'); //подключаем css
        $mpdf->WriteHTML($stylesheet, 1);

        $mpdf->WriteHTML($html, 2); //формируем pdf
        $mpdf->Output('invoice'.$_POST['id'].'.pdf', 'D');

        header("Location: /invoice/1");

Redirection doesn't work after downloading pdf. Can it be fixed?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Alexander Aksentiev, 2017-06-23
@Sanasol

http doesn't work that way.

V
vyrkmod, 2017-06-23
@vyrkmod

We read mana , there in the very first sentence it is written, "that the header () function can be called only if the client has not yet received data." The option that suits you is in the first example on the same page: "Content-Disposition: attachment;" tells the browser to "download, don't open", but when the download has started, redirect the js.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question