SitePoint Sponsor

User Tag List

Results 1 to 10 of 10

Thread: tcpdf vs fpdf ?

  1. #1
    SitePoint Wizard PHPycho's Avatar
    Join Date
    Dec 2005
    Posts
    1,200
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    tcpdf vs fpdf ?

    Which would you prefer for pdf generation using php?

  2. #2
    We're from teh basements.
    Join Date
    Apr 2007
    Posts
    1,205
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I looked at both and went with FPDF because the API is very straightforward.

  3. #3
    Programming Since 1978 silver trophybronze trophy felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, NSW, Australia
    Posts
    16,600
    Mentioned
    24 Post(s)
    Tagged
    1 Thread(s)
    I chose FPDF
    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="^$">

  4. #4
    SitePoint Wizard PHPycho's Avatar
    Join Date
    Dec 2005
    Posts
    1,200
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    What i have found so far:
    1> fpdf lacks proper code documentation so it's difficult to track the function arguments.
    2> tcpdf is based on fpdf and has many more functionalities like writeHtml() writeHtmlCell() etc
    3> joomla too uses tcpdf why not fpdf ?

    Please give your suggestions on choosing among two and good tutorials links if any.

    thanks

  5. #5
    Programming Since 1978 silver trophybronze trophy felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, NSW, Australia
    Posts
    16,600
    Mentioned
    24 Post(s)
    Tagged
    1 Thread(s)
    Quote Originally Posted by PHPycho View Post
    1> fpdf lacks proper code documentation so it's difficult to track the function arguments.
    They have a whole web site of documentation and anyone using the library also ought to know PHP and their PHP code is easy to read and modify. There are also lots of extensions that people have written and share to extend the FPDF library of functions. Extending it is really easy to do. If TCPDF is based on FPDF then it is FPDF with a specific set of extensions there whether you need them or not.
    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="^$">

  6. #6
    SitePoint Wizard PHPycho's Avatar
    Join Date
    Dec 2005
    Posts
    1,200
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks felgall for sharing your idea
    One off topic question:
    How to get the width of a pdf so that we can customize the width of the columns?
    For example
    col1 width + col2 width + ... coln width = total pdf width

    Thanks again.

  7. #7
    Programming Since 1978 silver trophybronze trophy felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, NSW, Australia
    Posts
    16,600
    Mentioned
    24 Post(s)
    Tagged
    1 Thread(s)
    Quote Originally Posted by PHPycho View Post
    How to get the width of a pdf so that we can customize the width of the columns?
    For example
    col1 width + col2 width + ... coln width = total pdf width

    Thanks again.
    With FPDF the page size is defined when you create the PDF prior to starting to fill it with content. If you don't specify the size then the default page size of A4 is used.

    You would want to allow left and right margins so that everything is inside the area that prionters can actually print so you'd deduct those off the total width and then divide the remainder by the number of columns you want.

    If you didn't override the default then the base measurements are millimetres. An A4 sheet is 210mm wide so if you allow 10mm left and right margins (which is the default) then you have 190mm to split between your columns.
    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="^$">

  8. #8
    Programming Since 1978 silver trophybronze trophy felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, NSW, Australia
    Posts
    16,600
    Mentioned
    24 Post(s)
    Tagged
    1 Thread(s)
    Quote Originally Posted by PHPycho View Post
    How to get the width of a pdf so that we can customize the width of the columns?
    For example
    col1 width + col2 width + ... coln width = total pdf width

    Thanks again.
    With FPDF the page size is defined when you create the PDF prior to starting to fill it with content. If you don't specify the size then the default page size of A4 is used.

    You would want to allow left and right margins so that everything is inside the area that prionters can actually print so you'd deduct those off the total width and then divide the remainder by the number of columns you want.

    If you didn't override the default then the base measurements are millimetres. An A4 sheet is 210mm wide so if you allow 10mm left and right margins (which is the default) then you have 190mm to split between your columns.

    Note that I don't have all those default sizes memorised, I just looked them up quickly in the FPDF documentation while I was writing this reply.
    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="^$">

  9. #9
    SitePoint Wizard PHPycho's Avatar
    Join Date
    Dec 2005
    Posts
    1,200
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks felgall for your valueable idea.

  10. #10
    SitePoint Wizard frank1's Avatar
    Join Date
    Oct 2005
    Posts
    1,392
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    i think tcpdf has support for unicode as well where as fpdf doesnt use to have(may be now it does have)


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
  •