SitePoint Sponsor

User Tag List

Page 1 of 2 12 LastLast
Results 1 to 25 of 41
  1. #1
    Non-Member
    Join Date
    Jun 2007
    Posts
    254
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    How do I create PDF files (was "Need Urgent Help")

    Heya,

    How do I create PDF files, using Xampp from Portableapps.com, found at the following address?:

    URL: http://www.apachefriends.org/downloa...in32-1.6.2.exe

    What needs to be done?

  2. #2
    ✯✯✯ silver trophybronze trophy php_daemon's Avatar
    Join Date
    Mar 2006
    Posts
    5,284
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    You might find this article useful: http://www.sitepoint.com/article/generate-pdfs-php
    Saul

  3. #3
    Non-Member
    Join Date
    Jun 2007
    Posts
    254
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Need Urgent Help

    I visited the website you specified (http://www.sitepoint.com/article/generate-pdfs-php) that mentions the following:

    In order to use PHP's PDF manipulation capabilities, you need to have the PDFLib library installed on your system. If you're working on Linux, you can download a copy from http://www.pdflib.com/pdflib/index.html and compile it for your box. If you're running Windows, your job is even simpler - a pre-built PDF library is bundled with your distribution, and all you need to do is activate it by uncommenting the appropriate lines in your PHP configuration file.
    Where do I find the PHP Configuration File, is this it? (What needs to be changed?)

    I am using Xampp from Portableapps.com, found at the following address?:
    URL: http://www.apachefriends.org/downloa...in32-1.6.2.exe
    Last edited by Salchester; Jul 23, 2007 at 12:00.

  4. #4
    ✯✯✯ silver trophybronze trophy php_daemon's Avatar
    Join Date
    Mar 2006
    Posts
    5,284
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Yes, it's php.ini. Find the line with php_pdf.dll and uncomment it. Make sure the .dll is found under the directory specified by extension_dir.

    I know nothing about xampp and the likes as I always do manual installations of php, so it's possible there are some quirks with that. Do try a sample from that article to see if it works.
    Saul

  5. #5
    Non-Member
    Join Date
    Jun 2007
    Posts
    254
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    How do I manual Install PHP?
    Where do I get the setup file from?

  6. #6
    ✯✯✯ silver trophybronze trophy php_daemon's Avatar
    Join Date
    Mar 2006
    Posts
    5,284
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    You can find it at http://www.php.net/downloads.php

    Keep in mind that you will have to configure your apache installation to work on this new installation. Might even need to install apache manually too.

    Worth a try of course. But perhaps you can find a workaround for xampp.
    Saul

  7. #7
    Non-Member
    Join Date
    Jun 2007
    Posts
    254
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    How do I create PDF files (was "Need Urgent Help")

    How do I take uncomment php_pdf.dll, if the following commented or uncommented?

    ;extension=php_pdf.dll

    Also, what do you mean by the following?:

    Make sure the .dll is found under the directory specified by extension_dir.

  8. #8
    ✯✯✯ silver trophybronze trophy php_daemon's Avatar
    Join Date
    Mar 2006
    Posts
    5,284
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Remove the semicolon in front of the line.

    By the extension_dir setting I mean, that you should check the path specified for that setting in php.ini and check if php_pdf.dll is under that path.
    Saul

  9. #9
    Non-Member
    Join Date
    Jun 2007
    Posts
    254
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    How do I create PDF files (was "Need Urgent Help")

    OK, I have removed the semicolon in front of the line, and saved the file.

    My extension_dir is C:\Documents and Settings\Dale Piper\Desktop\xampplite\php\ext says phpinfo() and php_pdf.dll is in that directory.

    When I try and execute the following code copied from the tutorial, I keep getting the following error message:

    Fatal error: Uncaught exception 'PDFlibException' with message 'Metrics data for font 'Arial' not found' in C:\Documents and Settings\Dale Piper\Desktop\xampplite\htdocs\PDF.php:12 Stack trace: #0 C:\Documents and Settings\Dale Piper\Desktop\xampplite\htdocs\PDF.php(12): pdf_findfont(Resource id #2, 'Arial', 'host', 1) #1 {main} thrown in C:\Documents and Settings\Dale Piper\Desktop\xampplite\htdocs\PDF.php on line 12

    Code PHP:
    <?php
    // create handle for new PDF document
    $pdf = pdf_new();
     
    // open a file
    pdf_open_file($pdf, "philosophy.pdf");
     
    // start a new page (A4)
    pdf_begin_page($pdf, 595, 842);
     
    // get and use a font object
    $arial = pdf_findfont($pdf, "Arial", "host", 1); pdf_setfont($pdf, $arial, 10);
     
    // print text
    pdf_show_xy($pdf, "There are more things in heaven and earth, Horatio,", 50, 750); pdf_show_xy($pdf, "than are dreamt of in your philosophy", 50, 730);
     
    // end page
    pdf_end_page($pdf);
     
    // close and save file
    pdf_close($pdf);
    ?>

  10. #10
    ✯✯✯ silver trophybronze trophy php_daemon's Avatar
    Join Date
    Mar 2006
    Posts
    5,284
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Looks like it doesn't find the Arial font. Try copying arial.tff to your script directory and rename it to arial.ttf in your script. Good news is that pdf lib is working after all.
    Saul

  11. #11
    Non-Member
    Join Date
    Jun 2007
    Posts
    254
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Where do I find arial.tff?

  12. #12
    ✯✯✯ silver trophybronze trophy php_daemon's Avatar
    Join Date
    Mar 2006
    Posts
    5,284
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    If you're on windows, it's c:\windows\fonts
    Saul

  13. #13
    Non-Member
    Join Date
    Jun 2007
    Posts
    254
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    How do I create PDF files (was "Need Urgent Help")

    I now get greeted with the following error message:

    Fatal error: Uncaught exception 'PDFlibException' with message 'Metrics data for font 'arial.ttf' not found' in C:\Documents and Settings\Dale Piper\Desktop\xampplite\htdocs\PDF.php:12 Stack trace: #0 C:\Documents and Settings\Dale Piper\Desktop\xampplite\htdocs\PDF.php(12): pdf_findfont(Resource id #2, 'arial.ttf', 'host', 1) #1 {main} thrown in C:\Documents and Settings\Dale Piper\Desktop\xampplite\htdocs\PDF.php on line 12

  14. #14
    ✯✯✯ silver trophybronze trophy php_daemon's Avatar
    Join Date
    Mar 2006
    Posts
    5,284
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Actually, I just found out that function is deprecated (pdf_findfont), try using PDF_load_font instead.
    Saul

  15. #15
    Non-Member
    Join Date
    Jun 2007
    Posts
    254
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    What do I change in the code, to reflect this new font?

    Code PHP:
    <?php
    // create handle for new PDF document
    $pdf = pdf_new();
     
    // open a file
    pdf_open_file($pdf, "philosophy.pdf");
     
    // start a new page (A4)
    pdf_begin_page($pdf, 595, 842);
     
    // get and use a font object
    $arial = pdf_findfont($pdf, "Arial", "host", 1); pdf_setfont($pdf, $arial, 10);
     
    // print text
    pdf_show_xy($pdf, "There are more things in heaven and earth, Horatio,", 50, 750); pdf_show_xy($pdf, "than are dreamt of in your philosophy", 50, 730);
     
    // end page
    pdf_end_page($pdf);
     
    // close and save file
    pdf_close($pdf);
    ?>

    Do I just put this code in a php file as-is or do I need to include a link to the PHP_PDF.dll?

  16. #16
    ✯✯✯ silver trophybronze trophy php_daemon's Avatar
    Join Date
    Mar 2006
    Posts
    5,284
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Just this, I presume: $arial = pdf_load_font($pdf, "Arial", "host", 1);
    Saul

  17. #17
    Non-Member
    Join Date
    Jun 2007
    Posts
    254
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    How do I create PDF files (was "Need Urgent Help")

    I now get greeted with the following error message, Now What?:

    Fatal error: Uncaught exception 'PDFlibException' with message 'Unknown option '1'' in C:\Documents and Settings\Dale Piper\Desktop\xampplite\htdocs\PDF.php:12 Stack trace: #0 C:\Documents and Settings\Dale Piper\Desktop\xampplite\htdocs\PDF.php(12): pdf_load_font(Resource id #2, 'Arial', 'host', '1') #1 {main} thrown in C:\Documents and Settings\Dale Piper\Desktop\xampplite\htdocs\PDF.php on line 12

    Code PHP:
    <?php
    // create handle for new PDF document
    $pdf = pdf_new();
     
    // open a file
    pdf_open_file($pdf, "philosophy.pdf");
     
    // start a new page (A4)
    pdf_begin_page($pdf, 595, 842);
     
    // get and use a font object
    $arial = pdf_load_font($pdf, "Arial", "host", 1);
     
    // print text
    pdf_show_xy($pdf, "There are more things in heaven and earth, Horatio,", 50, 750); pdf_show_xy($pdf, "than are dreamt of in your philosophy", 50, 730);
     
    // end page
    pdf_end_page($pdf);
     
    // close and save file
    pdf_close($pdf);
    ?>

  18. #18
    ✯✯✯ silver trophybronze trophy php_daemon's Avatar
    Join Date
    Mar 2006
    Posts
    5,284
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Right, try
    Code php:
    $arial = pdf_load_font($pdf, "Arial", "host", '');
    and you dropped this one:
    Code php:
    pdf_setfont($pdf, $arial, 10);
    Saul

  19. #19
    Non-Member
    Join Date
    Jun 2007
    Posts
    254
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by php_daemon View Post
    Right, try
    Code php:
    $arial = pdf_load_font($pdf, "Arial", "host", '');
    and you dropped this one:
    Code php:
    pdf_setfont($pdf, $arial, 10);
    What?

  20. #20
    ✯✯✯ silver trophybronze trophy php_daemon's Avatar
    Join Date
    Mar 2006
    Posts
    5,284
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)


    Code php:
    <?php
    // create handle for new PDF document
    $pdf = pdf_new();
     
    // open a file
    pdf_open_file($pdf, "philosophy.pdf");
     
    // start a new page (A4)
    pdf_begin_page($pdf, 595, 842);
     
    // get and use a font object
    $arial = pdf_load_font($pdf, "Arial", "host", '');
    pdf_setfont($pdf, $arial, 10);
     
    // print text
    pdf_show_xy($pdf, "There are more things in heaven and earth, Horatio,", 50, 750); pdf_show_xy($pdf, "than are dreamt of in your philosophy", 50, 730);
     
    // end page
    pdf_end_page($pdf);
     
    // close and save file
    pdf_close($pdf);
    ?>
    Saul

  21. #21
    Non-Member
    Join Date
    Jun 2007
    Posts
    254
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by php_daemon View Post


    Code php:
    <?php
    // create handle for new PDF document
    $pdf = pdf_new();
     
    // open a file
    pdf_open_file($pdf, "philosophy.pdf");
     
    // start a new page (A4)
    pdf_begin_page($pdf, 595, 842);
     
    // get and use a font object
    $arial = pdf_load_font($pdf, "Arial", "host", '');
    pdf_setfont($pdf, $arial, 10);
     
    // print text
    pdf_show_xy($pdf, "There are more things in heaven and earth, Horatio,", 50, 750); pdf_show_xy($pdf, "than are dreamt of in your philosophy", 50, 730);
     
    // end page
    pdf_end_page($pdf);
     
    // close and save file
    pdf_close($pdf);
    ?>
    On the PHP website - http://www.php.net/downloads.php

    Which file do I download, to intall PHP manually, then what do I do?

  22. #22
    ✯✯✯ silver trophybronze trophy php_daemon's Avatar
    Join Date
    Mar 2006
    Posts
    5,284
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Then you install it.

    I assume the above script didn't work? I've one more thing on my mind to try. Try changing the encoding:
    Code php:
    $arial = pdf_load_font($pdf, "Arial", "winansi", '');
    Saul

  23. #23
    Non-Member
    Join Date
    Jun 2007
    Posts
    254
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    to what?

  24. #24
    ✯✯✯ silver trophybronze trophy php_daemon's Avatar
    Join Date
    Mar 2006
    Posts
    5,284
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    To that. Notice how 'host' became 'winansi'.
    Code php:
    <?php
    // create handle for new PDF document
    $pdf = pdf_new();
     
    // open a file
    pdf_open_file($pdf, "philosophy.pdf");
     
    // start a new page (A4)
    pdf_begin_page($pdf, 595, 842);
     
    // get and use a font object
    $arial = pdf_load_font($pdf, "Arial", "winansi", '');
    pdf_setfont($pdf, $arial, 10);
     
    // print text
    pdf_show_xy($pdf, "There are more things in heaven and earth, Horatio,", 50, 750); pdf_show_xy($pdf, "than are dreamt of in your philosophy", 50, 730);
     
    // end page
    pdf_end_page($pdf);
     
    // close and save file
    pdf_close($pdf);
    ?>
    Saul

  25. #25
    Non-Member
    Join Date
    Jun 2007
    Posts
    254
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Why? What does that do?


Bookmarks

Posting Permissions

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