Accessing AnnotationManager methods in javascript

Discussions about GdPicture.NET usage in non managed applications built in vb6, Delphi, vfp, MFC c++ etc...
Post Reply
jeyaramg
Posts: 7
Joined: Fri Apr 06, 2012 3:04 pm

Accessing AnnotationManager methods in javascript

Post by jeyaramg » Fri Apr 06, 2012 3:24 pm

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

User avatar
Loïc
Site Admin
Posts: 5526
Joined: Tue Oct 17, 2006 10:48 pm
Location: France
Contact:

Re: Accessing AnnotationManager methods in javascript

Post by Loïc » Sun Apr 08, 2012 12:44 pm

Hello,

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);
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

jeyaramg
Posts: 7
Joined: Fri Apr 06, 2012 3:04 pm

Re: Accessing AnnotationManager methods in javascript

Post by jeyaramg » Mon Apr 09, 2012 7:36 am

Hi

Thanks for the response.
I will wait for 8.5.24.

Regards
Jeyaraman

User avatar
Loïc
Site Admin
Posts: 5526
Joined: Tue Oct 17, 2006 10:48 pm
Location: France
Contact:

Re: Accessing AnnotationManager methods in javascript

Post by Loïc » Mon Apr 09, 2012 5:17 pm

Hello Jey,

The new release is available. See: http://www.gdpicture.com/download.php

Kind regards,

Loïc

jeyaramg
Posts: 7
Joined: Fri Apr 06, 2012 3:04 pm

Re: Accessing AnnotationManager methods in javascript

Post by jeyaramg » Tue Apr 10, 2012 9:25 am

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

User avatar
Loïc
Site Admin
Posts: 5526
Joined: Tue Oct 17, 2006 10:48 pm
Location: France
Contact:

Re: Accessing AnnotationManager methods in javascript

Post by Loïc » Tue Apr 10, 2012 9:59 am

Hello Jey,

Please replace:

Code: Select all

GdPicture9.AnnotationManager
bu:

Code: Select all

GdPicture.AnnotationManager
Kind regards,

Loïc

jeyaramg
Posts: 7
Joined: Fri Apr 06, 2012 3:04 pm

Re: Accessing AnnotationManager methods in javascript

Post by jeyaramg » Tue Apr 10, 2012 10:42 am

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

User avatar
Loïc
Site Admin
Posts: 5526
Joined: Tue Oct 17, 2006 10:48 pm
Location: France
Contact:

Re: Accessing AnnotationManager methods in javascript

Post by Loïc » Tue Apr 10, 2012 10:49 am

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".
This is the problem. Now you have to find a way to update your project to use the latest 8.5.0.24 assembly.

Kind regards,

Loïc

jeyaramg
Posts: 7
Joined: Fri Apr 06, 2012 3:04 pm

Re: Accessing AnnotationManager methods in javascript

Post by jeyaramg » Wed Apr 11, 2012 6:54 am

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. :D

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

User avatar
Loïc
Site Admin
Posts: 5526
Joined: Tue Oct 17, 2006 10:48 pm
Location: France
Contact:

Re: Accessing AnnotationManager methods in javascript

Post by Loïc » Wed Apr 11, 2012 11:52 am

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

jeyaramg
Posts: 7
Joined: Fri Apr 06, 2012 3:04 pm

Re: Accessing AnnotationManager methods in javascript

Post by jeyaramg » Thu Apr 12, 2012 10:22 am

Hi Loïc

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>

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

User avatar
Loïc
Site Admin
Posts: 5526
Joined: Tue Oct 17, 2006 10:48 pm
Location: France
Contact:

Re: Accessing AnnotationManager methods in javascript

Post by Loïc » Thu Apr 12, 2012 10:59 am

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

rajabide4u
Posts: 2
Joined: Fri May 11, 2012 4:02 am

Re: Accessing AnnotationManager methods in javascript

Post by rajabide4u » Fri May 11, 2012 4:27 am

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"

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest