More specifically on how to properly export an image given the document objects bounds.
The method itself is working fine and the expected image is created … but … with a margin that I can’t figure out how to remove.
It seems like somewhere in the code there is something that adds spacing.
That basiclly visualizes the result I want to get, and what I do get right now. The first picture to the left is having a slight margin and the one to the right is what I want to get with no margin outside / around the object(s).
ComputeBounds does include the ExpandPaintBounds for each object, so you are picking up a little extra there, depending on the objects. I suspect that’s what you’re seeing.
You could iterate the objects and do your own Bounds computation if you want exact bounds.
The reason for having ExpandPaintBounds is to cover things like shadows.
Even if there’s no shadow, you would still need to be concerned about anti-aliasing and pixel positioning.
That computation covers the document’s area, but doesn’t account for selection handles and such, which belong to the GoView.
Finally, we originally didn’t have those extra margins, and people complained, even when none of the just-mentioned reasons applied.
So I suggest you do what Jake suggested – either calculate the bounds you want in your own manner, or just use a value somewhat smaller than that returned by ComputeBounds.