is there a way to generate a (single-page) PDF with pagesize that is just large enough for the text that I want to display?
Perhaps something along these lines:
\documentclass{article}
\pagestyle{empty}
\usepackage[papersize=minimal]{geometry}
\begin{document}
\[
Some beautiful formula
\]
\end{document}
And then produce a PDF with a pagesize that is just enough for the "beautiful formula".