473,405 Members | 2,379 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

Capture Control Into Image

111 100+
I wants to capture Table contents(ie. entire table) into image file in aspx page.

How to do?.

There is a code for captuer a portion of he screen.

Cature a rectangle of the screen and save to a png file

Expand|Select|Wrap|Line Numbers
  1. var as=new ActiveXObject("ActiveScreen.Capturer");
  2. as.CaptureRect(200, 200, 400, 300);
  3. var fs=as.SaveToFile("test3.png");
  4. WScript.Echo("Image Size = " + fs.toString() + "\r\n");
But I want to capture only a particular control (Table) contents as image.
Dec 27 '07 #1
11 5771
gits
5,390 Expert Mod 4TB
hi ...

so you may use a function like in the following example:

Expand|Select|Wrap|Line Numbers
  1. <script type="text/javascript">
  2. function get_coords(elem_id) {
  3.     var node = document.getElementById(elem_id);
  4.     var dims = {
  5.         x: node.offsetLeft,
  6.         y: node.offsetTop,
  7.         w: node.offsetWidth,
  8.         h: node.offsetHeight
  9.     };
  10.  
  11.     return dims;
  12. }
  13. </script>
  14. <body onload="get_coords('my_table');">
  15. <table id="my_table">
  16.     <tr>
  17.         <td>test</td>
  18.     </tr>
  19. </table>
  20. </body>
  21.  
that returns you an object with the coords for your CaptureRect(); method ...

kind regards
Dec 27 '07 #2
baburk
111 100+
I had used this script to capture control and its contents as image


Expand|Select|Wrap|Line Numbers
  1.    <script type="text/javascript">
  2. function get_coords(elem_id) {
  3.     var node = document.getElementById(elem_id);
  4.  
  5.  
  6.     var as = new ActiveXObject("ActiveScreen.Capturer");//Here I got this error
  7.     as.CaptureRect(node.offsetLeft, node.offsetTop, node.offsetWidth, node.offsetHeight);
  8.     var fs=as.SaveToFile("C:\Documents and Settings\arun.v.DBA-CORP\Desktop\Babu\test3.png");
  9.     WScript.Echo("Image Size = " + fs.toString() + "\r\n");
  10.  
  11.     var dims = {
  12.         x: node.offsetLeft,
  13.         y: node.offsetTop,
  14.         w: node.offsetWidth,
  15.         h: node.offsetHeight
  16.     };
  17.     return dims;
  18. }
  19. </script>
Any one help me how to rectify the error.

Thanks in advance.
Jan 3 '08 #3
baburk
111 100+
This script gets the height , width, left, top of the GridView.

Now I want to capture this gridview as image through this position.

How can I?.

Expand|Select|Wrap|Line Numbers
  1. <SCRIPT LANGUAGE="JAVASCRIPT">
  2. function capture()
  3. {
  4. var node = document.getElementById("GridView1");
  5.  
  6.     var dims = {
  7.         x: node.offsetLeft,
  8.         y: node.offsetTop,
  9.         w: node.offsetWidth,
  10.         h: node.offsetHeight
  11.     };
  12. </script>
Jan 3 '08 #4
gits
5,390 Expert Mod 4TB
hi ...

please keep one topic in one thread ... don't double post your question.

compare the code i provided with that you posted at least ... it will not work since it misses a bracket and the returnvalue for the dims.

as i said you simply should call the function and store the result in a variable:

Expand|Select|Wrap|Line Numbers
  1. var dims = function get_coords(elem_id);
now you could refer to the members of our dims-object like:

Expand|Select|Wrap|Line Numbers
  1. alert(dims.x);
which alerts the left top position. put it into your CaptureRect()-method and it should work.

make an attempt and post back in case you have further problems.

kind regards
Jan 3 '08 #5
gits
5,390 Expert Mod 4TB
I had used this script to capture control and its contents as image


Expand|Select|Wrap|Line Numbers
  1.    <script type="text/javascript">
  2. function get_coords(elem_id) {
  3.     var node = document.getElementById(elem_id);
  4.  
  5.  
  6.     var as = new ActiveXObject("ActiveScreen.Capturer");//Here I got this error
  7.     as.CaptureRect(node.offsetLeft, node.offsetTop, node.offsetWidth, node.offsetHeight);
  8.     var fs=as.SaveToFile("C:\Documents and Settings\arun.v.DBA-CORP\Desktop\Babu\test3.png");
  9.     WScript.Echo("Image Size = " + fs.toString() + "\r\n");
  10.  
  11.     var dims = {
  12.         x: node.offsetLeft,
  13.         y: node.offsetTop,
  14.         w: node.offsetWidth,
  15.         h: node.offsetHeight
  16.     };
  17.     return dims;
  18. }
  19. </script>
Any one help me how to rectify the error.

Thanks in advance.
threads merged again ... please don't spread the topic ... keep it in one thread!

first use the following simplyfied code:

Expand|Select|Wrap|Line Numbers
  1. function get_coords(elem_id) {
  2.     var node = document.getElementById(elem_id);
  3.  
  4.     var dims = {
  5.         x: node.offsetLeft,
  6.         y: node.offsetTop,
  7.         w: node.offsetWidth,
  8.         h: node.offsetHeight
  9.     };
  10.  
  11.     var capt_obj = new ActiveXObject("ActiveScreen.Capturer");
  12.     capt_obj.CaptureRect(dims.x, dims.y, dims.w, dims.h);
  13.  
  14.     var path = "C:\\Documents and Settings\\arun.v.DBA-CORP\\Desktop\\Babu\\";
  15.     var fs = capt_obj.SaveToFile(path + 'test3.png');
  16.  
  17.     WScript.Echo("Image Size = " + fs.toString() + "\r\n");
  18. }
  19.  
show the call! how do you call that code?

kind regards
Jan 3 '08 #6
baburk
111 100+
Hi,
Though that heigth, width, top, bottom I want to capture the GridView Into an image and store in one place.

There is a code for captuer a portion of the screen, This throws an exception (Microsoft JScript runtime error: Automation server can't create object).

Cature a rectangle of the screen and save to a png file
Expand|Select|Wrap|Line Numbers
  1. var as=new ActiveXObject("ActiveScreen.Capturer");
  2. as.CaptureRect(200, 200, 400, 300);
  3. var fs=as.SaveToFile("test3.png");
  4. WScript.Echo("Image Size = " + fs.toString() + "\r\n");
So I am expecting help. How to capture the gridview as image.
Jan 3 '08 #7
baburk
111 100+
I called like this

Expand|Select|Wrap|Line Numbers
  1. <SCRIPT LANGUAGE="JAVASCRIPT">
  2. function get_coords(elem_id) {
  3.     var node = document.getElementById(elem_id);
  4.  
  5.     var dims = {
  6.         x: node.offsetLeft,
  7.         y: node.offsetTop,
  8.         w: node.offsetWidth,
  9.         h: node.offsetHeight
  10.     };
  11.  
  12.     var capt_obj = new ActiveXObject("ActiveScreen.Capturer");
  13.     capt_obj.CaptureRect(dims.x, dims.y, dims.w, dims.h);
  14.  
  15.     var path = "C:\\Documents and Settings\\arun.v.DBA-CORP\\Desktop\\Babu\\";
  16.     var fs = capt_obj.SaveToFile(path + 'test3.png');
  17.  
  18.     WScript.Echo("Image Size = " + fs.toString() + "\r\n");
  19. }
  20.  
  21. </script>
  22.  
  23.  
  24. </head>
  25. <body>
  26.     <form id="form1" runat="server">
  27.     <div>
  28.         <br />
  29.         &nbsp;
  30.         <asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Button" OnClientClick = "get_coords(GridView1);" Height="25px" />
  31.         <asp:GridView ID="GridView1" runat="server">
  32.         </asp:GridView>
  33.     </div>
  34.     </form>
  35. </body>
  36. </html>
Jan 3 '08 #8
gits
5,390 Expert Mod 4TB
i assume that ID="GridView1" is not the real id of the control ... could you have a look at the source-code when the page is loaded and search for the id there?

kind regards

btw: are you sure you have access to the control? i mean does it work with fixed values?
Jan 3 '08 #9
baburk
111 100+
Are you sure you have access to the control? i mean does it work with fixed values?

Yes It worked with fixed values.

In source also its id is

Expand|Select|Wrap|Line Numbers
  1. <table cellspacing="0" rules="all" border="1" id="GridView1" style="border-collapse:collapse;">
  2.         <tr>
  3.             <th scope="col">Name</th><th scope="col">Age</th>
  4.         </tr><tr>
  5.             <td>Babu</td><td>26</td>
  6.         </tr>
  7.     </table>
  8.  
Thanks
Jan 4 '08 #10
gits
5,390 Expert Mod 4TB
hi ...

please use code tags when posting source-code ...

could you alert elem_id at start of the get_coords()-method? ... i think you should adapt:

Expand|Select|Wrap|Line Numbers
  1. OnClientClick="get_coords('GridView1');"
since the id has to be passed as a string ...

kind regards
Jan 4 '08 #11
Its really helpful, but this code is not working online. i have gone through the other post in which i refer that, for this screen capture user need to change their browser's security settings. From this code i am able to get all values on nodes, but image is not saving on my local machine. kindly help
Dec 30 '11 #12

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Larry Cheung | last post by:
I want to write a program to monitor each local printer When a print job is sending to a printer this program could be fired and capture the printed content as an image. It is easy to use API...
10
by: Rattanak Song | last post by:
Hi, I'm trying to build a database which can capture a still image from a digital camera or web cam and import to the database via an Object or something like that. Any help would be very...
0
by: Oddball | last post by:
Is there any way to capture the graphics output of a control and route it to another control? That's confusing.. It's all about my listbox again - I want to be able to draw an image of a user...
1
by: Jody Gelowitz | last post by:
I have seen some examples of how to capture a color from a point on screen using C#, but haven't come across anything with VB.NET. Is this possible under VB.NET? I know that I will need to use...
3
by: aledrjones | last post by:
Hi I've got a c# application that will often run in the background as it is used to monitor connections to a host. An activex control displays the communication between the app and the host. ...
1
by: JP2006 | last post by:
I'm trying to write a control that will take a screen capture of a particular website when a user submits a form in a web application; one of the form fields is for a URL - the control needs to get...
0
by: =?Utf-8?B?Q2hha3JhdmFydGh5?= | last post by:
Hi, Have been trying to capture the webpage as image from quite a long time. Can some one suggest me a solution to convert or capture the HTML Output of any webresponse to anykind of image...
0
by: ikramalikhan | last post by:
i am developing a software in vb 6.0 as front end and msaccess as back end..i want to capture an ultrasound image via my vb form image control.my doctor client will capture live ultrasound image and...
4
by: ink | last post by:
Hi All, I am trying to build an image capture user control using DirectShow to be used in an existing C# application. It needs to have a view finder/ preview window and be able to take...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.