Hmm, in theory I guess it's possible to do this at least: create an image "on the fly" using the ad's image and some extra space, while also writing text to the image during the creation process.
Your page would then end up as a big set of images, which would actually be similar to the way newspapers (used to, anyway) do their layout for publication.
It should then be possible to determine each image's size as they are displayed for billing purposes, I guess.
But, that's just in theory. Although it would be a nice challenge to develop something like that, it's also likely to be rather a PITA, so I can't say I'd envy you the task.
Kudos to you for a great question! Let's keep it up here a while and see if a real genius comes by. Maybe it's already been done? They say "there's nothing new under the sun ..." 🙂