Stud.IP  2.0 Revision 48548
 All Data Structures Namespaces Files Functions Variables Pages
LatexRender Class Reference
Collaboration diagram for LatexRender:
Collaboration graph

Public Member Functions

 LatexRender ($picture_path, $picture_path_httpd, $format="math")
 getErrorString ()
 setFormat ($format, $template)
 setPicturePath ($name)
 getPicturePath ()
 setPicturePathHTTPD ($name)
 getPicturePathHTTPD ()
 getFormulaURL ($latex_formula)
 wrap_latex ($latex_text)
 getDimensions ($filename)
 renderLatex ($latex_text)
 cleanTemporaryDirectory ()

Data Fields

 $_picture_path = ""
 $_picture_path_httpd = ""
 $_tmp_dir = "/tmp"
 $_latex_path = "/usr/bin/latex"
 $_dvips_path = "/usr/bin/dvips"
 $_convert_path = "/usr/bin/convert"
 $_identify_path = "/usr/bin/identify"
 $_formula_density = 120
 $_xsize_limit = 1024
 $_ysize_limit = 700
 $_tmp_filename
 $_format = ''
 $_template = ''
 $_latex_tags_blacklist
 $_err_string = ''

Member Function Documentation

cleanTemporaryDirectory ( )

Cleans the temporary directory

getDimensions (   $filename)

/** returns the dimensions of a picture file using 'identify' of the imagemagick tools. The resulting array can be adressed with either $dim[0] / $dim[1] or $dim["x"] / $dim["y"]

Parameters
stringpath to a picture
Returns
array containing the picture dimensions
getErrorString ( )
getFormulaURL (   $latex_formula)

Tries to match the LaTeX Formula given as argument against the formula cache. If the picture has not been rendered before, it'll try to render the formula and drop it in the picture cache directory.

Parameters
stringformula in LaTeX format
Returns
the webserver based URL to a picture in PNG format which contains the requested LaTeX formula. If anything fails, the resultvalue is false.

Here is the call graph for this function:

getPicturePath ( )

Picture path Mutator function

Returns
the current picture path

Here is the caller graph for this function:

getPicturePathHTTPD ( )

Picture path HTTPD Mutator function

Returns
the current picture path

Here is the caller graph for this function:

LatexRender (   $picture_path,
  $picture_path_httpd,
  $format = "math" 
)

Initializes the class

Parameters
stringpath where the rendered pictures should be stored
stringsame path, but from the httpd chroot
renderLatex (   $latex_text)

Renders a LaTeX formula by the using the following method:

  • write the formula into a wrapped tex-file in a temporary directory and change to it
  • Create a DVI file using latex (tetex)
  • Convert DVI file to Postscript (PS) using dvips (tetex)
  • convert, trim and add transparancy by using 'convert' from the imagemagick package.
  • Save the resulting image to the picture cache directory using an md5 hash as filename. Already rendered formulas can be found directly this way.
Parameters
stringLaTeX formula
Returns
true if the picture has been successfully saved to the picture cache directory

Here is the caller graph for this function:

setFormat (   $format,
  $template 
)

Format mutator function

Parameters
stringsets the current format
setPicturePath (   $name)

Picture path Mutator function

Parameters
stringsets the current picture path to a new location
setPicturePathHTTPD (   $name)

Picture path HTTPD Mutator function

Parameters
stringsets the current httpd picture path to a new location
wrap_latex (   $latex_text)

wraps a minimalistic LaTeX document around the formula and returns a string containing the whole document as string. Customize if you want other fonts for example.

Parameters
stringformula in LaTeX format
Returns
minimalistic LaTeX document containing the given formula

Field Documentation

$_convert_path = "/usr/bin/convert"
$_dvips_path = "/usr/bin/dvips"
$_err_string = ''
$_format = ''
$_formula_density = 120
$_identify_path = "/usr/bin/identify"
$_latex_path = "/usr/bin/latex"
$_latex_tags_blacklist
Initial value:
array(
"include","def","command","loop","repeat","open","toks","output","input",
"catcode","mathcode","name","item","section","%","^^","\$\$","mbox","csname","newhelp","makeatletter"
)
$_picture_path = ""
$_picture_path_httpd = ""
$_template = ''
$_tmp_dir = "/tmp"
$_tmp_filename
$_xsize_limit = 1024
$_ysize_limit = 700

The documentation for this class was generated from the following file: