Compiling Latex with Javascript

Viewed 523

I am working on a webapp(written with react-js) that generates a Latex code which contains information to give to the user. My goal is to let the user download the PDF file directly from my application.

I first tried using this library: texlive.js, that seemed to work but really it's impossible to recompile(their "Makefile" is not meant to handle new packages) if you try to add new packages(only some basic ones work).

So I thought about using the overleaf APIs but they don't let you obtain the pdf without sending the user to their website.

Any advice to make one of them work or any other way to achieve my goal?

2 Answers

You can install your package in texlive.js without using MakeFile

Sorry I am not expert in answering but here is how i made it work

I wanted to implement exam paper generation using javascript

Required Package/Class : exam

I created "\texlive.js\texlive\texmf-dist\tex\latex\exam\exam.cls"

Added this to

"\texlive.js\texlive\texmf-dist\ls-R"

./tex/latex/exam:
exam.cls

And Then \texlive.js\texlive.lst

/texmf-dist/tex/latex/exam/.

And

/texmf-dist/tex/latex/exam/exam.cls

I've recently found this project: https://github.com/SwiftLaTeX/SwiftLaTeX

I've tested it with a few documents and it seems to work. It downloads the needed packages from the web, see available packages: https://www.ctan.org/. I haven't gone deeper into passing images to the engine but it should be possible. See the official demo: https://www.swiftlatex.com/#demo

Here is the official guide with the download link for the already compiled wasm files and with the js bindings: https://www.swiftlatex.com/#install

Related