9

The call of command:

$dir = "/path/to/source/file";
exec("cd $dir;xelatex filesource.tex", $output_array[0]);

always fails, but:

$dir = "/path/to/source/file";
exec("cd $dir;/usr/texbin/xelatex -no-pdf filesource.tex", $output_array[0]);// now we have .xdv file
exec("cd $dir;/usr/texbin/xdvipdfmx filesource.xdv", $output_array[1]); 

succeed, and result .pdf file absolutely valid. What is the trick?

  • 1
    Getting any errors? – You Oct 29 '13 at 7:45
  • 3
    XeTeX spawns an xdvipdfmx process and pipes shipped out pages to it, unless --no-pdf is specified. It's possible that this fools exec. – egreg Oct 29 '13 at 8:56
  • 1
    I suspect xelatex without -no-pdf makes some kind .xdv but lost the path before final compilation. If it is, I want to find the way to fix this failure and understand the whole picture. – Ruben Kazumov Oct 29 '13 at 15:31
  • 2
    The question itself seems to be quite interesting, you could make an edit to the question, maybe add a little detail. That way it goes up to the top on main site, or in other words, it gets bumped ;-) – Johannes_B Mar 6 '15 at 20:01
  • 1
    What works for me is using chdir from PHP to change into the .tex directory. Then executing the commands and then changing directory back. Does that help? – TeXnician May 28 '17 at 10:50
1

In general there are two main cases:

  • your LaTeX binaries are known to the system (whichever you might use): This case is pretty simple because you can simply use your first approach without a full path to the binaries.
  • your LaTeX binaries are unknown to the system: If you install LaTeX not over repositories (if you're on Linux), but with the TeX Live installer f.i. you'll find them in a location that's unknown to the system. You have to add them to the PATH so that it can be found. The alternative is to use full paths when calling.

You seem to have a system of the second type. So you should either tell PHP to add the LaTeX binary path to PATH or should use full paths when calling.

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.