SitePoint Sponsor

User Tag List

Results 1 to 19 of 19

Thread: PHP to PDF

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

    PHP to PDF

    Hello Everyone,

    How do I create a PDF file in PHP that contains the following text "Testing Testing 1,2,3!!!"?

    Many Thanks,

  2. #2
    SitePoint Evangelist
    Join Date
    Aug 2005
    Posts
    453
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Documentation @ : http://us2.php.net/pdf
    Computers and Fire ...
    In the hands of the inexperienced or uneducated,
    the results can be disastrous.
    While the professional can tame, master even conquer.

  3. #3
    rajug.replace('Raju Gautam'); bronze trophy Raju Gautam's Avatar
    Join Date
    Oct 2006
    Location
    Kathmandu, Nepal
    Posts
    4,013
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    If you want to use the pre-built libraries then go for some:
    http://www.digitaljunkies.ca dompdf which converts html tags to pdf so it is called HTML2PDF too. Also you can use ezpdf class which also does the almost same task. Go to in the http://www.phpclasses.org/ and do make a search there with the keyword ezpdf.

    And of course if you want to go through yourself then you can use PHP's library http://www.php.net/pdf

    Good luck.
    Mistakes are proof that you are trying.....
    ------------------------------------------------------------------------
    PSD to HTML - SlicingArt.com | Personal Blog | ZCE - PHP 5

  4. #4
    Programming Since 1978 silver trophybronze trophy felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, NSW, Australia
    Posts
    16,603
    Mentioned
    24 Post(s)
    Tagged
    1 Thread(s)
    Another one to look at is FPDF

    http://www.fpdf.org/
    Stephen J Chapman

    javascriptexample.net, Book Reviews, follow me on Twitter
    HTML Help, CSS Help, JavaScript Help, PHP/mySQL Help, blog
    <input name="html5" type="text" required pattern="^$">

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

    PHP to PDF

    felgall,

    I tried this one before, how do I install it?

    Many Thanks,

  6. #6
    Programming Since 1978 silver trophybronze trophy felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, NSW, Australia
    Posts
    16,603
    Mentioned
    24 Post(s)
    Tagged
    1 Thread(s)
    All I did to install it was to copy the fpdf.php file to my server, add an include statement at the top of the pages where I wanted to use it, and then call the functions as required to generate the content for the file where I wanted it.

    The only point where the install became more complex was where I wanted to start using a specific non-standard font for part of the content where I then had to do additional processing to generate the font file in the correct format to use with it.
    Stephen J Chapman

    javascriptexample.net, Book Reviews, follow me on Twitter
    HTML Help, CSS Help, JavaScript Help, PHP/mySQL Help, blog
    <input name="html5" type="text" required pattern="^$">

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

    PHP to PDF

    Quote Originally Posted by felgall View Post
    All I did to install it was to copy the fpdf.php file to my server, add an include statement at the top of the pages where I wanted to use it, and then call the functions as required to generate the content for the file where I wanted it.

    The only point where the install became more complex was where I wanted to start using a specific non-standard font for part of the content where I then had to do additional processing to generate the font file in the correct format to use with it.
    How do I include a header? What is the header for using PDF?

    Many Thanks,

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

    Php To Pdf

    Rajug,

    How do I install/use PHP's PDF library http://www.php.net/pdf?
    What do I need to do to setup?

  9. #9
    rajug.replace('Raju Gautam'); bronze trophy Raju Gautam's Avatar
    Join Date
    Oct 2006
    Location
    Kathmandu, Nepal
    Posts
    4,013
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    If you are having PHP5 or upper version, it must be bundled with it just you have to uncomment it in php.ini. Otherwise search for the library and download and put it in the extension directory and it will work when you re-start your web server.
    Mistakes are proof that you are trying.....
    ------------------------------------------------------------------------
    PSD to HTML - SlicingArt.com | Personal Blog | ZCE - PHP 5

  10. #10
    SitePoint Addict KJedi's Avatar
    Join Date
    Sep 2005
    Location
    Ukraine, Nikolaev
    Posts
    231
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Best class to use is TCPDF. Why? It supports Unicode (PDFLib also, but i is not free, I mean completely free and requires to be installed on atarged hosting) and it's better to use thing you can extend in the future. If you don't need Unicode now, are you sure you will not need it forever. And once you need it, you'll come to conclusion that you need TCPDF or install PDFLib on some hosting. And not all hostings support PDFLib and not all hosting allow you to install your programs.

    My advice - use TCPDF.

  11. #11
    if ($zee == "Guru") { $zee--;}
    Join Date
    Nov 2005
    Location
    Karachi - Pakistan
    Posts
    1,133
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    the best is http://www.ros.co.nz/pdf/ i have been using it on simple pdf to complex legal forms. try this its free. AND I CAN BET THAT YOU CAN'T GET ANY THING BETTER !! BECAUSE FOR SOME WORKS, I TRIED MANY php PDFS TOOLS AND CLASSES, EVEN I BOUGHT SOME.

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

    PHP to PDF

    zeeshanhashmi,

    How do I install/use http://www.ros.co.nz/pdf/
    What do I need to do to setup?

  13. #13
    SitePoint Evangelist
    Join Date
    Jan 2006
    Location
    UK
    Posts
    537
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    If YOU ACTUALLY READ the page:

    "The file readme.pdf contains all of the documentation, it serves triple purpose as the demo file and the testscript. The class download contains everything that you will need to produce this file."

    **** READ THE PDF FILE ****

  14. #14
    if ($zee == "Guru") { $zee--;}
    Join Date
    Nov 2005
    Location
    Karachi - Pakistan
    Posts
    1,133
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    yes, and u do not need to INSTALL anything. Just put the class file (2 PHP files) in the same folder where your PDF script will reside. then simply use
    include 'php_pdf_class_name.php';

    and use that as per the documentation.

    Cheers !

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

    PHP to PDF

    Terrific!!!

    Can I just ask one question?

    If you were to use PHP's Built-in PDF Creator, would you need to include a file at the top of the code in order to get it working (Like http://www.ros.co.nz/pdf/) As I tried the built-in PDF creator previously, and couldn't get it to work. Do you have any knowledge why?

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

    PHP to PDF

    How do I display data from a database in a PDF? How do I adapt the following?

    Code:
    <?php
    $con = mysql_connect("localhost","peter","abc123");
    if (!$con)
    {
      die('Could not connect: ' . mysql_error());
    }
    
    mysql_select_db("my_db", $con);
    
    $result = mysql_query("SELECT * FROM person");
    
    while($row = mysql_fetch_array($result))
    {
      echo $row['FirstName'] . " " . $row['LastName'];
      echo "<br />";
    }
    
    mysql_close($con);
    ?>

  17. #17
    SitePoint Evangelist
    Join Date
    Jan 2006
    Location
    UK
    Posts
    537
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You don't.

    It's apparent you have absolute no capability to listen to advice given time and time again across multiple similar posts.

    You also appear to have no desire to actually learn, you just want somebody to do all the work for you.

    I'd suggest that you pay somebody to modify scripts for you, as it would appear that programming is not something suited to your mindset.

  18. #18
    SitePoint Enthusiast toytron's Avatar
    Join Date
    Nov 2006
    Posts
    71
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    been looking for a pdf solution for a while now. I wonder if some of you could help me.

    I used fpdf -> it doesn't work because I need to convert pages on the fly and they have gifs with transparency in them.

    I'm a big fan of FOP but my host doesn't do java and memory seems to be an issue for big files.

    I can't use pdflib since the ROI is not worth it.

    Anyone else been on this search before?

    all help is welcome.

  19. #19
    if ($zee == "Guru") { $zee--;}
    Join Date
    Nov 2005
    Location
    Karachi - Pakistan
    Posts
    1,133
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    http://www.ros.co.nz/pdf/

    is all you need !


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
  •