Attach screenshot of DIV using html2canvas with contact details
-
Hello all. The last piece of the puzzle for me on a website project is to attach a screenshot of the contents of a DIV on the page along with the basic Name, Email and Phone Number, when submitting the form.
To explain: The DIV contains the final product created by a Custom builder. It is a building the user created with some options on the page. Now that the user has created their building. They need to submit their contact info along with an image of that building they just created. I came across “html2canvas” javascript library and it seemed the best solution for this. It lets you specify a DIV by its ID to screenshot rather then the whole screen. In this case the DIV ID = “vpc-preview”
How can when the user submits the form, a screenshot of the “vpc-preview” DIV be included in the email going to the WP Admin?
I can understand a bit of JS.. just need some guidance on this… I am sure that with that I can make it happen. It is greatly appreciated!
Here is the URL ot the library: https://html2canvas.hertzen.com/
Here is a snippet I know can be useful.
html2canvas($('#vpc-preview'), { onrendered: function(canvas) { var img = canvas.toDataURL() window.open(img); } });
Here is the URL to the page on the staging server I am working with that contains the “vpc-preview” DIV previously mentioned and where I will add the form needed.
- The topic ‘Attach screenshot of DIV using html2canvas with contact details’ is closed to new replies.