无法从 php 执行 ttf2afm

发布于 2024-11-17 16:34:25 字数 707 浏览 4 评论 0原文

我正在开发一个涉及 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);

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

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

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

是否存在一些与权限相关的问题?或者我无法从网页执行此类命令?

提前致谢

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)

$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.

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...

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

Thanks in advance

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

孤独患者 2024-11-24 16:34:25

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

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

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

First, escapeshellarg is used wrong. Better is:

$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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文