Within the built-in functions of PHP, you probably cannot do that. You would need to interface with some sort of web page rendering engine that has the ability to generate the image. (No, I don't have any specific recommendation, I just know that they are out there.)