Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

PDF Problems

Status
Not open for further replies.

inbowns

Technical User
Mar 5, 2001
2
0
0
US
I have PHP5 installed, but when i try to open a script with a PDflib the one that come with the installation of PHP. I always get gibberish or this warning:


Do you want to download this file?

Name: noname_php?DBGSESSID=-1
Type: Adobe Acrobat for Active X, 1.00 KB
From: Localhost

When I click ok or save I got this error:

Internet Explorer was not able to open this site the requestis either unavailable or cannot be found.


I've checked the php_info file and it shows that PDFlib is working.
Also I'm including the script I'm trying to run and my system information

I'm running the following:
Windows XP SP2
Apache 2.0.50
PHP 5.02

<?php
$page_width = 576;
$page_height = 360;
$str = "Hello World!";
$creator = "helloworld.php";
$p = PDF_new ();
PDF_open_file ($p,"");
PDF_set_info ($p, "Creator", $creator);
PDF_set_info ($p, "Title", $str);
PDF_begin_page ($p, $page_width, $page_height);
$font = PDF_findfont ($p, "Helvetica-Bold", "host", 0);
$text_size = 18.0;
$strwidth = PDF_stringwidth ($p, $str, $font, $text_size);
$text_hpos = ($page_width / 2) - (floor ($strwidth / 2));
$text_vpos = ($page_height / 2) - (floor ($text_size / 2));
PDF_setfont ($p, $font, $text_size);
PDF_set_text_pos ($p, $text_hpos, $text_vpos);
PDF_show ($p, $str);
PDF_end_page ($p);
PDF_close ($p);
$buf = PDF_get_buffer ($p);
$len = strlen ($buf);
header ("Content-Type: application/pdf");
header ("Content-Length: $len");
header ("Content-Disposition: inline; filename=hello_world.pdf");
print $buf;
PDF_delete($p);
?>


Any help would be greatly appreciated

Thank you
 
PDF sometimes drive you crazy. You got the error message because your code is not correct, pdf file is not generated successfully. But sorry, at a brief glance, I can't find error.
Method 1: use
PDF_open_file ($p, "D:\\Apache\\htdoc\\test\\test.pdf");
<A href='test.pdf'>
This is will generate a real pdf file on your disk, you should use real path for your file.
Method 2 : make your code as simple as possible to find problem
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top