# Redistributing pdfLaTeX as a part of an application

I have a "template" .tex file which I've created manually, and I want to be able to dynamically convert it to PDF in my software.

On my computer I use pdflatex for the conversion, but the end user might not have it installed. My question is - how can I install pdflatex on the end user's computer? what files should I install? I don't want the user to have to install a whole latex distribution because it is huge.. Maybe there is a small-minimal package to which I could add the packages I use in my pdf?

-
Aurora uses a simplified MiKTeX. And MATLAB also includes a small TeX distribution as part of it. Old but small teTeX might be also suitable. – Leo Liu Jun 21 '11 at 17:10
I have not tried this tex.stackexchange.com/questions/8249/…. Please try it and let me know. :-) Thank you. – xport Jun 21 '11 at 18:52
@xport: I haven't tried it.. I looked at what @Karl suggested - the MiKTeX Portable, and it looks great. A bit big though.. – Ofir Jun 21 '11 at 20:22

MiKTeX Portable is the simplest solution, I think.

It's about 400 MB uncompressed. Size can be reduced to ~300 MB by uninstalling unnecessary packages and fonts. But some packages can't be removed because there are package dependences.

Removing the doc folder will save yet another ~80 MB but that breaks the packages themselves. And should be done last.

Going below 200 MB uncompressed is equal in effort to making your own TeX distribution (or fork of a such distribution).

-
Thanks. I will look into the MiKTeX Portable.. It looks promising :) – Ofir Jun 21 '11 at 16:47
Right now I'm standing at about 320MB.. How could I know if some packages depend on a package I want to uninstall? – Ofir Jun 21 '11 at 20:23
@Ofir: The fastest way is just uninstall everything you think will not need. If it's needed, MiKTeX will reinstall it automatically. And just make a sample document, that uses all packages you need to install. Run it, and MiKTeX will resolve all dependences and will install all the packages needed. That's in case needed packages exist in the MiKTeX repository. – Karl Karlsson Jun 21 '11 at 20:40

My advice: use plain TeX instead of LaTeX. You will need far fewer files that way, and that means you can (usually) have everything you need as part of your software. I have done this on various occasions, and could usually get by with only a couple of megabytes of extra stuff (pdftex.exe, plain format and a macro file, and a few fonts).

-
Thanks. But when I try using pdftex <FileName> on command prompt it generates an error for practically every line in the .tex file, starting from the \documentclass (says "Undefined control sequence").. Should I use it differently from pdflatex? (and again, what files do I need to include except pdftex.exe and the .sty s of the packages I use?) – Ofir Jun 21 '11 at 16:47
@Ofir Unfortunately what Taco is suggesting would require rewriting your document in plain TeX and not in LaTeX. And I suspect that this might not be something you might be able to do at the present time. Although some style files are usable in both TeX and LaTeX, (although invoked differently in TeX) most aren't, so translating an existing LaTeX document to plain TeX is likely not to be a trivial task. – Alan Munn Jun 21 '11 at 17:05
@Alan I didn't think there was such a difference between TeX and LaTeX... So I guess my best option will be to include some version of MiKTeX with my software.. Thanks anyway – Ofir Jun 21 '11 at 17:26
LaTeX is a collection of macros for TeX, so of courseyou will have a lot undeclared commands, as you used a lot of LaTeX commands, which are not TeX primitives. – MaxNoe Jan 28 at 18:48

In order to get below 200 MB I ended up writing a small C# console application, which "builds" a minimal "core" from a full MiKTeX installation. The basic steps were:

1) Set up file access audit rules for all files in the original full MiKTeX installation.

2) Compile the target `.tex` files.

3) Copy all files accessed during compilation to form the new "core".

Using this approbation I was able to get down to ~ 60 MB uncompressed using a decent amount of packages.

-
Would you be willing to share that application? I would find it useful! – mrf Sep 25 '12 at 23:10

A much smaller and more configurable option is W32TeX: http://w32tex.org/

If you need a version which isn't license encumbered, then try KerTeX: http://www.kergis.com/en/kertex.html

-