Render HTML as an Image

前端 未结 9 2126
遥遥无期
遥遥无期 2020-11-27 18:19

I\'m generating a coupon based on dynamic input and a cropped image, and I\'m displaying the coupon using ntml and css right now, the problem is, printing this has become an

9条回答
  •  时光说笑
    2020-11-27 18:51

    I haven't tried to myself, but you should be able to render HTML into an image by using the WebBrowser control and the DrawToBitmap() method inherited from the base Control class.

    UPDATE: I tried this myself and there are some caveats. The WebBrowser control doesn't seem to render the web page until the control is show, so the WebBrowser needs to be in a Form and the Form must be shown for the HTML to be rendered and the DocumentCompleted event to be raised.

提交回复
热议问题