it is about pdf generation with php problem

A

Anonymous

Guest
Hello,
it is the first time i use FPDF to generate pdf file with php script. After i use the testing file

<?php
define('FPDF_FONTPATH','../font/');
require('../fpdf.php');

$pdf=new FPDF();
$pdf->AddPage();
$pdf->SetFont('Arial','B',16);
$pdf->Cell(40,10,'Hello World!');
$pdf->Output();
?>

to generate the hello wold pdf file.

After i tested it, it work in mozilla explorer but cannot work in IE. In IE, the output just show many characters not pdf file:

%PDF-1.3 3 0 obj <> endobj 4 0 obj <> stream x?R謼2?5W(蔦 Q苡3T04?0PISp ?Z*?(hx斗鳵+憭(j*7W endstream endobj 1 0 obj <> endobj 5 0 obj <> endobj 2 0 obj <> >> endobj 6 0 obj << /Producer (FPDF 1.52) /CreationDate (D:20040604161730) >> endobj 7 0 obj << /Type /Catalog /Pages 1 0 R /OpenAction [3 0 R /FitH null] /PageLayout /OneColumn >> endobj xref 0 8 0000000000 65535 f 0000000228 00000 n 0000000416 00000 n 0000000009 00000 n 0000000087 00000 n 0000000315 00000 n 0000000504 00000 n 0000000580 00000 n trailer << /Size 8 /Root 7 0 R /Info 6 0 R >> startxref 683 %%EOF

I don't know why? Someone can help me solve the porblem :help:

Thanks a lot!!!
 
That usually happens to me when you are viewing a page that was previously in the cache. Delete your cache exit the browser and try again.
 
You have to use the header() function to send the correct headers to the browser, so that it knows that it's recieving a PDF document. This is covered, of course, in the documentation. See Example 2.
 
Back
Top