When I create PDF in PHP, how do I get the browser to render it correctly?

Posted by pavun_cool on Stack Overflow See other posts from Stack Overflow or by pavun_cool
Published on 2010-03-16T07:14:34Z Indexed on 2010/03/16 7:26 UTC
Read the original article Hit count: 408

Filed under:
|
|

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

© Stack Overflow or respective owner

Related posts about php

Related posts about pdf