
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Save DIV as Image with HTML5 Canvas
DIV content can be saved as an image with the help of html2canvas() function in JavaScript. DIV tag defines a section in HTML document.
Example
<div id = ”cpimg” style = ”padding: 25px ; ” > <h4>Welcome</h4> </div>
This shows the division area named cpimg.
The html2canvas() function save div as an image with the following code −
html2canvas(document.querySelector(“#cpimg”)).then(canvas { document.body.appendChild(canvas) });
It saves the referred div section “cpimg” into the image.
Advertisements