---
title: Take a screenshot in the browser
summary: Turn what the 3D viewer shows into a PNG, with or without a background, and render a series of images at a fixed size from a viewer that is never on the page.
order: 92
languages: [javascript]
terms: [viewer, viewpoint]
see-also: [how-to/rendering/render-a-screenshot, how-to/viewer3d/set-the-camera, how-to/viewer3d/annotations]
---

# Take a screenshot in the browser

`viewer.screenshot()` turns the viewer's canvas into a PNG in the browser: no server involved, and exactly what the user sees. For images without a browser, from a backend or a report, the server renders them instead ([[page:how-to/rendering/render-a-screenshot]]).

## Live demo

```demo
name: screenshots
title: Screenshots in the browser
models: ac11
height: 520
notes: |
  **Screenshot** copies the current view; **Background** gives it a white background instead of a transparent one. **Three views off screen** creates a second viewer that is never added to the page, sizes it to 1024 × 640 and renders three views of the model. Click an image to save it.
```

## Steps

```example
name: viewer-screenshot
code: javascript/viewer-screenshot.js
notes: The off-screen viewer has managers of its own, so the viewer on the page is not touched.
highlight: 2,14,19-22,26-28
```

1. **Take it.** `await viewer.screenshot(options)` returns a PNG `Blob` of the canvas at its current size (`viewer.getWidth()` × `viewer.getHeight()`). The background is transparent; `backgroundColor` puts a colour behind the model. `annotations: true` draws the template annotations into the image too, without their cards ([[page:how-to/viewer3d/annotations]]); `includeText: true` the labels of a plan ([[page:how-to/viewer3d/show-a-floor-plan#room-labels]]).
2. **Let it draw first.** The image is what the canvas shows at that moment. After moving the camera from code, wait for the viewer to draw, two animation frames, before taking the screenshot; otherwise you get the previous view.
3. **Fix the size off screen.** A viewer that is never added to the page renders all the same: `resize(width, height)` gives it the size of the images you want, independent of any screen. Load the model into it, set the camera ([[page:how-to/viewer3d/set-the-camera]]) and take a screenshot per view. `destroy()` frees it afterwards.
4. **Save it.** The `Blob` can be offered as a download through an object URL, uploaded, or put in an `<img>`.

## Check

The saved PNG has the size of the viewer, or of the `resize` call, and shows the view the camera was given before the screenshot.
