#Does Tauri have a feature similar to Electron's `capturePage()` ?

8 messages · Page 1 of 1 (latest)

gleaming cloak
#

Hello, everyone!
I want to take a snapshot for a Window. In electron, I can do something like window.webContents.capturePage().

I have already seen the following documents, but I couldn't find a feature that is similar to Electron:
https://docs.rs/tauri/latest/tauri/window/struct.Window.html
https://tauri.app/v1/api/js/window#webviewwindow

If Tauri doesn't currently support this feature, do you have any recommendations on how I might implement a similar functionality as a workaround?

Thank you!

Provides APIs to create windows, communicate with other windows and manipulate the current window.

#

I might have missed it in the documentation, and if so, I would appreciate it if you could point me in the right direction.

cobalt dust
#

I believe webviews in tauri are a lot more "vanilla" and don't provide an API like that

gleaming cloak
#

Thank you for your response.

If tauri don't support this, is there possibly another way to take snapshot for a window?

cobalt dust
#

There is this somewhat old library which basically recursively copies a node and all its children into an SVG's foreignObject to then render that to an image. I can't vouch for how well that works. https://www.npmjs.com/package/dom-to-image

Alternatively if you only want to capture what is currently visible on the screen then you could fall back to Rust and use this (or another) crate https://crates.io/crates/screenshots

#

with latter you'd have to do some manual work to figure out where the window is positioned currently, how big it is, etc so you can capture the correct area

leaden notch
cobalt dust
#

yeah that's probably going to be the most solid implementation