Skip to main content

Using the Equation Composer and Document Composer with ASP.NET


The information on this page applies to:

MathFlow SDK 1.x and 2.x



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.

Registering the DLL

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.

Setting Up and Running the Example

  1. Create a new 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:

  - 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:
  - Switch to the COM tab and select the "MathFlowSDK EquationComposer 1.0 Type Library" and click OK.
- Insert a button into the default web page that will execute the EquationComposer 
  - Open the default web page that appears in the project (Default.aspx).
  - Go to the View menu and choose Designer to enter Design View.
  - Click on the toolbox button {{mftsn009:tsn009c.jpg?32x28}} to allow you to drag a Button onto your page.
  - Double click on the button.
- 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:
Dim iw As EquationComposerLib.EquationComposer
iw = New EquationComposerLib.EquationComposer
iw.SetLicense("C:\Program Files\MathFlow SDK\2.0\windows\samples\dessci.lic")
iw.SetMathML("<html><math xmlns=""><mi>x</mi></math></html>")

iw.SetImageFolder("C:\Program Files\MathFlow SDK\2.0\windows\samples")
  1. Run the example

    1. Click on the start debugging button.

    2. In the resulting web page click on the button.

  2. 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.