How to turn a map into a picture,such as jpg or png

1. A concise explanation of the problem you're experiencing.

I create a map by the function of 'new Cesium.Viewer()' ,now I want to change the dom'scope of content to a picture

I have tried to get the dom of map canvas,then use the method 'canvas.toDataURL('image/jpeg', 1);',but why the picture just a whole black.
how can i do for this problem.

You have to call viewer.render() before calling canvas.toDataURL().