无法从php执行ttf2afm

时间:2021-08-05 21:52:24

I am working on a project that involves PDF API TCPDF. So I needed an area in admin where site admin can upload and install new fonts to be used with TCPDF. I am working on a script that does following : 1) upload TTF font to TCPDF fonts/utils/ directory. 2) execute ttf2afm from PHP script and create .AFM (adobe font metrics)

我正在开发一个涉及PDF API TCPDF的项目。所以我需要一个管理员区域,站点管理员可以上传并安装要与TCPDF一起使用的新字体。我正在编写以下脚本:1)将TTF字体上传到TCPDF fonts / utils /目录。 2)从PHP脚本执行ttf2afm并创建.AFM(adobe字体度量标准)

$command = escapeshellarg("/usr/bin/ttf2afm $fontPath$fontName -o $fontPath$afmName");
$result = passthru($command);

or

$command = escapeshellarg("ttf2afm $fontPath$fontName -o $fontPath$afmName");
$result = passthru($command);

3) execute php -f makefont.php font.ttf font.afm and generate the required font.php and font.z files.

3)执行php -f makefont.php font.ttf font.afm并生成所需的font.php和font.z文件。

now my problem is, the above commands are not executing from web page. If I copy and execute part of this code from php interactive shell it works well. But, from webpage, it simply does not work...

现在我的问题是,上面的命令没有从网页执行。如果我从php交互式shell复制并执行此代码的一部分,它运行良好。但是,从网页上看,它根本不起作用......

Is there some permission related problem? or I can not execute such commands from a web page?

有一些许可相关的问题吗?或者我无法从网页执行此类命令?

Thanks in advance

提前致谢

1 个解决方案

#1


0  

First, escapeshellarg is used wrong. Better is:

首先,escapeshellarg使用错误。更好的是:

$command = escapeshellcmd("/usr/bin/ttf2afm")." ".escapeshellarg($fontPath.$fontName)." -o ".escapeshellarg($fontPath.$afmName);

Also make sure that error logging is enabled, so you can see if there is a permission error.

还要确保启用了错误日志记录,以便您可以查看是否存在权限错误。

#1


0  

First, escapeshellarg is used wrong. Better is:

首先,escapeshellarg使用错误。更好的是:

$command = escapeshellcmd("/usr/bin/ttf2afm")." ".escapeshellarg($fontPath.$fontName)." -o ".escapeshellarg($fontPath.$afmName);

Also make sure that error logging is enabled, so you can see if there is a permission error.

还要确保启用了错误日志记录,以便您可以查看是否存在权限错误。