# About how to take a screenshot by websdk

**URL:** <https://forum.deepar.ai/t/about-how-to-take-a-screenshot-by-websdk/557>\
**Category:** SDK\
**Tags:** web-sdk\
**Created:** [February 3, 2024, 7:34am UTC](https://forum.deepar.ai/t/about-how-to-take-a-screenshot-by-websdk/557 "2024-02-03T07:34:37Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![William](https://avatars.discourse-cdn.com/v4/letter/w/b19c9b/32.png) [@William](https://forum.deepar.ai/u/William)\
**Post date:** [February 3, 2024, 7:34am UTC](https://forum.deepar.ai/t/about-how-to-take-a-screenshot-by-websdk/557/1 "2024-02-03T07:34:37Z")

</div>

How to take a screenshot by websdk?  
The following is my script for take screenshot of AR screen, but it is not working, there is an Uncaught ReferenceError:deepAR is not defined  
Would you provide a simple coding for reference, thank you.

Error:

 ![image](https://europe1.discourse-cdn.com/flex017/uploads/deepar/original/1X/20e6993ca507fa9cd5fc07c4ff7f4b5876661d95.png)

---

<div class="post-metadata">

**Author:** ![igor](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.deepar.ai/igor/32/547_2.png) [@igor](https://forum.deepar.ai/u/igor)\
**Post date:** [February 5, 2024, 7:38am UTC](https://forum.deepar.ai/t/about-how-to-take-a-screenshot-by-websdk/557/2 "2024-02-05T07:38:34Z")

</div>

You need to make sure you are accessing the `deepAR` variable in the scope where it was declared. You are getting the `ReferenceError` because the variable does not exist in the scope.

[`takeScreenshot`](https://docs.deepar.ai/deepar-sdk/deep-ar-sdk-for-web/api-reference/classes/DeepAR.html#takeScreenshot) is an async function which returns the image in `data:image/png` format. You can see one usage of it [here](https://github.com/DeepARSDK/photoedit-web-js/blob/b36bd6cfc26a1b3a1e0c8a12e66b2773b58c4278/src/index.js#L104).

---

<div class="post-metadata">

**Author:** ![William](https://avatars.discourse-cdn.com/v4/letter/w/b19c9b/32.png) [@William](https://forum.deepar.ai/u/William)\
**Post date:** [February 5, 2024, 8:05am UTC](https://forum.deepar.ai/t/about-how-to-take-a-screenshot-by-websdk/557/3 "2024-02-05T08:05:27Z")

</div>

Thank you very much, the problem is solved.

do you have example for recording video by websdk?

---

<div class="post-metadata">

**Author:** ![igor](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.deepar.ai/igor/32/547_2.png) [@igor](https://forum.deepar.ai/u/igor)\
**Post date:** [February 5, 2024, 8:34am UTC](https://forum.deepar.ai/t/about-how-to-take-a-screenshot-by-websdk/557/4 "2024-02-05T08:34:53Z")

</div>

I don’t have an example but I can write a short snipper which should help you get the idea of how to do it.

```auto
document.getElementById('record-button').onclick = async function() {
    if (!isRecording) {
       // Start the recording
       isRecording = true;
       await deepAR.startVideoRecording();
   } else {
      // Stop recording
       isRecording = false;
       const video = await deepAR.finishVideoRecording();

       // Download video
       const a = document.createElement("a");
       document.body.appendChild(a);
       a.style = "display: none";
       a.href = window.URL.createObjectURL(video);
       a.download = "video.mp4";
       a.click()
       window.URL.revokeObjectURL(a.href);

```
