Reputation: 500
I have a script that creates pdf document out of a tokens array and downloads it. SO far it does not download it, nor does it put a token per page on in the document. It only reads "tokens"
$pdf = new FPDF( );
for($i = 0 ; $i < $num_tokens ; $i++){
$tokens[$i] = pronto_aes_decrypt( $token_crypt[$i] , $prontoKey );
$pdf->AddPage();
$pdf->SetFont('Arial','B',16);
$pdf->Cell(0,10,$tokens[$i]);
}
unlink("tokens.pdf");
$pdf->Output('tokens.pdf','F');
readfile('tokens.pdf');
header('Content-Type: text/csv');
header('Content-Disposition: attachment; filename="tokens.pdf"');
Upvotes: 0
Views: 2767
Reputation: 2010
You can Output
a PDF generated by FPDF for download as follows:
$pdf->Output("tokens.pdf","D");
Note: You will not be able to output more to the browser window after this, so your header
calls will not work. That said, you do not need those calls whatsoever, as the above line will output as a file for you and save you the effort of having to manage it on your own.
Upvotes: 2