从PHP编译乳胶文档 [英] Compiling a latex document from PHP

查看:47
本文介绍了从PHP编译乳胶文档的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用shell_exec命令来编译一个非常简单的乳胶文件,以便在网页中生成各种报告.

I want to use the shell_exec command to compile a very simple latex file in order to generate a report of sorts in the webpage.

我移至创建tex文件的文件夹.如果我发出命令(从控制台通过键入)

I move to the folder where I created the tex file. If I issue the command (from console, by typing)

pdflatex report.tex

一切正常.

我尝试过的第一件事是在php中发出命令:

The first thing I have tried is issuing the command in php:

$cmd_out = shell_exec("pdflatex " . $wcopy);   

其中$ wcopy包含要编译的文件的完整路径(在示例中为report.tex).乳胶文件包含图像,起初编译失败,因为我是从php脚本所在的目录中发出pdflatex命令,而picture和report.tex文件都位于不同的目录中.我通过修改乳胶文件来解决该问题,以便图像路径相对于php脚本所在的目录.

where $wcopy contains the full path of the file to be compiled (report.tex in the example). The latex file contained an image and at first the compilation failed because I was issuing the pdflatex command from the directory where the php script resides and both the picture and the report.tex files are in a different directory. I fixed that problem by modifying the latex file so that the image path is relative the directory where the php script is located.

下次我尝试运行该脚本时,我从pdflatex收到了一条非常含糊的消息:

The next time I tried to run the script I get this very misterious message from pdflatex:

pdfTeX error: pdflatex (file ecrm1095): Font ecrm1095 at 600 not found

我不确定这与php函数shell_exec有关,尽管我不确定.

I believe this has something to do the php function shell_exec, although I'm not sure.

有人可以告诉我我可能做错了什么吗?我添加了图像的全部内容,因为我认为这可能是一个线索.

Can any one tell me what I might be doing wrong? I added the whole bit of the image, because I think it might be a clue.

添加请求的信息.该服务器正在Debian Linux发行版中运行,执行这些命令的用户是www-data

Adding requested information. The server is running in a Debian Linux Distribution and the user that will execute those commands is www-data

推荐答案

这大概是作为网页的一部分运行的吗?

This is running as part of a web page, presumably?

问题可能是您的脚本以其他用户身份运行.我希望它作为 apache 运行;和 apache 可能没有正确配置路径,或者没有正确的Latex设置来查找字体目录等.

The problem is probably that your script is running as a different user. I expect it is running as apache; and apache might well not have the right path configured, or the right Latex setup for finding font directories and the like.

关于正在运行的系统,您没有太多详细信息,但是您可以尝试以 apache 的形式运行它,以查看是否可以重现该错误.如果是Linux,请成为root用户,然后进入正确的目录并运行

You haven't given much detail as to what system you're running on, but you could try running it as apache to see if you can reproduce the error. If this is Linux, then become root, then go into the right directory, and run

su - apache pdflatex report.tex

看看会发生什么.要成为root用户,如果您知道root密码,则可以单独使用 su ;否则,您可以单独使用.或者,如果您使用的是Ubuntu,请尝试

to see what happens. To become root, you might be able to use su on its own, if you know the root password; or if you're on Ubuntu, try

sudo bash

成为root用户(并为其输入密码),然后我之前建议以 apache 身份运行的那一行.

to become root (and give it your own password), and then the line I previously suggested to run as apache.

这篇关于从PHP编译乳胶文档的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆