I’m looking for a library (or a cleverer solution) in C or C++ that would make an image file (PNG|jpeg) from LaTeX code. The use of packages is a prerequisite.
For now I’m thinking of compiling a .tex file into a .dvi and using dvipng to get a .PNG.
There’s also the possibility of compiling a .tex file into a .ps file and then converting it into a .PNG by the mean of extern utilities like pstopng or pstoedit.
But these solutions are cumbersome and not always portable. I would like to integrate this conversion in my program transparently.
I’ve used the dvipng route several times before, but in python. It’s a common path, that lots of people have taken. Here’s the code, to give you something to get started, and in case anyone wants Python code. I do realise you asked for C/C++; this is for a starter, or for others. This is for generating equations, but it would be trivial to adapt it for more general structures. It does support packages.
In terms of integrating it transparently, I feel your pain. Not everyone has tex / latex of course, and if they don’t, it’s often a pain to get. The best way to do it, I think, is to provide that functionality as a web service – but of course that’s not always an option.
Finally, note all the options for dvipng. They control the appearance, via various anti-alisaing options etc. I tuned them extensively to get what I thought looked good.