SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Guru
    Join Date
    Feb 2007
    Posts
    873
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Pdf generating based on mysql data

    Dear All,
    I would like to generate pdf document via my php page which are based on mysql data? Any recommendation so far I have seen fpdf and tcpdf. Which one will be better or is there any better tool for it? Thank you.

  2. #2
    SitePoint Wizard bronze trophy Immerse's Avatar
    Join Date
    Mar 2006
    Location
    Netherlands
    Posts
    1,661
    Mentioned
    7 Post(s)
    Tagged
    1 Thread(s)
    Nope, those two are probably the best tools.
    I've not worked with tcpdf, but I've used fpdf extensively. It's quite verbose, but is generates decent PDFs.

    What kind of data will you be displaying?

  3. #3
    SitePoint Guru
    Join Date
    Feb 2007
    Posts
    873
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Dear Immerse,
    Mine lots of gps data. What I want is for instance a user select a vehicle, start date and end date. Then first I will show the report on the page itself. Upon that will have a save button where user click and I want it to be in the format of pdf. What is the best mechanism to go about since you have lots of experience in it?

  4. #4
    SitePoint Wizard bronze trophy Immerse's Avatar
    Join Date
    Mar 2006
    Location
    Netherlands
    Posts
    1,661
    Mentioned
    7 Post(s)
    Tagged
    1 Thread(s)
    Do you already have a design/ setup in mind for what the PDF should look like?
    Depending on how complicated it is, it'll be quite easy to make, or very difficult.

    Here's a quick example of making a PDF (copied from the [url=http://www.fpdf.org/]FPDF site[/php], I added some comments to show what's going on):

    PHP Code:
    <?php
    require('fpdf.php');
     
    // create a new PDF
    $pdf = new FPDF();

    // add an empty page
    $pdf->AddPage(); 

    // set the font to arial, 16pts and make it bold
    $pdf->SetFont('Arial','B',16); 

    // create a cell 40 points wide, 10 high, and write Hello World into it
    $pdf->Cell(40,10,'Hello World!'); 

    // output the pdf to the browser
    $pdf->Output(); 
    ?>
    The manual on that site is pretty decent, it explains most of the possibilities quite well.

    Just a quick warning, it might take a while to get used to creating PDFs like this.
    Try it out, see how far you get and let us know if you get stuck

  5. #5
    SitePoint Guru
    Join Date
    Feb 2007
    Posts
    873
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Dear Immerse,
    I have an idea where I will have a header and footer and in between will be the data which is based on mysql db ? So any good sample on mysql because I only saw one sample their pages.


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
  •