Skip to main content

Formula persistence

This article explains how MathType Integrations store formulas created with MathType

First of all let us note that there are two ways to store the formulas:

  1. Store a formula in full MathML.This is the default behavior of the MathType Integrations since version 2.50

  2. Store a formula as an IMG tag.

Both methods needs the "storage and cache" mecanism that stores files in the file system but that can be overriden following the instructions detailed here.

Storing the formulas with the IMG tag

Formulas mixed with HTML takes the form of:

alt="square root of 2"
data-mathml="&laquo;math xmlns=&uml;
   msqrt&raquo;&laquo;/math&raquo;" />

When the formula is displayed, thesrc part of the tag img tells what formula to display. The number, e0455f7f946668e0cdedb568a1025821 is called the digest and is used to recover the MathML and generate the image. The data-mathml is used only for reediting the formula.

Thus, MathType needs to store two kind of information in the server. By default, such information is stored in the file system:

  1. The inverse association <digest> to MathML. This information cannot be removed unless exists a mechanism that is able to regenerate them.

  2. A cache with the images generated from MathML. This cache can be removed if necessary and it will be regenerated when formulas are displayed.

Configuration of the storage mechanism

The easiest thing that can be configured are the folders where the images are stored. See MathType Integrations configuration table.

Additionally, you might want to change

  1. The algorithm used as the <digest> of a formula. For example, change from md5 to sha1, or use a key of a table in a relational database.

  2. The way the <digest> values are stored. For example, they could be stored in a relational database. The default behavior is use the file system.

  3. The way the images are stored. For example, they could be stored in a relational database. The default behavior is use the file system.

To provide your own implementation of the digest and cache mechanism, you will need to write a Java, .NET or PHP (depending on your server technology) class that implements the Then, change the key wirisstorageclass of the configuration.ini to point to your own class. See API documentation for a description of the interface and configuration table to learn how to change the configuration file.

Configuring the configuration. This topic is not covered by this article, but it is worth to mention that there is a similar way to provide a custom class that feeds the values of the configuration.

For Java technology

The value of wirisstorageclass is the fully qualified class name of your class. Then, the class should be available in the classpath of the servlet. For example,

All plugins for Java contains a wirisplugin-api.jar that can be used to compile your class.

For PHP technology

The value of the wirisstorageclass is the name of the PHP class


The new Storage Class should be placed under integration/lib directory and the file name should be the class name followed by .class.php extension.

For example if the new class is called TestStorageClass:

  • The value of wirisstorageclass key on configuration.ini file should be wirisstorageclass=TestStorageClass

  • The php file name should be TestStorageClass.class.php and should be placed under integration/lib folder.

For .NET technology

The value of the wirisstorageclass is the name assembly-qualified name of your class. For example:

  wirisstorageclass=<namespace>.MyStorageClass, <assembly-name>