outputting PDF files with PHP

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts
  • cosmiclove
    Sergeant Major

    • Oct 2007
    • 90

    outputting PDF files with PHP

    Here is a simple code I copied froom a tutorial book in order to output PDF files with PHP.
    PHP Code:
    <? 
    require("../fpdf/fpdf.php");
    $pdf =new FPDF();
    $pdf->AddPage();
    $pdf->SetFont('Arial', 'B', 16);
    $pdf->Cell(40,10,'Hello Out There!');
    $pdf->output();
    ?>
    When placed in my browser (after uploading it to my VH DocumentRoot folder, I get the following error :
    Warning: require(../fpdf/fpdf.php) [function.require]: failed to open stream: No such file or directory in /home/mmtltlck/public_html/line.php on line 2

    Warning: require(../fpdf/fpdf.php) [function.require]: failed to open stream: No such file or directory in /home/mmtltlck/public_html/line.php on line 2

    Fatal error: require() [function.require]: Failed opening required '../fpdf/fpdf.php' (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/mmtltlck/public_html/line.php on line 2
    Is there any folder or library I shold place in my DocumentRoot folder before being able to use the FPDF function? Any help will be greatly appreciated. Thanks in advance!

    Herman
  • navaldesign
    General & Forum Moderator

    • Oct 2005
    • 12080

    #2
    Re: outputting PDF files with PHP

    hehe... sure! You need fpdf.php !!

    it is a PHP class, which allows to generate PDF files without using the PDF library.

    Please visit http://www.fpdf.org/
    Navaldesign
    Logger Lite: Low Cost, Customizable, multifeatured Login script
    Instant Download Cart: a Powerfull, Customized, in site, DB driven, e-products Cart
    DBTechnosystems.com Forms, Databases, Shopping Carts, Instant Download Carts, Loggin Systems and more....
    Advanced BlueVoda Form Processor : No coding form processor! Just install and use! Now with built in CAPTCHA!

    Comment

    • cosmiclove
      Sergeant Major

      • Oct 2007
      • 90

      #3
      Re: outputting PDF files with PHP

      Thanks, Naval, I see now. The initial code seemed too simple to be true
      I just downloaded the file from fpdf.org, so which files do I put where? in my public_html folder? The fpdf site didn't have any configuration tutorials so I can only rely on your help and any other person willing to help. Thanks again so much.
      Herman

      Comment

      • navaldesign
        General & Forum Moderator

        • Oct 2005
        • 12080

        #4
        Re: outputting PDF files with PHP

        You only need to upload the fpdf.php file. Since you have little experience with PHP it will be easier for you to upload the file in the same folder where the line.php file is .

        You should then need to change the fillowing line, as folows:

        require'fpdf.php';

        Are you sure you want to do this? apart some simple example outputs as the one you have posted above, creating a TRUE pdf document (with images, text, tables, formatted , etc) might require hours for an experienced user, for a beginner it could be days!

        Navaldesign
        Logger Lite: Low Cost, Customizable, multifeatured Login script
        Instant Download Cart: a Powerfull, Customized, in site, DB driven, e-products Cart
        DBTechnosystems.com Forms, Databases, Shopping Carts, Instant Download Carts, Loggin Systems and more....
        Advanced BlueVoda Form Processor : No coding form processor! Just install and use! Now with built in CAPTCHA!

        Comment

        • cosmiclove
          Sergeant Major

          • Oct 2007
          • 90

          #5
          Re: outputting PDF files with PHP

          yep! Just uploaded the fpdf.php file and it works! Merci beaucoup, Naval!

          Are you sure you want to do this?
          Well, seriously, after reading your replies in the 2 threads, I felt terrible, I really felt like burning all my php tutorial books and keep using just old plain static code for my website...just kidding. But you're a PHP professional, so I definitely understand that you are trying to keep me from getting BIG headaches in the future when facing more advanced PHP codes.
          I am a language professor and perhaps I see PHP as just another language to decode, and it's real fun for me (even if it's not exactly in my field and it sometimes keeps awake till 3 am at night). But I will make sure to go slowly and I may request some help once in a while or even take a regular class. Thanks so much for helping me fix this PDF stuff. I TRULY appreciate it.

          Herman

          Comment

          • navaldesign
            General & Forum Moderator

            • Oct 2005
            • 12080

            #6
            Re: outputting PDF files with PHP

            The only real world applications that require creating a PDF file on the fly are invoices, orders, application forms and vouchers (to be printed) that require that some user details or calculations performed by your scripts, are automatically embedded in the document.

            So unless your website requires such features, i really would suggest taking care more of the visual part and the content you put in.

            php is used for interactivity (or better say, php with Ajax). Database (MySQL or other) becomes at that point also necessary.

            So as you see, to make a really interactive site, you ned Javascript, PHP and MySQL knowledge. All three go together.

            If this is a challenge for you (learning) then all is fine, but if you have some specific delivery (completion) time terms, this could become quite an adventure.
            Navaldesign
            Logger Lite: Low Cost, Customizable, multifeatured Login script
            Instant Download Cart: a Powerfull, Customized, in site, DB driven, e-products Cart
            DBTechnosystems.com Forms, Databases, Shopping Carts, Instant Download Carts, Loggin Systems and more....
            Advanced BlueVoda Form Processor : No coding form processor! Just install and use! Now with built in CAPTCHA!

            Comment

            Working...
            X