Problems with new_php() function

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • dudelideisann
    New Member
    • Jan 2008
    • 12

    Problems with new_php() function

    I only get this message whenever I try to create a pdf:

    Call to undefined function: pdf_new()
    My webhost has the pdf set to 'enabled' in phpinfo() using php 4.4

    Any ideas what might be wrong? Could there be any other problems than my webhost?
  • TheServant
    Recognized Expert Top Contributor
    • Feb 2008
    • 1168

    #2
    [edit] I'm dyslexic (not really but I made a spelling mistake and wasted a bit of time).

    Have you looked at http://au2.php.net/manual/en/ref.pdf.php ? I don't have any experience with pdf's in php, but it seems that maybe how you were using the function was incorrect. Can you post some of your code so we can see what inputs you have in there?

    Comment

    • fingurez
      New Member
      • Apr 2008
      • 2

      #3
      Originally posted by dudelideisann
      I only get this message whenever I try to create a pdf:



      My webhost has the pdf set to 'enabled' in phpinfo() using php 4.4

      Any ideas what might be wrong? Could there be any other problems than my webhost?
      I am real interested in the solution because I have been pulling my air out trying to get my pdf script to work. Now I have used the same script sometime last year and it worked just fine infact the project still creates PDFs without a problem but when I try the same script in my new project I get a similar error <call to undefiined function>.

      This is the script that I have used previously to print out existing MySQL data to a PDF document.

      Now I am trying to edit the script so it can print complete field data to a PDF, can some1 please help me out because this problem has taken too much of my time already!



      <form method="post" action="this.ph p">
      <input type="submit" value="Generate PDF" name = "submited"/>
      <input type="hidden" name= "initials" value="<?php echo($initials) ;?>" />
      <input type="hidden" name= "firstName" value="<?php echo($firstName );?>" />
      <input type="hidden" name= "lastName" value="<?php echo($lastName) ;?>" />
      <input type="hidden" name= "dateOfBirt h" value="<?php echo($dateOfBir th);?>" />

      </form>

      <?php
      if ($_POST['submited']){
      //set up a standard pdf document
      define('PAGE_WI DTH', 612);
      define('PAGE_HE IGHT', 792);

      $pdf = pdf_new();
      //pdf_begin_docum ent($pdf, "", "");
      //set up a location for file to be written to directory
      pdf_open_file($ pdf, "C:/reports/Details.pdf");

      pdf_begin_page( $pdf, PAGE_WIDTH, PAGE_HEIGHT);

      //set up a font
      $font = pdf_findfont($p df, "Helvetica" , "auto", false);
      pdf_setfont($pd f, $font, 30);


      pdf_show_xy($pd f,"Document name",5,PAGE_HE IGHT-30);
      pdf_moveto($pdf ,20,750);
      pdf_lineto($pdf ,575,750);
      pdf_stroke($pdf );

      pdf_setfont($pd f, $font, 15);
      pdf_show_xy($pd f, "Report", 10, PAGE_HEIGHT-80);

      pdf_setfont($pd f, $font, 12);
      //data from database to be printed on the PDF document
      pdf_show_xy($pd f, "Initials : ".$_POST[initials], 10, PAGE_HEIGHT-105);
      pdf_show_xy($pd f, "First Name : ".$_POST[firstName], 10, PAGE_HEIGHT-125);
      pdf_show_xy($pd f, "Last Name : ".$_POST[lastName], 10, PAGE_HEIGHT-145);
      pdf_show_xy($pd f, "Date Of Birth : ".$_POST[dateOfBirth], 10, PAGE_HEIGHT-165);



      pdf_moveto($pdf ,20,50);
      pdf_lineto($pdf ,575,50);
      pdf_stroke($pdf );

      pdf_setcolor($p df, "fill", "rgb", 1.0, 0.0, 0.0, 0.0);

      pdf_show_xy($pd f,"Confidenti al and Private Information",20 0,35);

      pdf_end_page($p df);


      pdf_close($pdf) ;
      }
      ?>

      Comment

      • fingurez
        New Member
        • Apr 2008
        • 2

        #4
        chack out this tutorial think it will help you!

        http://www.devshed.com/c/a/PHP/Constructing-MultiLine-PDF-Documents-with-PHP-5/3/

        Comment

        • dudelideisann
          New Member
          • Jan 2008
          • 12

          #5
          Originally posted by TheServant
          [edit] I'm dyslexic (not really but I made a spelling mistake and wasted a bit of time).

          Have you looked at http://au2.php.net/manual/en/ref.pdf.php ? I don't have any experience with pdf's in php, but it seems that maybe how you were using the function was incorrect. Can you post some of your code so we can see what inputs you have in there?
          Off course! Here is what I've put in my createPdf function (not sure it's right though..):

          [PHP]
          function pdfCreator() {

          $pdf = pdf_new();

          $randName = md5(rand() * time());
          $title = $_POST['title'];
          $someText = $_POST['sometext'];
          $pdfName = $randName . ".pdf";

          pdf_open_file($ pdf, "../pdf/$pdfName");

          pdf_set_info($p df, "Author", "Me");
          pdf_set_info($p df, "Title", "Creating a pdf");
          pdf_set_info($p df, "Creator", "Me again");
          pdf_set_info($p df, "Subject", "Creating a pdf");

          pdf_begin_page( $pdf, 595, 842);

          $arial = pdf_findfont($p df, "Arial", "host", 1);
          pdf_setfont($pd f, $arial, 14);



          if(!empty($_POS T['image])) {

          if(!empty($_SES SION['image']['Filename'][0])) {
          $imageName = $_SESSION['image']['Filename'][0];
          $ext = substr(strrchr( $imageName, "."), 1);
          }
          switch ($ext) {
          case $ext=='jpg':
          $image = pdf_open_jpeg($ pdf, "../images/category/$imageName");
          break;
          case $ext=='jpeg':
          $image = pdf_open_jpeg($ pdf, "../images/category/$imageName");
          break;
          case $ext=='pjpg':
          $image = pdf_open_jpeg($ pdf, "../images/category/$imageName");
          break;
          case $ext=='pjpeg':
          $image = pdf_open_jpeg($ pdf, "../images/category/$imageName");
          break;
          case $ext=='gif':
          $image = pdf_open_gif($p df, "../images/category/$imageName");
          break;
          case $ext=='x-png':
          $image = pdf_open_png($p df, "../images/category/$imageName");
          break;
          case $ext=='png':
          $image = pdf_open_png($p df, "../images/category/$imageName");
          break;

          }

          }

          pdf_place_image ($pdf, $image, 200, 300, 1.0);

          pdf_close_image ($pdf, $image);

          pdf_show_xy($pd f, "$title<br /><br />$someText",5 0, 400);

          pdf_end_page($p df);
          pdf_close($pdf) ;



          }[/PHP]

          Comment

          Working...