Reputation: 5345
I have used following code to create a simple PDF file. It executes fine in browsers, but I am not able to get the PDF file. It gives me some output when I am running the code in the CLI; my doubt is where I specify the PDF's filename.
<?php
require('fpdf.php');
$pdf=new FPDF();
$pdf->AddPage();
$pdf->SetFont('Arial','B',16);
$pdf->Cell(40,10,'Hello World!');
$pdf->Output();
?>
CLI output: 2 0 obj << /Type /Page /Parent 1 0 R /Contents 3 0 R >> endobj 3 0 obj << /Length 4 0 R >> stream 2.834646 0 0 2.834646 0 841.9 cm 2 J 0.2 w BT /F1 5.64 Tf ET BT 11 -16.692 Td (Hello World!) Tj ET
Upvotes: 2
Views: 277
Reputation: 382881
This is how you can create the file:
$pdf=new FPDF();
$pdf->AddPage();
$pdf->SetFont('Arial','B',16);
$pdf->Cell(40,10,'Hello World!');
$pdf->Output('myFile.pdf', 'F');
Just specify file name to output
function.
Upvotes: 2
Reputation: 81132
You're probably looking for the "Content-type" and "Content-disposition" headers. The documentation for PHP's header function in its own manual give an example for the specific task you're trying to do.
Though I see why you wouldn't have any indication that the "header" function is where to look.
Upvotes: 2