SitePoint Sponsor

User Tag List

Results 1 to 18 of 18

Thread: PDF export

  1. #1
    SitePoint Addict I don`t mind's Avatar
    Join Date
    Feb 2006
    Location
    LA
    Posts
    218
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Angry PDF export

    Hi guys,

    i need to export data from a database to a pdf-file.
    my sql statement is...

    Code:
    $sql = 'SELECT id,name,author,isbn,unit,location,summary FROM bibliography_t_books';
    			$db = new db_operations($_SESSION['db']);
    			$db->read_db($sql);

    if anyone has an idea how to do or know links with solutions or something else it would be very nice
    Last edited by I don`t mind; Mar 6, 2006 at 06:26.
    Words are weapons of Mass Destruction.

  2. #2
    SitePoint Addict I don`t mind's Avatar
    Join Date
    Feb 2006
    Location
    LA
    Posts
    218
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Angry

    I tried to use fpdf but it doesn`t work with the sql above
    Last edited by I don`t mind; Mar 6, 2006 at 06:26.
    Words are weapons of Mass Destruction.

  3. #3
    SitePoint Addict lmasi02's Avatar
    Join Date
    Aug 2004
    Location
    Zambia
    Posts
    257
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Power of Knowledge

  4. #4
    SitePoint Addict I don`t mind's Avatar
    Join Date
    Feb 2006
    Location
    LA
    Posts
    218
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    thanks for your reply the link is very helpful but I tried to do it create a pdf-file and get the following error message:

    Fatal error: Call to undefined function: pdf_new()
    Words are weapons of Mass Destruction.

  5. #5
    SitePoint Addict lmasi02's Avatar
    Join Date
    Aug 2004
    Location
    Zambia
    Posts
    257
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by I don`t mind
    thanks for your reply the link is very helpful but I tried to do it create a pdf-file and get the following error message:

    Fatal error: Call to undefined function: pdf_new()
    uncomment the line 'extension=php_pdf.dll' in the php.ini file
    Power of Knowledge

  6. #6
    SitePoint Addict I don`t mind's Avatar
    Join Date
    Feb 2006
    Location
    LA
    Posts
    218
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    So easy and I didn't get it

    works fine thank you VERY much
    Words are weapons of Mass Destruction.

  7. #7
    SitePoint Addict I don`t mind's Avatar
    Join Date
    Feb 2006
    Location
    LA
    Posts
    218
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Angry

    hmmm another problem...i create a pdf and the follwoing error message is shown
    There was an error opening this document. The file is damaged and could not be repaired.
    My code:

    PHP Code:
    $pdf PDF_new(); 
    PDF_open_file($pdf); 
    PDF_set_info($pdf"author""User");  
    PDF_set_info($pdf"title""list");  
    PDF_set_info($pdf"creator""User");  
    PDF_set_info($pdf"subject""List"); 
    PDF_begin_page($pdf450450); 
    $font PDF_findfont($pdf"Helvetica-Bold",  "winansi",0);     
    PDF_setfont($pdf$font12);
    PDF_show_xy($pdf"Test"5225); 
    PDF_end_page($pdf); 
    PDF_close($pdf); 

    $buffer PDF_get_buffer($pdf); 
    header("Content-type: application/pdf"); 
    header("Content-Length: ".strlen($buffer)); 
    header("Content-Disposition: inline; filename=list.pdf"); 
    echo 
    $buffer;

    PDF_delete($pdf); 
    I try to figure out what is happening but i have no idea
    Words are weapons of Mass Destruction.

  8. #8
    SitePoint Addict I don`t mind's Avatar
    Join Date
    Feb 2006
    Location
    LA
    Posts
    218
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Found the problem...when I tried to run the pdf code as part of the framework i have to work with - it won't work, actually I don't know why. Running the pdf code in an extra file it works...
    Words are weapons of Mass Destruction.

  9. #9
    SitePoint Wizard
    Join Date
    Jan 2004
    Location
    3rd rock from the sun
    Posts
    1,005
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Pdf creation is part of the new http://framework.zend.com (ZF)
    isempty()

  10. #10
    SitePoint Wizard
    Join Date
    Jan 2004
    Location
    3rd rock from the sun
    Posts
    1,005
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    ps PDFs viewed with IE can also throw up some nasty errors, depending on whether you are set to :
    -view them embedded in browser
    -fire up pdf (and versions matter a LOT)
    -right-click open in new window
    -right-click, Save as, then open them etc

    Some of that behaviour is client side and headers can make a difference in some cases. Just some massive timewasters I have in that particular black hole in my brain.

    Gd Lk
    isempty()

  11. #11
    SitePoint Addict I don`t mind's Avatar
    Join Date
    Feb 2006
    Location
    LA
    Posts
    218
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Well the right click and open in new window won't work because the page which is generating the pdf is opening with javascript. The save target as solution doesn't work...an error says that it cannot download from "........index.php?display_page=pdf"
    Words are weapons of Mass Destruction.

  12. #12
    SitePoint Wizard
    Join Date
    Jan 2004
    Location
    3rd rock from the sun
    Posts
    1,005
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Well lets face it, any of those options failing is bad news because thats what users try and do with them.

    I flag them as a list of reality checks to make when testing a pdf creation package, like I say headers have a lot more to do with this than I first imagined. I dont envy you because I just think pdfs stink - but then I have always have - so am slightly biased. Anything coming out of Adobe/Macomedium is a POS IMO.

    Still, its like boybands, we know they unfathomable, reprehensible and unsustainable but we have to live with them, right?
    isempty()

  13. #13
    SitePoint Addict I don`t mind's Avatar
    Join Date
    Feb 2006
    Location
    LA
    Posts
    218
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Ok i start to hate that stu***pdf stuff now I have to create an extra file because the framework is sending headers too and so the pdf won't work like it is at the moment...maybe someone should create a simple interface that creates the pdf export code using the user inputs
    Words are weapons of Mass Destruction.

  14. #14
    SitePoint Addict I don`t mind's Avatar
    Join Date
    Feb 2006
    Location
    LA
    Posts
    218
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    And again a "simple" question...finally i managed to create a pdf file but the file is empty maybe I have done something wrong in the query, actually I have no idea...So below is my code maybe someone can help

    PHP Code:
        function read_db() {
            
    include_lists();
            
            
    $sql 'SELECT id,name,author,isbn,unit,location,summary FROM bibliography_t_books';
            
    $list = new lists('Name''name');
            
    $db_list $list->get_list($sql);
            if (
    is_array($db_list)) {
                while (list(
    $row) = each($db_list)) {
                
    $disp_list[$row][0] = $db_list[$row][1];
                        
    $disp_list[$row][1] = $db_list[$row][2];
                        
    $disp_list[$row][2] = $db_list[$row][3];
                        
    $disp_list[$row][3] = $db_list[$row][4];
                        
    $disp_list[$row][4] = $db_list[$row][5];
                        
    $disp_list[$row][5] = $db_list[$row][6];                        
                }
            }
        }        
        
        
        
    $pdf PDF_new(); 
        
    PDF_open_file($pdf); 
        
    PDF_set_info($pdf"author""User");  
        
    PDF_set_info($pdf"title""Bibliography Index");  
        
    PDF_set_info($pdf"creator""User");  
        
    PDF_set_info($pdf"subject""Bibliography Index"); 
        
    PDF_begin_page($pdf450450); 
        
    $font PDF_findfont($pdf"Helvetica-Bold",  "winansi",0);     
        
    PDF_setfont($pdf$font12);
        
    PDF_show_xy($pdfread_db(), 10430); 
        
    PDF_end_page($pdf); 
        
    PDF_close($pdf); 

        
    $buffer PDF_get_buffer($pdf); 
        
    header("Content-type: application/pdf"); 
        
    header("Content-Length: ".strlen($buffer)); 
        
    header("Content-Disposition: inline; filename=index_bibliograpy.pdf"); 
        echo 
    $buffer;
        
        
    PDF_delete($pdf); 
    Words are weapons of Mass Destruction.

  15. #15
    SitePoint Addict I don`t mind's Avatar
    Join Date
    Feb 2006
    Location
    LA
    Posts
    218
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Ok forget about that...last but not least the stuff is printed out in the pdf file BUT unfortunately it prints out the html code of the table (<tr><td>,etc.) and it prints everything out in the first line

    So what i need is something that converts the HTML table code to a real table and a line break after e.g. 490 pixel
    Last edited by I don`t mind; Mar 9, 2006 at 06:06.
    Words are weapons of Mass Destruction.

  16. #16
    SitePoint Addict I don`t mind's Avatar
    Join Date
    Feb 2006
    Location
    LA
    Posts
    218
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    For those who need a good HTML to PDF converter look at http://www.tufat.com/html2ps.php
    Words are weapons of Mass Destruction.

  17. #17
    SitePoint Member hacki's Avatar
    Join Date
    Feb 2006
    Posts
    6
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    you should to try html2pdf. it uses fpdf. But i dont remember where you can download it.

  18. #18
    SitePoint Wizard
    Join Date
    Jan 2004
    Location
    3rd rock from the sun
    Posts
    1,005
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    It has an extra f as in "Free PDF" - Rockon Olivier Plathey.

    html2fpdf.sourceforge.net <-I love fpdf, but havent tried this extension of it yet, but you have to have pdf reader installed to read the docs... hmmmm...

    (nb if you want to work out why you get blank pages etc and other "minor issues" then the fpdf.org website and Oliviers docs have really good explanations as to why its so)
    isempty()


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
  •