PHP Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgrammingPHP Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old May 27th, 2004, 03:10 AM
obi obi is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jan 2003
Posts: 17 obi User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 h 9 m 5 sec
Reputation Power: 0
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.

Reply With Quote
  #2  
Old May 27th, 2004, 07:43 AM
dhouston's Avatar
dhouston dhouston is offline
Contributing User
Dev Articles Beginner (1000 - 1499 posts)
 
Join Date: May 2003
Location: Tennessee
Posts: 1,355 dhouston User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 7
Send a message via ICQ to dhouston
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.

Reply With Quote
  #3  
Old May 27th, 2004, 12:28 PM
obi obi is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jan 2003
Posts: 17 obi User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 h 9 m 5 sec
Reputation Power: 0
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.

Reply With Quote
  #4  
Old May 27th, 2004, 02:56 PM
dhouston's Avatar
dhouston dhouston is offline
Contributing User
Dev Articles Beginner (1000 - 1499 posts)
 
Join Date: May 2003
Location: Tennessee
Posts: 1,355 dhouston User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 7
Send a message via ICQ to dhouston
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.

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingPHP Development > problem with creating PDF with php


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway
Stay green...Green IT