13

I am looking for a solution to generate pdfs dynamically and serve the web requests. I have a couple of questions:

  • Would it be a good solution to use LaTeX if I get input from web, fill LaTeX sources, generate pdf and return a link to the pdf?

As far as the amount of such request may go up to 10K a day, I am worrying about load, concurrency, scaleability issues. So,

  • Does anyone know the limits/boudaries for TeX compilers and pdf generators? Or suggest any to use in my case?

PS. The reason why I chose LaTeX is that documents to be generated have lots of rules such as formating, section alignments, margins, floats, etc...

  • 2
    shareLaTeX and writeLaTeX are examples of such on-demand online compilers. you can start from thise to get an idea of the speed. – percusse Jan 24 '14 at 6:22
8

Yes, you can do that. However, remember that it's not going to be a simple task. I'll first try to point out some general facts:

  • You wouldn't be the first one doing that, others include:

    • arXiv.org
    • many journals, who let authors submit the articles in TeX and typeset them on the server
    • writeLaTeX and shareLaTeX and similar services
    • me using it for PHP&MySQL-driven data visualization (score charts and score tables, meeting schedules and such)
  • Especially the last example above shows that people can use it without any LaTeX knowledge (I made the system, other colaborators have no idea what LaTeX is).

Then, excuse me for that, but I think that possible issues and things needed to solve should be pointed out:

  1. The amount of 10000 a day is really really a lot! If the compilation took 8 seconds per document, it would be 80000 seconds, which is the full day! And 8 seconds per document is quite possible. Get a very good hardware for that all. From my point of view: a lot of memory, so that the whole LaTeX distro can be pre-cached, or installation on an hybrid drive, with LaTeX distro being on the SSD part of course.

  2. If the data is not filled "from inside LaTeX", you have to cleverly and clearly take care of the input transformation, I mean: special characters, correct formatting, etc. It's a bit more difficult that how it looks at the first sight.

  3. Big problem is if you don't solve some situation correctly and error messages appear during the LaTeX compilation, users will simply have to wait until you come and see what's going on.

  4. You need the correct access to the services from within the web server environment. I mean, if it's in PHP, you can only call LaTeX using exec(), which is quite frowned upon by many sysadmins for its risks. Surely you should create a seperate user account just for this stuff on your (I suppose UNIX) server.

  • Actually I am to design slightly different than those online tex editing services. – maksmara Jan 24 '14 at 14:38
  • I do not need realtime editing of the tex document, as they are predefined with all necessary styles and markups, except for content, and stored in the server. User opens webapp and selects document to fill in, enters necessary content in html forms and send them to the server. Server fills tex template with the content from the request, generates pdf, informs the user that pdf is ready and sends a link to that pdf. Most of the documents are a couple of pages, but there are some more than 70 pages. – maksmara Jan 24 '14 at 14:54
  • 1
    @maksmara Yep, that's quite similar to what I do in my workflow. The problems are as I mentioned: when someone fills We work with the companies Jack & John, Ltd. and Josh, Inc. then you need to convert it into Jack \& John, Ltd.\@ and Josh, Inc., or use \frenchspacing, for isntance. There are dozens of such rules you need to take care of. Or you can simply \let\do\@makeother\dospecials to prevent these problems, but that isn't the easiest thing to handle either. – yo' Jan 24 '14 at 15:03
  • TeX doesn't know pre-caching of parts of the document. Well, you can speed the process up by precompiling your own headers, but still, with 10k documents, you're on a tight boundary of what's actually doable. – yo' Jan 24 '14 at 15:09
  • @maksmara Those services have clusters behind. I want to have a cluster, too :) But if you have one, you're a happy guy :) – yo' Jan 24 '14 at 15:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.