|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
problem with creating PDF with php
Hello everyone,
been growing grey hairs(more than my usual few) over the last couple of days trying to output a PDF page from my php code.The code is a simple one from an online example and getting it to run as been one big headache.It's as follows: <?php $user = $HTTP_POST_VARS["userName"]; $pdf = pdf_new(); pdf_open_file($pdf, "obiboy.pdf"); pdf_set_info($pdf, "Author", "J.F.Kennedy"); pdf_set_info($pdf, "Title", "Creating a pdf"); pdf_set_info($pdf, "Creator", "J.F.Kennedy"); pdf_set_info($pdf, "Subject", "Creating a pdf"); pdf_begin_page($pdf, 595, 842); $arial = pdf_findfont($pdf, "Arial", "host", 1); pdf_setfont($pdf, $arial, 14); pdf_show_xy($pdf, "<Type your info here>",50, 400); $gif_image = pdf_open_gif($pdf, "baseball.gif"); pdf_place_image($pdf, $gif_image, 200, 300, 1.0); pdf_close_image($pdf, $gif_image); pdf_end_page($pdf); pdf_close($pdf); //echo "<A HREF=\"C:\obiboy.pdf\" TARGET=\"_blank\">Open pdf in a new window $user</A>" ?> Its meant to carry details from a sign in page as reflected by the declared globals on top.Even though I have enabled usage of PDF extension in my php.ini, the code dosent run. The error it returns is as follows: Fatal error: PDFlib error: function 'PDF_set_info' must not be called in 'object' scope in c:\inetpub\wwwroot\pdf_house\pdf_file.php on line 6 so can someone please look it over and tell me where I am screwing it up? Thanks all. |
|
#2
|
||||
|
||||
|
This is a permissions error. Add a die statement at the end of your pdf_open_file() line and you'll see that you're unable to open the file. Which means that the rest of the code can't execute because it's out of scope. If you give your Web server write permissions on the directory you're working out of, this error should clear up.
__________________
Please don't PM me asking for solutions outside the scope of a thread. Keeping all responses in a thread stands to help others who come along later, which is after all what this forum's all about. |
|
#3
|
|||
|
|||
|
Thanks dhouston.Tried your suggested test and it worked great.The file could just not be opened.Please could you give me a tip on getting my webserver permission to write into the directory thatI am working out from?I changed folder permissions to the equivalent of chmod 777 and it still did not clear up the permission problems.
Thanks very muchI am using an IIS webserver on a Win2k PC. |
|
#4
|
||||
|
||||
|
Hmm, 777 should do the trick. I'm not familiar enough with IIS to make any additional suggestions. In my case, I added, I gave the "nobody" group write access on the directory and it worked like a charm. If your directory's got 777 perms but the file already exists and has more restrictive perms, that could be your problem.
|
![]() |
| Viewing: Dev Articles Community Forums > Programming > PHP Development > problem with creating PDF with php |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|