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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

PHP/PDF

Status
Not open for further replies.

jianbo

Programmer
Dec 19, 2001
78
US
I tried to create a pdf file by using php. I install all the necessary package, my Apache and PHP work well before. While I always met the same problem: browser let me downloade my php files then show an internal error message.

I tried in another machine, my code works. And I found if I use window.open("....") to create php/pdf page in a new window, browser will show the same error message in my machine.

Who met this situation and have idea? Please give me some help, thanks!
 
In internet explorer (if that's what your using) click tools -> internet options -> advanced tab -> under browsing uncheck show friendly HTTP error messages.

You should then see exactly whats wrong
--BB
 
I tried your suggestion, but got the same result. I don't this this is the problem of browser's setting. Maybe it is some bug of PHP/PDF. Thanks for your help.
 
Can you give more details about what you did,what you're using, and what the error (if any) is? --
How can you be in two places at once when you're not anywhere at all?
 
I copy a sample code like:(I call it test.php)
<?php
//Create & Open PDF-Object
$pdf = pdf_new();
pdf_open_file($pdf);
pdf_set_info($pdf, &quot;Author&quot;,&quot;Bob Nijman&quot;);
pdf_begin_page($pdf, 300, 300);

$font = pdf_findfont($pdf, &quot;Times New Roman&quot;, &quot;host&quot;, 1);
if ($font) {
pdf_setfont($pdf, $font, 30);
}

$string = &quot;Hello Berlin-Mitte!&quot;;

$width = pdf_stringwidth($pdf, $string);
pdf_set_text_pos($pdf, (300-$width)/2, 200);
pdf_show($pdf, $string);


//close it up
pdf_end_page($pdf);
pdf_close($pdf);
$data = pdf_get_buffer($pdf);
header('Content-type: application/pdf');
header('Content-disposition: inline; filename=myTest.pdf');
header('Content-length: ' . strlen($data));
echo $data;
?>

While I run this sample code in other guys's machine, it works OK and display pdf file in browser. In my machine, first browser let me open/save this test.php file, I choose open this file, I saw Adobe Acrobat run, but then show error message :&quot;IE can't open internet site..., the file is either unavailable or can't be found&quot;.
Also I found if I use window.open(&quot;test.php&quot;) to run this file in a new window, the above error message will definetely appear.
Thanks,
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top