0

I'm creating a PDF file in PHP:

header("Content-Type: application/pdf");
header("Content-Disposition: attachment; filename=\"file.pdf\"");
echo "Hello";

The downloaded file.pdf was not able to open. It says "Adobe Reader could not open the file because it is either not a supported file type or because the file has been damaged (for example, it was sent as an email attachment and wasn't correctly decoded)".

But when opening the file with a text editor, only "hello" is there within the file. It looks as if it's not encoded correctly as a PDF. Any help please?

Brendan
  • 2,777
  • 1
  • 18
  • 33
Raju
  • 11
  • 2

1 Answers1

1

You can't just echo out a string and expect it to be correctly formatted into a PDF file, "like that".

You need to look into PDF generation. Here are some related questions:

Community
  • 1
  • 1
Brendan
  • 2,777
  • 1
  • 18
  • 33