如何通过PHP将LaTeX转换为PDF/PNG [英] How to convert LaTeX to PDF/PNG by PHP

查看:83
本文介绍了如何通过PHP将LaTeX转换为PDF/PNG的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在PHP中有 LaTeX 代码(不是.tex文件);例如由$ _POST收到.如何在服务器上将呈现的 LaTeX 保存为PNG或PDF文件?

I have LaTeX code inside PHP (not as .tex file); for example received by $_POST. How can I save the rendered LaTeX as a PNG or PDF file on my server?

编辑:我知道PHP通常不会这样做.我将在PHP中运行一个shell命令.因此,我需要在Linux终端中执行此操作.

I know that PHP normally does not do this. I will run a shell command within PHP. Thus, I need something to do so in Linux terminal.

推荐答案

您可以执行exec()pdfTex生成PDF

you could exec() pdfTex to generate a PDF

URL: http://www.tug.org/applications/pdftex/

运行命令

pdftex file.tex

使用file_put_contents()将tex代码从$ _POST保存到文件后,请确保您具有写入指定文件夹的权限.

after you saved your tex-code from $_POST to a file using file_put_contents() - make sure you have the rights to write in the specified folder.

希望有帮助!

这篇关于如何通过PHP将LaTeX转换为PDF/PNG的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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