I'm using XeTeX, Version 3.1415926-2.4-0.9998

I'm creating .tex file using PHP and storing it on linux server. [ex: abc.tex] Then creating .sh file with command to execute *.tex file using XeLaTeX [ex: abc.sh]

sample content of abc.sh

/usr/local/texlive/2012/bin/x86_64-linux/xelatex abc.tex

If i execute abc.sh on linux command prompt, required PDF is getting generated. But, If i execute abc.sh from apache webserver via php, it's giving error as :

Error 32512 (driver return code) generating output;
file abc.pdf may not be valid.

Note: There is NO PDF File generated.

Can you please suggest any pointers to solve this?


Finally it got executed. DANGER part is that, still I don't know reason. I suspect it may be due to some path issue.

Instead of executing tex file using xelatex, i complied it with latex & then with dvips and finally converted PDF using ps2pdf

NOTE: it's getting executed via webserver using PHP

  • Can you show the exec(...) arguments for whole line of compilation? I have absolutely the same problem! – Ruben Kazumov Oct 28 '13 at 19:35
  • Hi Ruben, Basically I call shell script from exec('/bin/sh abc.sh'); and commands are written in this .sh file ; shell file will have latex , dvips & ps2pdf for compilation in sequence. – Pawan Mude Oct 29 '13 at 16:04
  • I did it by this two lines: tex.stackexchange.com/q/141221/27881 – Ruben Kazumov Oct 29 '13 at 16:24

Here is a working way to execute latex from PHP. The point is that functions as exec, shell_exec, passthru, etc. get no or a vary limited PATH variable. However, latex, pdflatex and others use the path variable to call other programs. We therefore need to set the path appropriately, for example as follows:

passthru('PATH=/usr/bin:$PATH pdflatex file.tex');

Also note that your webserver user (typically www-data or apache) should have the necessary packages installed; this may not be the case if you're using local tlmgr stores.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.