English 中文(简体)
Generating Postscript using PHP: browser offers to save file
原标题:
$ps = ps_new();
ps_open_file($ps,$filename);
ps_begin_page($ps,$size,$size);
ps_set_parameter($ps,  SearchPath  ,  /usr/share/texmf-texlive/fonts/afm/bluesky/cm );
$psfont = ps_findfont($ps, "cmr10", "", 0);  

ps_setfont($ps, $psfont, 12.0);

ps_circle($ps,$size/2,$size/2,$size/10);
ps_circle($ps,$size/4,$size/2,1);
ps_circle($ps,$size/2,$size/4,1);
ps_circle($ps,$size/4,$size/4,1);    
ps_fill($ps);


//ps_show_xy($ps,  test ,$size/8,$size/8);
//ps_stroke($ps);

ps_end_page($ps);
ps_close($ps);
ps_delete($ps);

If I comment out the ps_setfont line, it correctly saves a .ps file containing some filled circles.

With the ps_setfont line not commented out, firefox offers to save something with my .php filename, but what gets saved is 0 bytes long.

I don t understand why this "download" is being offered :-S

最佳回答

Probably it s a matter of some error output happening in ps_setfont() calling line. Try to set:

error_reporting(E_ALL);

and check error messages in logs or before you send it as an output to the browser. Once you eliminate the error output, the script should be working fine.

问题回答

暂无回答




相关问题
Brute-force/DoS prevention in PHP [closed]

I am trying to write a script to prevent brute-force login attempts in a website I m building. The logic goes something like this: User sends login information. Check if username and password is ...

please can anyone check this while loop and if condition

<?php $con=mysql_connect("localhost","mts","mts"); if(!con) { die( unable to connect . mysql_error()); } mysql_select_db("mts",$con); /* date_default_timezone_set ("Asia/Calcutta"); $date = ...

定值美元

如何确认来自正确来源的数字。

Generating a drop down list of timezones with PHP

Most sites need some way to show the dates on the site in the users preferred timezone. Below are two lists that I found and then one method using the built in PHP DateTime class in PHP 5. I need ...

Text as watermarking in PHP

I want to create text as a watermark for an image. the water mark should have the following properties front: Impact color: white opacity: 31% Font style: regular, bold Bevel and Emboss size: 30 ...

How does php cast boolean variables?

How does php cast boolean variables? I was trying to save a boolean value to an array: $result["Users"]["is_login"] = true; but when I use debug the is_login value is blank. and when I do ...

热门标签