not PHP, but a Java library, which does the thing:
Flying Saucer takes XML or XHTML and applies CSS 2.1-compliant
stylesheets to it, in order to render to PDF
It is usable from PHP via system()
or a similar call. Although it requires XML well-formedness of the input
.