[Tex/LaTex] Howto generate png images of characters using LaTeX

conversiongraphics

I need to generate PNG images of Latin characters and AMS symbols with transparent background. Each image should be exactly in dimensions of its box. I know It's possible with LaTeX because I see online LaTeX formula editors can generate such pictures. Currently I can generate only dvi and pdf files in known paper sizes (a4,letter …). size of output must be bounded to its content and output must be in png format with transparent background.

I wish do this using a program. because there are thousands of characters and symbols that I need their LaTeX-produced images. Please tell me if there are CLI solutions or not. Also some of characters can only produced by XeTeX and XeLaTeX (characters of non-latin scripts)

Best Answer

How about using dvipng.

\documentclass{minimal}
\newcount\n
\parindent=0pt
\begin{document}
\n=1
\loop\ifnum\n<256
        \char\n
        \advance\n by 1
        \newpage
\repeat
\char0
\end{document}

Then run latex l; dvipng l; mv l256.png l0.png

Obviously, this only solves part of the problem, but it should demonstrate how to handle the ones that can be done with dvi output.