Jump to content

Creating PDF


elmas156

Recommended Posts

Hello everyone,

 

I found a tutorial on creating a pdf with php and I just tried to create a basic pdf to see if it worked and modify it from there.  Here is the link to the tutorial: http://www.astahost.com/info/tfclt-create-pdf-php-create-fly-pdf-web-server.html

 

Well, after uploading the following php file to the server and testing it, I got this error:

 

Fatal error: Call to undefined function pdf_new() in /home/caresa6/public_html/BubblyBounce.com/admin/pdftest.php on line 2

 

Here's the code that produced the error:

<?php
$mypdf = PDF_new();
PDF_open_file($mypdf, "");
PDF_begin_page($mypdf, 595, 842);
$myfont = PDF_findfont($mypdf, "Times-Roman", "host", 0);
PDF_setfont($mypdf, $myfont, 10);
PDF_show_xy($mypdf, "Sample PDF, constructed by PHP in real-time.", 50, 750);
PDF_show_xy($mypdf, "Made with the PDF libraries for PHP.", 50, 730);
PDF_end_page($mypdf);
PDF_close($mypdf);

$mybuf = PDF_get_buffer($mypdf);
$mylen = strlen($mybuf);
header("Content-type: application/pdf");
header("Content-Length: $mylen");
header("Content-Disposition: inline; filename=gen01.pdf");
print $mybuf;

PDF_delete($mypdf);
?>

 

Can anyone help me figure out what to do from here?  I have some PHP knowledge, but I'm treading in uncharted waters with this, so I am totally lost.  Thanks in advance.

Link to comment
Share on other sites

Did you follow the first half of the tutorial? It seems as though you are likely missing the required library.

 

The phpinfo() function generates a html page with all the information
about the PHP installation, including the information about the Apache
web server, the version and settings of the PHP compiler, and the
supplemental PHP libraries that are installed and activated.

We have to check the pdf libraries.
The results should look something like this:

PDF Support: enabled
PDFlib Gmbh Version: 5.0.3
Revision: $Revision: 1.112.2.11 $

Link to comment
Share on other sites

I contacted my hosting provider tech support and they told me that pdf support was actually listed under "SPL," and that it was enabled.  Not sure what SPL is, but that's what I was told.  Anyone know anything about this.  Just FYI, my hosting provider is Web Hosting Hub.

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.