By Keith Hurst on
Hi peeps,
On submitting a D6 form I am using the FPDF class to auto generate a PDF based on form values, this works well.
function myform_submit( $form, &$form_state ){
$pdf = new FPDF( parameter list here );
stuff;
stuff;
$fpdf->Output( 'mypdf.pdf', 'D' ); // this brings up the standard SAVE / VIEW pdf browser dialog
$form_state[ 'redirect' ] = 'thanks' ; // this never kicks in
drupal_goto( 'thanks' ); // this never kicks in
}
As you can see the last two statements never kick in, no page redirection takes place. It's as though the PDF is generated and offered for download but after that nada.
Any idea on how I can generate the PDF but still redirect to a page of my choice, currently the user remains on the form and I ideally do not want that.
Thanks,
Keith
Comments
Check the error log
I'm not familiar with the details of FPDF, however I would check the logs to see if there is an error before the redirect statement.
You need to pass
$form_state['redirect']a valid path. In other words if you try to navigate to /thanks in your browser is there a page mapped there?Perhaps try commenting out the FPDF statements at first and see if you can figure out the redirect first?
The redirect takes place
The redirect takes place without the FPDF stuff, the path I have given is correct.
I am assuming that the Output from FPDF is constuctring the pdf as required then simply doing the headers for a standard file download. I will have a look at the FPDF code to see if there is any way I can inject a redirection after the download has been offered.
Thanks,
Keith