Create an Image of a DIV in JavaScript (GIF/PNG)

后端 未结 7 847
萌比男神i
萌比男神i 2020-11-30 12:39

I\'m wondering is there a JavaScript library available that would allow me to generate an Image from the contents of a DIV.

Basically this is required for some Serve

7条回答
  •  隐瞒了意图╮
    2020-11-30 13:08

    You can create an image tag from JavaScript but not the actual image in it: JS has no commands to allocate memory for the bitmap and it has no commands to render anything on it.

    The usual solution is to have a report generator on the server which creates the image on request. Look at BIRT or JasperReports.

    [EDIT] Based on your comment, the solution is simple: Examine the DIV, find the URL for the background image and replace the DIV with an IMG element. Put the URL into the SRC attribute and then print.

提交回复
热议问题