2

i have a problem with fpdf ( another more =( )

i want to load a page after a pdf output... this is my end code:

.....

$pdf->MultiCell(0,10,"Totale Camper Cliente: ".$TOTAL_CLIENT." euro"."\n");
$pdf->MultiCell(0,10,"Totale Complessivo: ".$TOTAL." euro"."\n");
$pdf->MultiCell(0,10,"bye!");

$pdf->Output("$client"."_2015".".pdf",'D'); 
redirect($_SERVER["DOCUMENT_ROOT"].'index.php/site/members_area','refresh');

but the program create the pdf but dont go in /site/members_area

do you have any answer for me ? thanks a lot by

riccardo airone
  • 506
  • 1
  • 6
  • 21

1 Answers1

1

Outputting to screen followed by a redirect isn't the right approach. We need to separate the PDF generation as much as possible from all other code. As a quick solution, you can open a new window and generate the file there. The redirect can be handled through JavaScript bound to the child window by the parent window. Your parent window can reload itself if it detects the child window has been closed. An extremely brief jQuery example:

var childWindow = window.open('print.php');
$(childWindow).bind('beforeunload',function(){ location.reload(); });
Muhammad Abdul-Rahim
  • 1,980
  • 19
  • 31