JuliTrusalin
JuliTrusalin

Reputation: 11

Autodesk Forge Viewer getScreenshot methode

Im trying to generate a Screenshot from my forge Viewer with an explicit width and height. Im using this methode:

this.viewer.getScreenShot(
            this.width,
            this.height,
            img => this.createPDF(img));
    }

If my height value is the full canvas height I can calculate a width value to fit a certain aspect ratio like 1:2. If I want to calculate my height value to match someting like 16:9 I always get the full canvas height no matter what my this.height value is and my screenshot width will change to a value to match the 16:9 aspect ratio. I dont know if Im missing something or doing sth wrong or this this a feature from the forge viewer implementation. With this behavior it is impossible for me to make a 16:9 screenshot just from my canvas and nothing more. My actual goal was to render a frame into my viewer canvas to see the aspect ratio and switch between multiple. I was able to render this frame based on ratio and clientToWorld coords but my screenshot just expands to the full height size. Maybe you guys know a solution for this problem. Thx, JT

Upvotes: 1

Views: 691

Answers (1)

Adam Nagy
Adam Nagy

Reputation: 2125

Are you trying to crop the image to a certain aspect ratio? Or stretch it to that?

What getScreenShot() does is like creating a Viewer with the given dimensions and taking a snapshot of that. So you are not restricted to the current Viewer dimensions but could even create a better quality image than what the user is currently seeing. E.g. I can create a 1600x900px png no matter what the Viewer size is.

If you do not pass in a 3rd parameter for the blob, the generated image will just pop up in another browser tab. You can test things in the Browser Console on any site that is using the Viewer via NOP_VIEWER e.g. doing this:

NOP_VIEWER.getScreenShot(1600, 900); 

Upvotes: 2

Related Questions