×

Services APIs

Index of services


Rendering images

MathType can generate images of math equations from Presentation MathML, Content MathML or LaTeX and export them to PNG, SVG, SWF, PDF and EPS.

Web service

http://domain/context-path/render

GET and POST parameters:

  • mml: Presentation MathML or Content MathML that represents the formula. 

  • latex: LaTeX code that represents the formula. 

  • format: format of the image. Allowed values are png, swf, svg, pdf and eps. If not specified, png is used. 

  • Parameters from this list

 

Examples:

Alternative services:

http://domain/context-path/render.png
http://domain/context-path/render.swf
http://domain/context-path/render.svg
http://domain/context-path/render.eps
http://domain/context-path/render.pdf

When calling to render.png, render.swf, render.svg, render.eps or render.pdf instead of render, format parameter is taken as png, swf, svg, eps or pdf respectively.

Java

Detailed information is available in the reference page:

Example:

Properties p = new Properties();
p.setProperty("color", "red");
Properties out = new Properties();
byte[] imageBytes = PublicServices.getInstance().renderPng(null, "2-x", p, out);
int width = Integer.parseInt(out.getProperty("width"));

.NET

Detailed information is available in the reference page (although the documentation itself is a Javadoc):

 

Example:

Dictionary<string, string> p = new Dictionary<string, string>();
p["color"] = "red";
Dictionary<string, string> out = new Dictionary<string, string>();
byte[] imageBytes = PublicServices.getInstance().renderPng(null, "2-x", p, out);
int width = int.Parse(out["width"]);

 


LaTeX to MathMLLaTex logo

MathType provides a service to convert LaTeX code into Presentation MathML. The list of LaTeX commands currently supported by MathType, with examples, can be found here.

Web service

http://domain/context-path/latex2mathml

 

GET and POST parameters:

  • latex: LaTeX code that represents the formula. 

  • saveLatex: if defined, the LaTeX code is stored inside the result MathML as an annotation. 

  • grammar: the URL of the transformation grammar used to convert from LaTeX to MathML. If not specified, the default grammar is used. 

 

Examples:

Java

Detailed information is available in the reference page:

 

Example:

String mathml = PublicServices.getInstance().latex2mathml("2-x", false, null);

Result:

<math xmlns="http://www.w3.org/1998/Math/MathML"><mn>2</mn><mo>-</mo><mi>x</mi></math>

.NET

Detailed information is available in the reference page (although the documentation itself is a Javadoc):

 

Example:

string mathml = PublicServices.getInstance().latex2mathml("2-x", false, null);

Result:

<math xmlns="http://www.w3.org/1998/Math/MathML"><mn>2</mn><mo>-</mo><mi>x</mi></math>


MathML to LaTeX

MathType provides a service to convert Presentation MathML into LaTeX code. The list of LaTeX commands currently supported by MathType, with examples, can be found here.

Web service

http://domain/context-path/mathml2latex

 

GET and POST parameters:

  • mml: Presentation MathML that represents the formula. 

  • saveMathML: if defined, the MathML is stored inside the result LaTeX code as a comment. 

  • grammar: the URL of the transformation grammar used to convert from MathML to LaTeX. If not specified, the default grammar is used. 

 

Examples:

Java

Detailed information is available in the reference page:

 

Example:

String latex = PublicServices.getInstance().mathml2latex("<math><mn>2</mn><mo>-</mo><mi>x</mi></math>", false, null);

Result:

2-x

.NET

Detailed information is available in the reference page (although the documentation itself is a Javadoc):

 

Example:

String latex = PublicServices.getInstance().mathml2latex("<math><mn>2</mn><mo>-</mo><mi>x</mi></math>", false, null);

Result:

2-x


Content MathML to Presentation MathML

MathType provides a service to convert Content MathML into Presentation MathML. The list of Content MathML tags currently supported by MathType can be found here.

Web service

http://domain/context-path/content2mathml

 

GET and POST parameters:

  • mml: Content MathML that represents the formula. 

  • grammar: the URL of the transformation grammar used to convert from Content MathML to Presentation MathML. If not specified, the default grammar is used. 

 

Examples:

Java

Detailed information is available in the reference page:

 

Example:

String mathml = PublicServices.getInstance().content2mathml("<math><apply><minus></minus><cn>2</cn><ci>x</ci></apply></math>", null);

Result:

<math><mn>2</mn><mo>-</mo><mi>x</mi></math>

.NET

Detailed information is available in the reference page (although the documentation itself is a Javadoc):

 

Example:


string mathml = PublicServices.getInstance().content2mathml("<math><apply><minus></minus><cn>2</cn><ci>x</ci></apply></math>", null);

Result:

<math><mn>2</mn><mo>-</mo><mi>x</mi></math>


 

Presentation MathML to Content MathML

MathType provides a service to convert Presentation MathML into Content MathML. The list of Content MathML tags currently supported by MathTypecan be found here.

Web service

http://domain/context-path/mathml2content

 

GET and POST parameters:

  • mml: Presentation MathML that represents the formula. 

  • grammar: the URL of the transformation grammar used to convert from Presentation MathML to Content MathML. If not specified, the default grammar is used. 

 

Examples:

Java

Detailed information is available in the reference page:

 

Example:

String mathml = PublicServices.getInstance().mathml2content <math><mn>2</mn><mo>-</mo><mi>x</mi></math> ", null);

Result:

<math><apply><minus></minus><cn>2</cn><ci>x</ci></apply></math>

.NET

Detailed information is available in the reference page (although the documentation itself is a Javadoc):

 

Example:

string mathml = PublicServices.getInstance().mathml2content <math><mn>2</mn><mo>-</mo><mi>x</mi></math> ", null);

Result:

<math><apply><minus></minus><cn>2</cn><ci>x</ci></apply></math>


Accessible text to MathML

Accesibility in WIRIS EDITOR

MathType provides a service to convert accessible textual representations into Presentation MathML.

Web service

http://domain/context-path/accessible2mathml

 

GET and POST parameters:

  • accessible: text represents the formula. 

  • lang: language code in ISO 639 format (“en”, “es”, etc). 

 

Examples:

Java

Detailed information is available in the reference page:

 

Example:

String mathml = PublicServices.getInstance().accessible2mathml("2 minus x", "en", null);

Result:

<math xmlns="http://www.w3.org/1998/Math/MathML"><mn>2</mn><mo>-</mo><mi>x</mi></math>

.NET

Detailed information is available in the reference page (although the documentation itself is a Javadoc):

 

Example:

string mathml = PublicServices.getInstance().accessible2mathml("2 minus x", "en", null);

Result:

<math xmlns="http://www.w3.org/1998/Math/MathML"><mn>2</mn><mo>-</mo><mi>x</mi></math>


MathML to accessible text

MathType provides a service to convert Presentation MathML into accessible text.

Web service

http://domain/context-path/mathml2accessible

 

GET and POST parameters:

  • mml: Presentation MathML that represents the formula. 

  • lang: language code in ISO 639 format (“en”, “es”, etc). 

 

Examples:

Java

Detailed information is available in the reference page:

 

Example:

String accessible = PublicServices.getInstance().mathml2accessible("<math><mn>2</mn><mo>-</mo><mi>x</mi></math>", "en", null);

Result:

2 minus x

.NET

Detailed information is available in the reference page (although the documentation itself is a Javadoc):

 

Example:

string accessible = PublicServices.getInstance().mathml2accessible("<math><mn>2</mn><mo>-</mo><mi>x</mi></math>", "en", null);

Result:

2 minus x


Evaluating formulas

MathType can evaluate Presentation MathML or Content MathML to a floating point value. It admits a list of variable values that will be replaced before the evaluation. There is more information about this feature here.

The list of Content MathML tags currently supported by MathType can be found here.

Web service

http://domain/context-path/evaluate

 

GET and POST parameters:

  • mml: Presentation MathML or Content MathML that represents the formula. 

  • Parameters starting with “var_”, to define variable values. Example: “var_x=4.5”. 

 

Examples:

Java

Detailed information is available in the reference page:

 

Example:

Properties variables = new Properties();
variables.setProperty("x", "4.5");
double result = PublicServices.getInstance().evaluate("<math><mn>2</mn><mo>-</mo><mi>x</mi></math>", variables, null);

Result:

-2.5

.NET

Detailed information is available in the reference page (although the documentation itself is a Javadoc):

 

Example:

Dictionary<string, string> variables = new Dictionary<string, string>();
variables["x"] = "4.5";
double result = PublicServices.getInstance().evaluate("<math><mn>2</mn><mo>-</mo><mi>x</mi></math>", variables, null);

Result:

-2.5


Comparing formulas

MathType provides a service to compare two formulas and retrieve a third one with the differences between them marked.

One of the formulas to compare will be the 'before' or 'old' formula, while the other one will be the 'after' or 'new' formula. The service will return a new formula comprised of a combination of the two: parts that can be found in the 'old' formula but not in the 'new' will be highlighted in red, while those that weren't in 'old' but are in 'new' will be marked in a green background.

Web service

http://domain/context-path/compare

 

This service is only available via POST.

POST parameters:

  • before: first formula to compare.
  • after: second formula to compare.
  • format: indicates the format that the 'before' and 'after' formulas are in. Only 'mathml' is available, and it defaults to it if it's not specified.

Example:

Given the following parameters:

before = <math><mroot><mfrac><mn>1</mn><mrow><mi>x</mi><mo>+</mo><mi>y</mi></mrow></mfrac><mn>2</mn></mroot></math>
after = <math><mroot><mfrac><mn>1</mn><mrow><mn>2</mn><mi>&#x3C0;</mi></mrow></mfrac><mn>3</mn></mroot></math>

the service should return the following MathML:

<math xmlns="http://www.w3.org/1998/Math/MathML"><mroot><mfrac><mn>1</mn><mrow>
<mstyle mathbackground="#F0D6D6"><mi>x</mi></mstyle><mstyle mathbackground="#F0D6D6"><mo>+</mo></mstyle>
<mstyle mathbackground="#F0D6D6"><mi>y</mi></mstyle><mstyle mathbackground="#D5EACD"><mn>2</mn></mstyle>
<mstyle mathbackground="#D5EACD"><mi>&#x3C0;</mi></mstyle></mrow></mfrac><mrow>
<mstyle mathbackground="#F0D6D6"><mn>2</mn></mstyle><mstyle mathbackground="#D5EACD"><mn>3</mn></mstyle>
</mrow></mroot></math>

which, when rendered, will look like this:

Java

Currently not available.

.NET

Currently not available.


Error handling

New in v3.19

All services now accept this request paramenter:

  • httpstatus: If true then the service will return HTTP status code 5xx on error. Otherwise, if not defined or false, the service does not label errors; always returns HTTP status code 200.