Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    Regular Coder
    Join Date
    May 2010
    Posts
    207
    Thanks
    0
    Thanked 0 Times in 0 Posts

    File does not begin with '%PDF-

    I am not familiar of generating pdf from php. I tried the code below, and acrobat display that error?

    PHP Code:
    <?php

    $fileName 
    'filetest.pdf';
    header("Content-type: application/pdf");
    header("Content-Disposition: inline; filename=$fileName");

    echo 
    "test";

    ?>

  • #2
    Super Moderator Inigoesdr's Avatar
    Join Date
    Mar 2007
    Location
    Florida, USA
    Posts
    3,642
    Thanks
    2
    Thanked 405 Times in 397 Posts
    You can't just output text and call it a PDF. PDF is a special format that you need to generate. Look in to DOMPDF, FPDF, TCPDF, or the native PDF library if you have it compiled in to PHP.

  • #3
    Regular Coder
    Join Date
    May 2010
    Posts
    207
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by Inigoesdr View Post
    You can't just output text and call it a PDF. PDF is a special format that you need to generate. Look in to DOMPDF, FPDF, TCPDF, or the native PDF library if you have it compiled in to PHP.
    Thanks for the reply, I have heard of them and is googling to see which one is better to use.

    Between DOMPDF, FPDF, TCPDF, MPDF based on your experience which is better in terms of ease of use and capabilities? Which do you prefer?
    Last edited by Anishgiri; 09-18-2011 at 02:19 AM.

  • #4
    Super Moderator Inigoesdr's Avatar
    Join Date
    Mar 2007
    Location
    Florida, USA
    Posts
    3,642
    Thanks
    2
    Thanked 405 Times in 397 Posts
    I prefer TCPDF personally because it seems to be the most consistent when writing HTML to the PDF and has some nice features I use frequently like the ability to add a header, background to each page, and auto page break.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •