manuels / texlive.js

Compiling LaTeX (TeX live) in your browser
http://manuels.github.com/texlive.js/
GNU General Public License v2.0
1.25k stars 140 forks source link

How do I actually use texlive.js on my website? #39

Closed hypernova0 closed 8 years ago

hypernova0 commented 8 years ago

Hey, sorry for the newbie question, but I'm having great difficulty actually understanding how texlive.js is integrated into a website.

All I've wanted to do is get the example at the top of the page working - I think I could take the rest from there. That is:

var pdftex = new PDFTeX();
var latex_code = "" + 
  "\\documentclass{article}" + 
  "\\begin{document}" + 
  "\\LaTeX is great!" + 
  "$E = mc^2$" + 
  "\\end{document}"; 

pdftex.compile(latex_code)
      .then(function(pdf) { window.open(pdf) });

I've tried downloading the zip file of the github project, running index.html locally, then running 'compile this latex document' and get an error about difficulty establishing a web worker.

I've tried using (what I thought were) the main scripts of this project, i.e., promise.js, pdftex.js, and pdftex-worker.js, and then running the above code but that didn't work either.

What am I missing here? Is emscripten required to get texlive.js up and running? Is there a backend aspect to texlive.js that I'm completely missing? My understanding is that everything in this project is client-side, so shouldn't it be possible to throw up all the files in the project on my server, load up the index.html, then insert the above code in the console and have a tab pop open with the 'LaTeX is great!' pdf?

Thanks for any help!

xylo04 commented 8 years ago

It sounds to me like everything should work. Any web server should do; I've used both Apache2 and Node http-server for local testing. Getting the paths set up just right was a bit tricky though. Can you provide more information, maybe console messages or 404's from the network debugger?

If you want to see a working integration, you can check out my project googledrive/drivetex; in index.js#251 I'm taking the pdf data URL in the callback and shoving that into an iframe for inline viewing. You can see at line 238 that I use an optional constructor parameter to set up the path within the project; I actually submitted pull request #29 to @manuels to make that possible.

hypernova0 commented 8 years ago

Thanks a heap @xylo04! You pointed me in the right direction and now I have texlive.js up and running on my web server. I truly appreciate your help!