Using the Equation Composer and Document Composer with ASP.NET

The information on this page applies to:
MathFlow SDK 1.x and 2.xASP.NET

This document describes how to use the MathFlow SDK Equation Composer within an ASP.NET environment. The same lessons learned here can be applied to the Document Composer.

The MathFlow SDK includes DLL libraries for the Equation and Document Composers. In this example, we'll show how to use the Equation Composer in a simple ASP.NET website.

You will need Microsoft Visual Studio .NET 2005 with a correctly configured web server such as IIS in order to run this example. You will also need basic familiarity with Visual Basic, but the example can be refactored into any .NET language.

The EquationComposer.dll exposes a MathFlowSDK.EquationComposer COM object that provides COM clients with a way of generating images from MathML. In order to make use of the EquationComposer object, the EquationComposer.dll must first be registered. From a command prompt or the Run dialog, issue the following command:

regsvr32 <path to EquationComposer.dll>

A dialog box will display indicating that the registration was successful. Once registered, the EquationComposer can be instantiated just like any other COM object.

  1. Create a new ASP.net VS 2005 project.
    1. Open Visual Studio .NET 2005
    2. Choose File → New → Web Site
    3. Select "ASP.NET Web Site"
    4. Choose a location
    5. Choose a language (this example uses Visual Basic)
  2. Include the DLL into the project
    1. In the Solution Explorer, select the "Developer Web Server" object just below the "solution". This looks something like this:
      tsn009a.jpg
    2. Right click the "Developer Web Server" object and select "Add Reference…" from the contextual menu. This will bring up a dialog that looks like this:
      tsn009b.jpg
    3. Switch to the COM tab and select the "MathFlowSDK EquationComposer 1.0 Type Library" and click OK.
  3. Insert a button into the default web page that will execute the EquationComposer
    1. Open the default web page that appears in the project (Default.aspx).
    2. Go to the View menu and choose Designer to enter Design View.
    3. Click on the toolbox button tsn009c.jpg to allow you to drag a Button onto your page.
    4. Double click on the button.
  4. Insert code into the Button1_Click subroutine. Since this is Visual Basic code, type in the following, changing the paths to those of your preference:
    The Visual Basic code block.
  5. Run the example
    1. Click on the start debugging button.
    2. In the resulting web page click on the button.
  6. Check for an image
    1. If all went well, there is an image called "asptest.png" sitting in the location you specified using the SetImageFolder() command. In real life you would obviously do something with the image, such as display it to the user, or store it somewhere.


""

We hope this has been helpful. As always, please let us know if you have questions about this, or if you have additional techniques that work. We'd love to hear from you.