views:

992

answers:

4
+7  Q: 

LaTex for .NET

I am using ItextSharp to generate PDF. Part of our output, we have a lot of math related content. Maybe we can use some kind of Latex library to feed the result to ItextSharp to produce PDF. I have been googling for a while now but found nothing. Do you know if there is a latex library for .NET exists?

Also, do you know if ItextSharp can handle this without this Latex help?

+2  A: 

Your best bet may be to roll your own.

It might be as simple as making a basic template, and then doing:

  1. Insert expression into template.
  2. Compile with pdflatex.
  3. Insert resulting pdf into your document.

As another option, you could look at the source for other applications that do this. Mediawiki (the software behind wikipedia) springs to mind – it can use a LaTeX backend to generate maths formulae, and it's open-source so you can see how they did it.

John Fouhy
See also the TeX-like engine of Matplotlib - it is written in Python, and although Matplotlib uses Numpy and other extensions so you can't directly use it in IronPython, it would likely be a fairly easy project to make the math rendering engine a standalone library. I think there was once going to be a GSoC project to do exactly this, but the student got a real job at the last moment.
Jouni K. Seppänen
Hey, there's a new project with the same goal accepted for GSoC 2009! I'll edit my answer to link to it.
Jouni K. Seppänen
+2  A: 

It probably doesn't exist yet, but it shouldn't be an impossibly big project to compile TeX for C#. The original TeX was written in a version of Pascal, which is nowadays automatically translated into C by web2c. So it would just be a "small matter of programming" to make web2c produce C#, and to translate the supporting libraries (kpathsea, and whatever parts of pdftex you need - probably not nearly all of it) to be compatible.

Apart from that, there seems to be a GSoC project to extract the math rendering engine of Matplotlib into a separate library. Assuming that the library will be pure Python, you could use it via IronPython. So if you can wait until the end of the summer, that might be just what you need.

Jouni K. Seppänen
+2  A: 

The GSoC project owner got back to me on the new project to externalize Mathtext to a new python library called MathTex.

He said that his work depends on a library called FT2FONT which is a wrapper around a C++ library. It would be trivial, for someone with good .net font knowledge, to take this work and use the wrapper to wrap the .net Font library and allow it to be used in IronPython.

Jeremy Petzold
A: 

I'd look at a wrapper library too. Unless your wanting to write something massive like a latex editor, you're probably only wanting a small subset. I'd look at texnet free (www.texdotnet.com).

Rod