Jump to:
navigation,
search
HotSpotting (Plugin)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Overview
This Plugin is designed to enable the work with HotSpots and Annotations on the server side.
Usage
The Plugin exposes several methods through the classes Annotating and "HotSpotting" that can be used in UBIK® customizing code.
[edit]
- Annotating (write annotation to revision)
- Annotating (write annotation to original document)
- HotSpotting
- Annotating (old API)
Annotating (write annotation to revision)
Example script for the UBIK® Whobert that shows the basic capabilities of the Plugin.
using System;
using System.Windows.Forms;
using UBIK.Kernel;
using UBIK.Compiler;
using System.Linq;
using UBIK.Module.HotSpotting.Module;
using UBIK.WinX.HotSpotting.Models;
using UBIK.WinX.HotSpotting.Common;
namespace Studio
{
public class ObjectTest
{
public void TestObject (params BaseClass[] InVariables)
{
BaseClass obj = InVariables[0];
UBIK.Document.DocumentClass sourcedoc = obj.Environment.UBIKDataFactory().ContentObject(new Guid("a847ab9f-1e4c-42ed-933f-833fb8d69b5e")) as UBIK.Document.DocumentClass;
// create an instance of the Annotated Document wrapper
UBIK.Module.Annotation.AnnotatedDocument pdf = new UBIK.Module.Annotation.AnnotatedDocument(sourcedoc);
// optional you can set the relation name
pdf.SetRedlineRelationName("MY_RELATION_NAME");
UBIK.Document.DocumentClass revDoc;
// create a new revision and write annotations to pdf file
// True => clear annotations property afterwards
if (pdf.WriteAnnotationToRevisionDoc(true, out revDoc))
{
revDoc.Save(); // save revision document
pdf.Save(); // save original document with cleared annotations property
}
Debugger.Output(this, "*** Finished");
}
}
}
using System.Windows.Forms;
using UBIK.Kernel;
using UBIK.Compiler;
using System.Linq;
using UBIK.Module.HotSpotting.Module;
using UBIK.WinX.HotSpotting.Models;
using UBIK.WinX.HotSpotting.Common;
namespace Studio
{
public class ObjectTest
{
public void TestObject (params BaseClass[] InVariables)
{
BaseClass obj = InVariables[0];
UBIK.Document.DocumentClass sourcedoc = obj.Environment.UBIKDataFactory().ContentObject(new Guid("a847ab9f-1e4c-42ed-933f-833fb8d69b5e")) as UBIK.Document.DocumentClass;
// create an instance of the Annotated Document wrapper
UBIK.Module.Annotation.AnnotatedDocument pdf = new UBIK.Module.Annotation.AnnotatedDocument(sourcedoc);
// optional you can set the relation name
pdf.SetRedlineRelationName("MY_RELATION_NAME");
UBIK.Document.DocumentClass revDoc;
// create a new revision and write annotations to pdf file
// True => clear annotations property afterwards
if (pdf.WriteAnnotationToRevisionDoc(true, out revDoc))
{
revDoc.Save(); // save revision document
pdf.Save(); // save original document with cleared annotations property
}
Debugger.Output(this, "*** Finished");
}
}
}
Annotating (write annotation to original document)
Example script for the UBIK® Whobert that shows the basic capabilities of the Plugin.
using System;
using System.Windows.Forms;
using UBIK.Kernel;
using UBIK.Compiler;
using System.Linq;
using UBIK.Module.HotSpotting.Module;
using UBIK.WinX.HotSpotting.Models;
using UBIK.WinX.HotSpotting.Common;
namespace Studio
{
public class ObjectTest
{
public void TestObject (params BaseClass[] InVariables)
{
BaseClass obj = InVariables[0];
UBIK.Document.DocumentClass sourcedoc = obj.Environment.UBIKDataFactory().ContentObject(new Guid("a847ab9f-1e4c-42ed-933f-833fb8d69b5e")) as UBIK.Document.DocumentClass;
// create an instance of the Annotated Document wrapper
UBIK.Module.Annotation.AnnotatedDocument pdf = new UBIK.Module.Annotation.AnnotatedDocument(sourcedoc);
// write annotations to pdf file
// True => clear annotations property afterwards
pdf.WriteAnnotationToSourceDoc(true);
pdf.Save(); // save original document with cleared annotations property
Debugger.Output(this, "*** Finished");
}
}
}
using System.Windows.Forms;
using UBIK.Kernel;
using UBIK.Compiler;
using System.Linq;
using UBIK.Module.HotSpotting.Module;
using UBIK.WinX.HotSpotting.Models;
using UBIK.WinX.HotSpotting.Common;
namespace Studio
{
public class ObjectTest
{
public void TestObject (params BaseClass[] InVariables)
{
BaseClass obj = InVariables[0];
UBIK.Document.DocumentClass sourcedoc = obj.Environment.UBIKDataFactory().ContentObject(new Guid("a847ab9f-1e4c-42ed-933f-833fb8d69b5e")) as UBIK.Document.DocumentClass;
// create an instance of the Annotated Document wrapper
UBIK.Module.Annotation.AnnotatedDocument pdf = new UBIK.Module.Annotation.AnnotatedDocument(sourcedoc);
// write annotations to pdf file
// True => clear annotations property afterwards
pdf.WriteAnnotationToSourceDoc(true);
pdf.Save(); // save original document with cleared annotations property
Debugger.Output(this, "*** Finished");
}
}
}
HotSpotting
Example script for the UBIK® Whobert that shows the creation of LinkSpots (Cross-references) between documents.
using System;
using System.Windows.Forms;
using UBIK.Kernel;
using UBIK.Compiler;
using System.Linq;
using UBIK.Module.HotSpotting.Module;
using UBIK.WinX.HotSpotting.Models;
using UBIK.WinX.HotSpotting.Common;
namespace Studio
{
public class ObjectTest
{
public void TestObject (params BaseClass[] InVariables)
{
Debugger.Output(this, "*** Started");
//HotSpots with the same ID will be highlighted on the target
Guid sameID = Guid.NewGuid();
BaseClass obj = InVariables[0];
//Get our Source document
var sourcedoc = obj.Environment.UBIKDataFactory().ContentObject(new Guid("3451ed94-b8b2-4459-a7e9-60f041868294"));
var hotspotting = new HotSpotting();
//Create a new Layer
HotSpottingLayer sourcelayer = new HotSpottingLayer(null);
//Set the page of the document where the hs should appear
//ATTENTION: counting starts with 1 since this is already the natural page number
sourcelayer.Page = 1;
//Create a new LinkHotSpot
LinkHotSpot sourcehs = new LinkHotSpot(null)
{
//Position it on the document
X = 100,
Y = 100,
Width = 256,
Height = 256,
//Set its value to the UID of the target document
Value = new Guid("60ab6606-9de1-4f0c-ab15-f1dfc31f421c"),
//Set its ID to the same id as the target HotSpot
//which enables focussing and highlighting
ID = sameID,
//Assign a unique ID
UID = Guid.NewGuid(),
//Give it an optional label
Label = "TestLink",
//Give it a shape (default is round)
Shape = HotSpotShape.Angular
};
sourcelayer.AddHotSpot(sourcehs);
//Save the layer to the document
hotspotting.Save(sourcedoc, new HotSpottingLayer[] { sourcelayer });
//Save the document
sourcedoc.Save();
//If we only create the source HS, navigation is a one way street;
//if we want to navigate back we also need to create the other direction
//which means in this case, do the same but vice versa
HotSpottingLayer targetlayer = new HotSpottingLayer(null);
targetlayer.Page = 1;
var targetdoc = obj.Environment.UBIKDataFactory().ContentObject(new Guid("60ab6606-9de1-4f0c-ab15-f1dfc31f421c"));
LinkHotSpot targeths = new UBIK.WinX.HotSpotting.Models.LinkHotSpot(null)
{
X = 100,
Y = 100,
Width = 128,
Height = 128,
Value = new Guid("3451ed94-b8b2-4459-a7e9-60f041868294"),
ID = sameID,
UID = Guid.NewGuid(),
Label = "TestLinkBack",
Shape = HotSpotShape.Round
};
targetlayer.AddHotSpot(targeths);
hotspotting.Save(targetdoc, new HotSpottingLayer[] { targetlayer });
targetdoc.Save();
Debugger.Output(this, "*** Finished");
}
}
}
using System.Windows.Forms;
using UBIK.Kernel;
using UBIK.Compiler;
using System.Linq;
using UBIK.Module.HotSpotting.Module;
using UBIK.WinX.HotSpotting.Models;
using UBIK.WinX.HotSpotting.Common;
namespace Studio
{
public class ObjectTest
{
public void TestObject (params BaseClass[] InVariables)
{
Debugger.Output(this, "*** Started");
//HotSpots with the same ID will be highlighted on the target
Guid sameID = Guid.NewGuid();
BaseClass obj = InVariables[0];
//Get our Source document
var sourcedoc = obj.Environment.UBIKDataFactory().ContentObject(new Guid("3451ed94-b8b2-4459-a7e9-60f041868294"));
var hotspotting = new HotSpotting();
//Create a new Layer
HotSpottingLayer sourcelayer = new HotSpottingLayer(null);
//Set the page of the document where the hs should appear
//ATTENTION: counting starts with 1 since this is already the natural page number
sourcelayer.Page = 1;
//Create a new LinkHotSpot
LinkHotSpot sourcehs = new LinkHotSpot(null)
{
//Position it on the document
X = 100,
Y = 100,
Width = 256,
Height = 256,
//Set its value to the UID of the target document
Value = new Guid("60ab6606-9de1-4f0c-ab15-f1dfc31f421c"),
//Set its ID to the same id as the target HotSpot
//which enables focussing and highlighting
ID = sameID,
//Assign a unique ID
UID = Guid.NewGuid(),
//Give it an optional label
Label = "TestLink",
//Give it a shape (default is round)
Shape = HotSpotShape.Angular
};
sourcelayer.AddHotSpot(sourcehs);
//Save the layer to the document
hotspotting.Save(sourcedoc, new HotSpottingLayer[] { sourcelayer });
//Save the document
sourcedoc.Save();
//If we only create the source HS, navigation is a one way street;
//if we want to navigate back we also need to create the other direction
//which means in this case, do the same but vice versa
HotSpottingLayer targetlayer = new HotSpottingLayer(null);
targetlayer.Page = 1;
var targetdoc = obj.Environment.UBIKDataFactory().ContentObject(new Guid("60ab6606-9de1-4f0c-ab15-f1dfc31f421c"));
LinkHotSpot targeths = new UBIK.WinX.HotSpotting.Models.LinkHotSpot(null)
{
X = 100,
Y = 100,
Width = 128,
Height = 128,
Value = new Guid("3451ed94-b8b2-4459-a7e9-60f041868294"),
ID = sameID,
UID = Guid.NewGuid(),
Label = "TestLinkBack",
Shape = HotSpotShape.Round
};
targetlayer.AddHotSpot(targeths);
hotspotting.Save(targetdoc, new HotSpottingLayer[] { targetlayer });
targetdoc.Save();
Debugger.Output(this, "*** Finished");
}
}
}
Annotating (old API)
Example script for the UBIK® Whobert that shows the basic capabilities of the Plugin.
using System;
using System.Windows.Forms;
using UBIK.Kernel;
using UBIK.Compiler;
using System.Linq;
using UBIK.Module.HotSpotting.Module;
using UBIK.WinX.HotSpotting.Models;
using UBIK.WinX.HotSpotting.Common;
namespace Studio
{
public class ObjectTest
{
public void TestObject (params BaseClass[] InVariables)
{
BaseClass obj = InVariables[0];
UBIK.Document.DocumentClass sourcedoc = obj.Environment.UBIKDataFactory().ContentObject(new Guid("a847ab9f-1e4c-42ed-933f-833fb8d69b5e")) as UBIK.Document.DocumentClass;
var annotating = new Annotating();
//Load the Inking imformation from the UBIK document
InkingLayer[] ann = annotating.Load(sourcedoc);
//If we have an Image, merge trhe inking directly into the picture
if(annotating.GetAnnotationFileType(sourcedoc) == Annotating.AnnotationFileTypes.Image)
{
if(annotating.UpdateRedline(ann, sourcedoc))
{
annotating.Delete(sourcedoc);
//sourcedoc.MP_CREATE_PDF = false;
sourcedoc.Save();
}
}
//If we have a pdf, create a subdocument (redline) first and merge the inking into the version rather than the original
else if(annotating.GetAnnotationFileType(sourcedoc) == Annotating.AnnotationFileTypes.PdfDocument)
{
if(annotating.CreateRedline(ann, sourcedoc, "REL_FILEDOC_REDLINEDOC"))
{
//sourcedoc.MP_CREATE_PDF = false;
sourcedoc.Save();
}
}
Debugger.Output(this, "*** Finished");
}
}
}
using System.Windows.Forms;
using UBIK.Kernel;
using UBIK.Compiler;
using System.Linq;
using UBIK.Module.HotSpotting.Module;
using UBIK.WinX.HotSpotting.Models;
using UBIK.WinX.HotSpotting.Common;
namespace Studio
{
public class ObjectTest
{
public void TestObject (params BaseClass[] InVariables)
{
BaseClass obj = InVariables[0];
UBIK.Document.DocumentClass sourcedoc = obj.Environment.UBIKDataFactory().ContentObject(new Guid("a847ab9f-1e4c-42ed-933f-833fb8d69b5e")) as UBIK.Document.DocumentClass;
var annotating = new Annotating();
//Load the Inking imformation from the UBIK document
InkingLayer[] ann = annotating.Load(sourcedoc);
//If we have an Image, merge trhe inking directly into the picture
if(annotating.GetAnnotationFileType(sourcedoc) == Annotating.AnnotationFileTypes.Image)
{
if(annotating.UpdateRedline(ann, sourcedoc))
{
annotating.Delete(sourcedoc);
//sourcedoc.MP_CREATE_PDF = false;
sourcedoc.Save();
}
}
//If we have a pdf, create a subdocument (redline) first and merge the inking into the version rather than the original
else if(annotating.GetAnnotationFileType(sourcedoc) == Annotating.AnnotationFileTypes.PdfDocument)
{
if(annotating.CreateRedline(ann, sourcedoc, "REL_FILEDOC_REDLINEDOC"))
{
//sourcedoc.MP_CREATE_PDF = false;
sourcedoc.Save();
}
}
Debugger.Output(this, "*** Finished");
}
}
}