Accessing AnnotationManager methods in javascript
Accessing AnnotationManager methods in javascript
Hi
I am evaluating the product (GdPicture.NET v8.5.0.23) for an upcoming project.
I need to highlight a section of a tiff image in code uisng RectangleHighlighter annotation. These RectangleHighlighter annotations should be created in code when the user enters a field and deleted when he leaves the field. I have tried this functionality in a C# app using AnnotationManager.AddRectangeHighlighterAnnot method. It works fine.
But, I need to do this using Javascript in a ASP.NET app.
The javascript sample code provided in the download is only for the interactive methods (GdViewer.AddRectangleHighlighterAnnotInteractive) in the GdViewer. But, I need to implement this functionality in code using the annot methods in the AnnotationManager.
How do I get access to the AnnotationManager methods in Javascript?
Thanks in advance.
Regards
jeyaramg
I am evaluating the product (GdPicture.NET v8.5.0.23) for an upcoming project.
I need to highlight a section of a tiff image in code uisng RectangleHighlighter annotation. These RectangleHighlighter annotations should be created in code when the user enters a field and deleted when he leaves the field. I have tried this functionality in a C# app using AnnotationManager.AddRectangeHighlighterAnnot method. It works fine.
But, I need to do this using Javascript in a ASP.NET app.
The javascript sample code provided in the download is only for the interactive methods (GdViewer.AddRectangleHighlighterAnnotInteractive) in the GdViewer. But, I need to implement this functionality in code using the annot methods in the AnnotationManager.
How do I get access to the AnnotationManager methods in Javascript?
Thanks in advance.
Regards
jeyaramg
Re: Accessing AnnotationManager methods in javascript
Hello,
Here the code:
Note: this code will work only with the GdPicture.NET 8.5.24 and up. We will release the GdPicture.NET 8.5.24 within a couple of days.
Kind regards,
Loïc
Here the code:
Code: Select all
var oGdViewer = document.getElementById("GdViewer1");
var oAnnotationManager = new ActiveXObject("GdPicture.AnnotationManager");
oAnnotationManager.InitFromGdViewer(oGdViewer.GetObject());
oAnnotationManager.AddRectangleHighlighterAnnot(oAnnotationManager.ARGBI(255, 255, 255, 0), 1, 1, 3, 1);
Kind regards,
Loïc
Re: Accessing AnnotationManager methods in javascript
Hi
Thanks for the response.
I will wait for 8.5.24.
Regards
Jeyaraman
Thanks for the response.
I will wait for 8.5.24.
Regards
Jeyaraman
Re: Accessing AnnotationManager methods in javascript
Hello Jey,
The new release is available. See: https://www.gdpicture.com/download.php
Kind regards,
Loïc
The new release is available. See: https://www.gdpicture.com/download.php
Kind regards,
Loïc
Re: Accessing AnnotationManager methods in javascript
Hi Loïc
I uninstalled GdPicture8 and installed the latest version using the url mentioned in your last post.
I copied the code below from your mail in my dummy project.
Added a reference to the latest GdPicture.dll (v8.5.0.24).
var oGdViewer = document.getElementById("GdViewer1");
var oAnnotationManager = new ActiveXObject("GdPicture9.AnnotationManager");
oAnnotationManager.InitFromGdViewer(oGdViewer.GetObject());
oAnnotationManager.AddRectangleHighlighterAnnot(oAnnotationManager.ARGBI(255, 255, 255, 0), 1, 1, 3, 1);
While executing "new ActiveXObject("GdPicture9.AnnotationManager", it fails giving the following message.
Microsoft JScript runtime error : Automation server can't create object
I added an object tag for AnnotationManager as below.
<object id="AnnotationManager1" type="application/x-oleobject" classid="CLSID:942b6c88-8765-4d7c-bf6a-ff48b4b56d16">
</object>
Added the following line.
var oAnn = document.getElementById("AnnotationManager1");
On inspecting locals, the contentDocument and object entries for oAnn in the list are showing "Access is denied".
I am using VS2010, IE 8 on Windows7 Ultimate.
A quick reponse will be greatly appreciated.
Regards
Jey
I uninstalled GdPicture8 and installed the latest version using the url mentioned in your last post.
I copied the code below from your mail in my dummy project.
Added a reference to the latest GdPicture.dll (v8.5.0.24).
var oGdViewer = document.getElementById("GdViewer1");
var oAnnotationManager = new ActiveXObject("GdPicture9.AnnotationManager");
oAnnotationManager.InitFromGdViewer(oGdViewer.GetObject());
oAnnotationManager.AddRectangleHighlighterAnnot(oAnnotationManager.ARGBI(255, 255, 255, 0), 1, 1, 3, 1);
While executing "new ActiveXObject("GdPicture9.AnnotationManager", it fails giving the following message.
Microsoft JScript runtime error : Automation server can't create object
I added an object tag for AnnotationManager as below.
<object id="AnnotationManager1" type="application/x-oleobject" classid="CLSID:942b6c88-8765-4d7c-bf6a-ff48b4b56d16">
</object>
Added the following line.
var oAnn = document.getElementById("AnnotationManager1");
On inspecting locals, the contentDocument and object entries for oAnn in the list are showing "Access is denied".
I am using VS2010, IE 8 on Windows7 Ultimate.
A quick reponse will be greatly appreciated.
Regards
Jey
Re: Accessing AnnotationManager methods in javascript
Hello Jey,
Please replace:
bu:
Kind regards,
Loïc
Please replace:
Code: Select all
GdPicture9.AnnotationManager
Code: Select all
GdPicture.AnnotationManager
Loïc
Re: Accessing AnnotationManager methods in javascript
Hi Loïc
I have already tried "new ActiveXObject("GdPicture.AnnotationManager")".
It is still showing the same error ("Activex server can't create object").
I also tried running "GdPictureComReg.exe" from command prompt.
It returned without any message.
Tried the app after this. Same result.
I also ran VS2010 using "Run as administrator" option.
Same result.
I ran regedit. I could see entries for "GdPicture.AnnotationManager".
The runtimeVersion is v2.0.50727.
My project targets v4.0. Does this make a difference?
I am planning to try this on XP professional.
I have installed gdPicture (8.5.0.24) on the XP machine.
Strangly the "assembly" entry for GdPicture.NET shows "GdPicture.NET, Version=8.5.0.24, Culture=neutral, PublicKeyToken=463a3e8f47c889a3". On my Windows 7 machine the version is shown as "Version=8.5.0.5".
I will try the dummy project on my XP machine and update you.
Is there anything you want me check/try at this end?
Regards
Jey
I have already tried "new ActiveXObject("GdPicture.AnnotationManager")".
It is still showing the same error ("Activex server can't create object").
I also tried running "GdPictureComReg.exe" from command prompt.
It returned without any message.
Tried the app after this. Same result.
I also ran VS2010 using "Run as administrator" option.
Same result.
I ran regedit. I could see entries for "GdPicture.AnnotationManager".
The runtimeVersion is v2.0.50727.
My project targets v4.0. Does this make a difference?
I am planning to try this on XP professional.
I have installed gdPicture (8.5.0.24) on the XP machine.
Strangly the "assembly" entry for GdPicture.NET shows "GdPicture.NET, Version=8.5.0.24, Culture=neutral, PublicKeyToken=463a3e8f47c889a3". On my Windows 7 machine the version is shown as "Version=8.5.0.5".
I will try the dummy project on my XP machine and update you.
Is there anything you want me check/try at this end?
Regards
Jey
Re: Accessing AnnotationManager methods in javascript
This is the problem. Now you have to find a way to update your project to use the latest 8.5.0.24 assembly.Strangly the "assembly" entry for GdPicture.NET shows "GdPicture.NET, Version=8.5.0.24, Culture=neutral, PublicKeyToken=463a3e8f47c889a3". On my Windows 7 machine the version is shown as "Version=8.5.0.5".
Kind regards,
Loïc
Re: Accessing AnnotationManager methods in javascript
Hi Loïc
The issue with the version number (8.5.0.5) shown in the registry was due to an old Web runtime.
1. Uninstalled GdPicture and Web runtime.
2. Installed the latest GdPicture (8.5.0.24) and the latest Web runtime.
The version number is shown properly in the registry.
Still had the same problem with "new ActiveXObject("GdPicture.AnnotationManager").
Ran Redist\Com Interop\GdPictureComReg.exe.
Ran Redist\Com Interop\_Register for Com.bat
Added a button and the code to create the annotation to samples\AnyCPU\html using com interop\pdf-image-annotation.html.
Clicking the button added a rectangleHighlighter annotation to the image.
Pasted the code to create the annotation to a webform in the dummy asp.net project.
It gave "Automation server can't create object" error.
Added samples\AnyCPU\html using com interop\pdf-image-annotation.html file to the dummy asp.net project.
Made the html as the startup page and ran.
It gave "Automation server can't create object" error
Please advice.
Regards
Jey
The issue with the version number (8.5.0.5) shown in the registry was due to an old Web runtime.
1. Uninstalled GdPicture and Web runtime.
2. Installed the latest GdPicture (8.5.0.24) and the latest Web runtime.
The version number is shown properly in the registry.
Still had the same problem with "new ActiveXObject("GdPicture.AnnotationManager").
Ran Redist\Com Interop\GdPictureComReg.exe.
Ran Redist\Com Interop\_Register for Com.bat
Added a button and the code to create the annotation to samples\AnyCPU\html using com interop\pdf-image-annotation.html.
Clicking the button added a rectangleHighlighter annotation to the image.
Pasted the code to create the annotation to a webform in the dummy asp.net project.
It gave "Automation server can't create object" error.
Added samples\AnyCPU\html using com interop\pdf-image-annotation.html file to the dummy asp.net project.
Made the html as the startup page and ran.
It gave "Automation server can't create object" error
Please advice.
Regards
Jey
Re: Accessing AnnotationManager methods in javascript
Hello Jey,
Please could you reproduce the problem in a very small standalone application ?
The code I provided you is very basic and should work if you use the script in javascript client/side on a machine with the GdPicture.NET web runtime installed.
Kind regards,
Loïc
Please could you reproduce the problem in a very small standalone application ?
The code I provided you is very basic and should work if you use the script in javascript client/side on a machine with the GdPicture.NET web runtime installed.
Kind regards,
Loïc
Re: Accessing AnnotationManager methods in javascript
Hi Loïc
The code below is just a stripped-down version of the html sample with your code to add the annotation.
The error message is :
Line : 92
Error: Automation server can't create object
If you need anything else, please specify.
Thanks a lot for the support.
Regards
Jeyaraman
The code below is just a stripped-down version of the html sample with your code to add the annotation.
Code: Select all
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>GdPicture:: Online Document Annotation Demo</title>
<script type="text/javascript" language="javascript">
var m_NativeImage = 0;
var m_GdPictureImaging;
var m_LicenseManager;
function InitGdPicture() {
var gdPictureLoaded = true;
var gdPictureVersionOK = true;
try {
m_LicenseManager = new ActiveXObject("GdPicture.LicenseManager");
m_GdPictureImaging = new ActiveXObject("GdPicture.GdPictureImaging");
if (m_LicenseManager.GetVersion() < 8.5) {
gdPictureVersionOK = false;
}
gdPictureLoaded = true;
}
catch (err) {
gdPictureLoaded = false;
}
if (!gdPictureLoaded) {
DisplayAlert('AlertBox');
}
else {
if (!gdPictureVersionOK) {
DisplayAlert('AlertBox2');
}
}
}
function unlockGdPicture() {
m_LicenseManager.RegisterKey("XXX"); //Please replace XXX by a valid demo or commercial KEY.
}
function closeDocument() {
var oGdViewer = document.getElementById("GdViewer1");
// var oThumbnailEx = document.getElementById("ThumbnailEx1");
oGdViewer.CloseDocument();
// oThumbnailEx.ClearAllitems();
oGdViewer.DocumentAlignment = 6;
oGdViewer.ZoomMode = 3;
if (m_NativeImage != 0) {
m_GdPictureImaging.ReleaseGdPictureImage(m_NativeImage);
m_NativeImage = 0;
}
}
function onDocumentLoaded() {
var oGdViewer = document.getElementById("GdViewer1");
// var oThumbnailEx = document.getElementById("ThumbnailEx1");
// var oBookmarkTree = document.getElementById("BookmarkTree1");
// var oAnnotationEditor = document.getElementById("AnnotationEditor1");
// oThumbnailEx.LoadFromGdViewer(oGdViewer.GetObject())
// oAnnotationEditor.GdViewer = oGdViewer.GetObject();
// oBookmarkTree.GdViewer = oGdViewer.GetObject();
}
function openFile() {
unlockGdPicture();
closeDocument();
var oGdViewer = document.getElementById("GdViewer1");
oGdViewer.DisplayFromFile("");
onDocumentLoaded();
}
</script>
<script type="text/javascript">
function DisplayAlert(id) {
document.getElementById(id).style.display = 'block';
}
</script>
<script type="text/javascript">
function addAnnot()
{
var oGdViewer = document.getElementById("GdViewer1");
var annot = new ActiveXObject("GdPicture.AnnotationManager");
annot.InitFromGdViewer(oGdViewer.GetObject());
annot.AddRectangleHighlighterAnnot(oGdViewer.ARGBI(255, 255, 255, 0), 1, 3, 3, 1);
alert('Annotation created...');
}
</script>
</head>
<body onload="InitGdPicture();">
<div class="viewer">
<object id="GdViewer1" type="application/x-oleobject" classid="CLSID:942B6C88-8765-4D7C-BF6A-FF48B4B56D04" width="300px" height="300px">
<param name="BackColor" value="#e5e5e5"/>
<param name="ZoomMode" value="2"/>
<param name="AllowDropFile" value="true"/>
Please enable ActiveX to see this GdPicture Object </object>
</div>
<button type ="button" onclick="openFile();">Load image</button>
<button type ="button" onclick="addAnnot();">Add annotation</button>
<form id="form1" runat="server">
<div>
</div>
</form>
</body>
</html>
Line : 92
Error: Automation server can't create object
If you need anything else, please specify.
Thanks a lot for the support.
Regards
Jeyaraman
Re: Accessing AnnotationManager methods in javascript
Hello,
Your sample works fine from my end and in all our virtual machines...
Again, I can only suggest to to check you've correctly installed the latest GdPicture.NET web runtime on the computer in which you are running the script. I can't see any other reason for the failure.
Kind regards,
Loïc
Your sample works fine from my end and in all our virtual machines...
Again, I can only suggest to to check you've correctly installed the latest GdPicture.NET web runtime on the computer in which you are running the script. I can't see any other reason for the failure.
Kind regards,
Loïc
-
- Posts: 2
- Joined: Fri May 11, 2012 4:02 am
Re: Accessing AnnotationManager methods in javascript
hi jeyaram,
Please enable the options at active x controls in tools-->InternetOptions-->Security-->custom level.This may cleanup error "Automation server can't create object"
Please enable the options at active x controls in tools-->InternetOptions-->Security-->custom level.This may cleanup error "Automation server can't create object"
Who is online
Users browsing this forum: No registered users and 1 guest