Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Native Development

Reply
Developer
Posts: 109
Registered: ‎06-25-2013
My Device: Z10

Save screen/window to image

Hi,

 

I have to capture the screen and save it as pdf in memory. I have written the code part to capture the screenshot and convert it into a pdf and it is working fine. 

 

I have a webview in a scrollview where i have some contents either above or below the displayed screen. 

 

I need to capture the complete screen or page and save it as a pdf. But, the issue is that it captures only the displayed part of the screen

 

How to capture complete screen ????

 

Regards,

 

 

Developer
Posts: 824
Registered: ‎10-16-2012
My Device: Red Z10

Re: Save screen/window to image

[ Edited ]

to do this you would need to scroll your content onto the screen and capture it, then merge all the images into 1

 

like this(my favorite) google chrome extension does

http://www.webpagescreenshot.info/

 

if you want a visual idea of it's done install this extension then go to a page that needs to be scrolled, click the extension icon in top right of chrome and then select All Page Screenshot, then watch it go

Developer
Posts: 109
Registered: ‎06-25-2013
My Device: Z10

Re: Save screen/window to image

Hi,

 

That extension was not available at the store.

 

I need to scroll the page programatically in my app or what ???

 

if yes, then how but my page should stay at the position where it is currently.

 

regards,

Developer
Posts: 824
Registered: ‎10-16-2012
My Device: Red Z10

Re: Save screen/window to image

Well that's unfortunate, I've found a similar extension that is still in the chrome store

 

https://chrome.google.com/webstore/detail/capture-webpage-screensho/mcbpblocgmgfnpjjppndjkmgjaogfceg

 

yes you would need to scroll the page programtically (actually the scrollview) using scrolltopoint and viewablearea you should be able to determine what parts of the screen you havent captured yet

Developer
Posts: 109
Registered: ‎06-25-2013
My Device: Z10

Re: Save screen/window to image

I am trying the same, using scrolltopoint and viewablearea.

There isn't any other method simpler than this.
Developer
Posts: 824
Registered: ‎10-16-2012
My Device: Red Z10

Re: Save screen/window to image

using those 2 methods (and maybe others) you'll need to develop a formula to determine how big the scrollable area is, how much of the screen you have seen and how much is left to be seen, then you'll also need to ensure none of the pictures content overlapped, and if it did you'll need to crop it before joining them.

 

This isn't going to be extremely easy, but once you've figured it out it will make for a neat application.

Developer
Posts: 109
Registered: ‎06-25-2013
My Device: Z10

Re: Save screen/window to image

Hi, 

 

I am unable to get how to take the complete screenshot. 

 

My page size (in scroll view) is dynamic. suppose currently it is 2000, 1200 (height, width). 

 

How to extract the page size which is displayed currently from program.

 

viewablearea returns 1280, 768. So, i am unable to navigate to the required place.

 

 

Developer
Posts: 824
Registered: ‎10-16-2012
My Device: Red Z10

Re: Save screen/window to image

the max area as you said is 2000,1200 

 

your viewable area is 1280x768.  What this means is you are currently viewing this portion of the 2000x1200

 

so you take a screenshot then use scrolltopoint(1280, 0) (sideways)take another screenshot then move over again if neccesary  (notice when you scroll to point your viewable area changes because you're viewing a new area)

 

Then you want to go downwards use scrolltopoint(0,768) then take your next screenshot.

 

you can either allow the content to over lap (and crop it after) or cut your screenshot dimensions down to the area's that you haven't captured yet

 

then you will need to take all these images and merge them.  

 

I have never done anything like this so that's the most detailed info i can provide on the process, hope it helps.

 

Developer
Posts: 109
Registered: ‎06-25-2013
My Device: Z10

Re: Save screen/window to image

[ Edited ]

is there any way to get the height and width of the scroll view.

As the webview content is dynamic so the dimensions may vary.

 

Developer
Posts: 824
Registered: ‎10-16-2012
My Device: Red Z10

Re: Save screen/window to image

if you're using a webview, put this inside of it then watch your console.log to see.  then you can use handler.layoutFrame.width & handler.layoutFrame.height

 

attachedObjects: [
                    // This handler is tracking the layout frame of the button.
                    LayoutUpdateHandler {
                        id: handler
                        onLayoutFrameChanged: {
                            // Individual layout frame values can be
                            // retrieved from the signal parameter
                            console.log("Web Layout Frame: [" +
                            "Web Width: " + layoutFrame.width + ", Web Height " + 
                            layoutFrame.height + "]");
                        }
                    }
                ]