Compile latex from php: "Error: Invalid XRef stream header"
I have been trying to compile latex from php. I got the help from this tutorial. However, I keep getting this error.
Error: Invalid XRef stream header Error: Invalid XRef stream header pdf.worker.js:232:5 XRef_readXRef@resource://pdf.js/build/pdf.worker.js:3708:13 XRef_parse@resource://pdf.js/build/pdf.worker.js:3296:23 PDFDocument_setup@resource://pdf.js/build/pdf.worker.js:2469:7 PDFDocument_parse@resource://pdf.js/build/pdf.worker.js:2350:7 ensureHelper@resource://pdf.js/build/pdf.worker.js:1971:22 NetworkPdfManager_ensure/<@resource://pdf.js/build/pdf.worker.js:1985:7 NetworkPdfManager_ensure@resource://pdf.js/build/pdf.worker.js:1965:1 BasePdfManager_ensureDoc@resource://pdf.js/build/pdf.worker.js:1832:14 loadDocument/
Note: I have installed texlive in ubuntu so I can use pdftex. xelatex is also installed.
Web server content: small latex file contained "latex_template.php" and the index.php contains the following php script.
ob_start();
include 'latex_template.php';
$outputData .=ob_get_contents();
ob_end_clean();
$texFile = tempnam(sys_get_temp_dir(), 'test');
$base = basename($texFile);
rename($texFile, $texFile.".tex");
$texFile .= ".tex";
file_put_contents($texFile, $outputData);
chdir(dirname(realpath($texFile)));
$console = shell_exec("xelatex {$base}" );
//$console = system("xelatex {$base}" );
header('Content-Type: application/pdf');
$pdf = dirname(realpath($console)).DIRECTORY_SEPARATOR.$base.".pdf";
readfile($pdf);
Note: Manual execution xelatex: log file:
链接地址: http://www.djcxy.com/p/33428.html上一篇: 这些LateX错误来自哪里?