CHIMERA SPEAK

A Chimera Newsletter



Newsletter, Feb 2009

Creating Corel Plug-ins and Integrating with a Web Service


This article describes how a Corel Plug-in could be developed to integrate with a Web Service.


We all know that Corel draw is a designer tool. But, many of us see Corel as only a designer tool. This article would give you an insight on how Corel can also be used to interact with a webservice to manage information in a database.


In print design houses, it is a usual practice to have the designers work with CorelDraw most of the time. If their designs are to be centrally managed, with integration to a backend design repository system or a digital asset management system, it is important that Corel be enhanced to provide additional features directly from inside it (like having additional menus/toolbars etc). This enhances productivity, providing a single window interface to design and manage (including approvals and other workflows).



We were faced with one such need and this article describes the nuances of this implementation from the technology perspective.

I assume the reader is familiar with GSM files for Corel. If not please have a primer at http://www.oberonplace.com/vba/newgms.htm.


Who will act as a bridge between Corel and database?


Visual Basic for Applications (VBA) will act as a bridge between the Corel to the enterprise platforms. Create a vb.net windows application which would have functions to carry the information from Corel to database. There is no direct way of calling a web service from Corel draw.


As a workaround, add a reference to the webservice in the dot net dll. If the webservice reference needs to be dynamic, place it in an xml file inside the “Draw” or anywhere inside the default location where CorelDraw is installed. In order to utilize the dot net dll in the Corel application, the dll has to be registered in the system where the Corel draw is installed.


How to register the dot net DLL


For CorelDraw to use the dot net dll, it has to be registered in the system running CorelDraw. To register the dot net dll, we need to use the Assembly registration tool (Regasm.exe). Once, registered, using VBA we can reference the dot net dll and call the methods used in the dot net dll to get and put values in the database.


What is an Assembly Registration Tool and why it is needed (Regasm.exe)


The Assembly Registration tool reads the metadata within an assembly and adds the necessary entries to the registry, which allows COM clients to create .NET Framework classes transparently. Once a class is registered, any COM client can use it as though the class were a COM class. The class is registered only once, when the assembly is installed. Instances of classes within the assembly cannot be created from COM until they are actually registered.


Source: http://msdn.microsoft.com/en-us/library/tzat5yw6(VS.71).aspx
Syntax: Regasm /codebase pathofthedllfile /tlb:dllfilename.tlb 
Tlb -> type library

Creating Customized Forms


Once, the dot net dll is registered and a new GMS is created using the VBA editor, we need to start creating the forms which would get the information from the user and store in to the database using the methods exposed by dot net dll. Global methods and functions which can be used by all forms should be written inside the Global macros.gms file.

Some of the customized Features

We can create a new command bar in the Corel and add command bar and add our own commands (icons) which acts as a plug-in and can be displayed separately in the tool bar section. For ex: New, open, save, Orientation, Rotation etc. Even if these functionalities are already available, the challenge is to restrict the user not to update it in our customized Corel document.

Some of the following features were successfully implemented using the above architecture:


  • Allowing only authorized used to access the custom functionalities
  • Creating customized plug-in for Corel
  • Creating meta tags to store crucial information in the Corel document (that would eventually be used by our enterprise platform )
  • Custom functions to add tags to each field in the corel document.
  • Changing the orientation of the document, rotation by angle, adding additional fonts to the document
  • Saving a svg file and the working document using webservice methods, with the similar text alignments used in the Corel document.