0

I have an order form which generates a pdf then prints it automatically using TCPDF. to print it i have to open it which opens a web PDF.

here is the code that opens my pdf

$pdf->Output('test.pdf', 'I');

how can i redirect the user after the print dialog has closed

  • Please post your code to open the PDF. Do you open it in a new window by javascript? – tillz Jul 18 '14 at 00:42
  • If it's printed from the web page, look at [**`this`**](http://stackoverflow.com/a/19115657/2518525). – Darren Jul 18 '14 at 00:42
  • $pdf->Output('test.pdf', 'I'); – user3244715 Jul 18 '14 at 00:44
  • 1
    try the answers from the page you linked, but replace `window.close();` with `window.location.href='http://target.site'`. If this doesn't work (seems like different browsers behave different) - sorry, don't know – tillz Jul 18 '14 at 00:49
  • Might be best to overlay a message on your screen once the print dialog has opened, and try and force the user to "click here to proceed" etc – scrowler Jul 18 '14 at 01:58

1 Answers1

0
window.addEventListener("afterprint", af_pri);
function af_pri(){
   window.location.replace("https://stackoverflow.com");
}
  • 3
    You should avoid the code only as an answer rather you should provide a description for the OP as well as for future readers otherwise it can be downvoted or deleted permanently. – Suraj Kumar Mar 08 '20 at 13:52