Using the Equation Composer and Document Composer with ASP.NET
Applicability
The information on this page applies to: | |
---|---|
MathFlow SDK 1.x and 2.x | ASP.NET |
Summary
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.
Overview
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.
Requirements
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
Create a new ASP.net VS 2005 project.
Open Visual Studio .NET 2005
Choose File → New → Web Site
Select "ASP.NET Web Site"
Choose a location
Choose a language (this example uses Visual Basic)
Include the DLL into the project
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="http://www.w3.org/1998/Math/MathML"><mi>x</mi></math></html>") iw.SetImageFolder("C:\Program Files\MathFlow SDK\2.0\windows\samples") iw.SetImageName("asptest") iw.SetImageType("png") iw.GenerateImageFile()
Run the example
Click on the start debugging button.
In the resulting web page click on the button.
Check for an image
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.