SitePoint Sponsor

User Tag List

Results 1 to 9 of 9
  1. #1
    SitePoint Zealot asrasrasr's Avatar
    Join Date
    Apr 2009
    Posts
    107
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Call to undefined function pdf_begin_document()

    I m trying to generate pdf file using php version 5.2

    Code:
    Code PHP:
    <?php
     
      $pdf = pdf_new();
     
      pdf_begin_document($pdf);
     
      pdf_set_info($pdf, "Author", "Paul Adams");
     
      pdf_begin_page($pdf, (72 * 8.5), (72 * 11));
     
      $font = pdf_findfont($pdf, "Times-Roman", "host", 0);
     
      pdf_setfont($pdf, $font, 16);
     
      pdf_set_text_pos($pdf, 72, 720);
     
      pdf_show($pdf, "My First PDF Document");
     
      pdf_end_page($pdf);
     
      pdf_end_document($pdf);
     
      $document = pdf_get_buffer($pdf);
     
      $length = strlen($document);
     
      $filename = "myfirstpdf.pdf";
     
      header("Content-Type:application/pdf");
     
      header("Content-Length:" . $length);
     
      header("Content-Disposition:inline; filename=" . $filename);
     
      echo($document);
     
      unset($document);
     
      pdf_delete($pdf);
     
      ?>

    But this return error

    Fatal error: Call to undefined function pdf_begin_document() in D:\xampp\htdocs\studio\admin\download.php on line 5


    In my phpinfo() file:

    Code HTML4Strict:
    PDF Support 	          enabled
    PDFlib GmbH Version 	  5.0.3
    PECL Version 	          2.1.4
    Revision 	                  $Revision: 1.155 $


    Please Help me What is problem in my code.
    Please help me. I alraedy post same [rm but get no reply or answer.

    Waitng for ur reply. thnx.

  2. #2
    SitePoint Member
    Join Date
    Sep 2005
    Posts
    13
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Try upper case PDF like

    PHP Code:

    PDF_begin_document
    ($pdf); 

  3. #3
    SitePoint Zealot asrasrasr's Avatar
    Join Date
    Apr 2009
    Posts
    107
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    i have change upper case PDF but prm still working.

    Plaedse give me any other solution.

  4. #4
    SitePoint Addict
    Join Date
    Dec 2007
    Posts
    348
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    is the appropriate pdf extension installed and/or included?

  5. #5
    SitePoint Zealot asrasrasr's Avatar
    Join Date
    Apr 2009
    Posts
    107
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yes all installaltion completed

  6. #6
    SitePoint Wizard
    Join Date
    Nov 2005
    Posts
    1,191
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    http://nz2.php.net/manual/en/functio...n-document.php

    Never used that lib, but it looks like PDF_begin_document() requires 3 arguments. You're only passing one:
    pdf_begin_document($pdf);

  7. #7
    SitePoint Addict
    Join Date
    Dec 2007
    Posts
    348
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by asrasrasr View Post
    Yes all installaltion completed
    is the appropriate extension enabled as well as installed?

    Quote Originally Posted by hash View Post
    http://nz2.php.net/manual/en/functio...n-document.php

    Never used that lib, but it looks like PDF_begin_document() requires 3 arguments. You're only passing one:
    that wouldn't produce a 'function not found' error though, would it?

  8. #8
    SitePoint Enthusiast
    Join Date
    Mar 2009
    Posts
    39
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I think your code will only work with PHP 4. In PHP 5 use PDFlib object:

    PHP Code:
    $pdf = new PDFlib();
    $pdf->begin_document(""""); 

  9. #9
    SitePoint Zealot asrasrasr's Avatar
    Join Date
    Apr 2009
    Posts
    107
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I used PDFlib but this return error

    Fatal error: Call to undefined function pdflib() in D:\xampp\htdocs\studio\admin\download.php on line 2

    Code PHP:
    <?php
      $pdf = PDFlib();
     
      $pdf->begin_document("", ""); 
     
      PDF_set_info($pdf, "Author", "Paul Adams");
     
      PDF_begin_page($pdf, (72 * 8.5), (72 * 11));
     
      $font = PDF_findfont($pdf, "Times-Roman", "host", 0);
     
      PDF_setfont($pdf, $font, 16);
     
      PDF_set_text_pos($pdf, 72, 720);
     
      PDF_show($pdf, "My First PDF Document");
     
      PDF_end_page($pdf);
     
      PDF_end_document($pdf);
     
      $document = PDF_get_buffer($pdf);
     
      $length = strlen($document);
     
      $filename = "myfirstpdf.pdf";
     
      header("Content-Type:application/pdf");
     
      header("Content-Length:" . $length);
     
      header("Content-Disposition:inline; filename=" . $filename);
     
      echo($document);
     
      unset($document);
     
      pdf_delete($pdf);
     
      ?>


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
  •