+ Reply to Thread
Results 1 to 6 of 6

Thread: outputting PDF files with PHP
      
   

  1. #1
    cosmiclove is offline Sergeant Major
    Join Date
    Oct 2007
    Posts
    90

    Default 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

  2. #2
    navaldesign's Avatar
    navaldesign is offline General & Forum Moderator
    Join Date
    Oct 2005
    Location
    Italy
    Posts
    12,061

    Default 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!


  3. #3
    cosmiclove is offline Sergeant Major
    Join Date
    Oct 2007
    Posts
    90

    Default 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

  4. #4
    navaldesign's Avatar
    navaldesign is offline General & Forum Moderator
    Join Date
    Oct 2005
    Location
    Italy
    Posts
    12,061

    Default 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!


  5. #5
    cosmiclove is offline Sergeant Major
    Join Date
    Oct 2007
    Posts
    90

    Default 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

  6. #6
    navaldesign's Avatar
    navaldesign is offline General & Forum Moderator
    Join Date
    Oct 2005
    Location
    Italy
    Posts
    12,061

    Default 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!


Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

     

Posting Permissions

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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49