PHP LaTeX to PDF Conversion/Compiling [closed]
Asked Answered
I

3

10

I have searched far and wide to find a PHP-based tool to convert LaTeX to PDF, but have had no success. I understand that LaTeX runs on the server side, however I still require a PHP-based command process in order to generate said PDF files using LaTeX.

Edit

Additionally, installing binaries, libraries or tools on to the server is a no-no. The tool at my disposal is PHP and the functionalities it has built in. Any class or PHP tool that can convert LaTex to PDF is incredibly useful.

Any guidance would be most appreciated.

Idiom answered 20/12, 2011 at 14:50 Comment(2)
LaTeX isn't converted to PDF, but compiled. Simply use the pdflatex compiler on a temporary file at the server side..Rowlock
tex.stackexchange.com exists; you migt want to ask there.Elkeelkhound
S
12

i just installed the package texlive-binaries and used a shell exec with the pdflatex command to generate the PDF from a (La)TeX file:

shell_exec("/usr/bin/pdflatex --interaction batchmode $filename");

i know this is not what you asked for but i don't know of a php lib as complete as the already existing latex compilers.

why reinvent the wheel anyways?

Update: When you have enough space, install textlive-full instead of texlive-binaries. This will install all the available packages, fonts, etc. and avoid you some headache why your document renders wrong.

Supersession answered 20/12, 2011 at 15:0 Comment(5)
How does one go about installing the texlive-binaries on both a window and then a linux server?Idiom
on debian linux, you just do sudo apt-get install texlive-binaries. on a windows system you follow the instructions on the texlive websiteSupersession
I cannot accomplish such a task in my server environment. The tool at my disposal is PHP and the functionalities it has. Unless there is some Class or PHP tool that can convert LaTex to PDF, then I'm afraid this is of no help.Idiom
Using shell_exec() is a security issue. Be warned.Gorlin
@josh122a123 no, it's not. Passing unfiltered user input is the security issue you're thinking about. The same applies to database queries, all kind of file operations or any other type of privileged access, i.e. backend API calls. Using shell_exec() is NOT a security issue per se.Supersession
M
0

If you can't change your server setup to install server package for LaTeX you can't convert LaTeX files them into PDF...

but what you could check to convert directly into PDF without LaTeX, but that depends what you like to accomplish? It might be a look worth...fpdf...

Masterpiece answered 22/12, 2011 at 18:24 Comment(4)
I have looked into fpdf, as you can see by my previous question: #8479220 I can write a script to convert XML to LaTeX, I am just attempting to find a way of outputting certain characteristics LateX happens to offer.Idiom
So now the question is coming to my mind: What's the reason to use LaTeX? Which functionality do you need of LaTeX ?Masterpiece
LaTex has a built in Screenplay class, as pointed out by @Blender, which has certain functionalities that pose difficult to recreate. LaTeX offers a simpler solution (As noted in my previous question).Idiom
Ok..I know LaTeX so you need to install a LaTeX system on the server to use it. That's the point. There seemed to be no way around it.Masterpiece
E
0

that is my example: name: phplatex.php

<?php
$data = shell_exec('/Library/TeX/texbin/pdflatex --interaction=nonstopmode -output-directory=/Users/arico/a/destino /Users/arico/a/fuente/prueba.tex');
echo ('Latex: ' . $data . '');
?>

path of pdflatex executable: /Library/TeX/texbin/pdflatex

path of output file in pdf: (you need permissions to write) -output-directory=/Users/arico/a/destino

path of source file in latex: /Users/arico/a/fuente/prueba.tex

Expenditure answered 9/9, 2017 at 18:31 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.