com-tecnick-tcexam-shared
[ class tree: com-tecnick-tcexam-shared ] [ index: com-tecnick-tcexam-shared ] [ all elements ]

Class: LatexRender

Source Location: /shared/code/tce_latexrender.php

Class Overview


This is a PHP5 class for generating images from LaTeX Formulas.


Author(s):

  • Benjamin Zeiss, Nicola Asuni

Variables

Methods



Class Details

[line 44]
This is a PHP5 class for generating images from LaTeX Formulas.

This class is based on the following: LaTeX Rendering Class v0.8 (Licensed under GPL 2) Copyright (C) 2003 Benjamin Zeiss <zeiss@math.uni-goettingen.de> Currently the project is maintained by Steve Mayer. Please check the following Website to obtain the original source code: http://www.mayer.dial.pipex.com/tex.htm




Tags:

author:  Benjamin Zeiss, Nicola Asuni
abstract:  Class for generating images from LaTeX Formulas.
name:  LaTeX Render
license:  GPL


[ Top ]


Class Variables

$convert_path =  K_LATEX_PATH_CONVERT

[line 82]



Tags:

var:  to ImageMagick convert.
access:  protected

Type:   Path


[ Top ]

$dvips_path =  K_LATEX_PATH_DVIPS

[line 76]



Tags:

var:  to DVIPS.
access:  protected

Type:   Path


[ Top ]

$errorcode =  0

[line 150]



Tags:

var:  code.
access:  private

Type:   Error


[ Top ]

$font_size =  K_LATEX_FONT_SIZE

[line 118]



Tags:

var:  size.
access:  protected

Type:   Font


[ Top ]

$formula_density =  K_LATEX_FORMULA_DENSITY

[line 94]



Tags:

var:  density (used by ImageMagick)
access:  protected

Type:   Formula


[ Top ]

$height_limit =  K_LATEX_MAX_HEIGHT

[line 106]



Tags:

var:  height limit in pixels.
access:  protected

Type:   Image


[ Top ]

$identify_path =  K_LATEX_PATH_IDENTIFY

[line 88]



Tags:

var:  to ImageMagick identify.
access:  protected

Type:   Path


[ Top ]

$image_format =  K_LATEX_IMG_FORMAT

[line 136]



Tags:

var:  format (default = PNG).
access:  protected

Type:   Image


[ Top ]

$img_height =  0

[line 174]



Tags:

var:  height.
access:  private

Type:   Image


[ Top ]

$img_prefix =  K_LATEX_IMG_PREFIX

[line 130]



Tags:

var:  prefix for chached images.
access:  protected

Type:   Filename


[ Top ]

$img_width =  0

[line 168]



Tags:

var:  width.
access:  private

Type:   Image


[ Top ]

$latexclass =  K_LATEX_CLASS

[line 124]



Tags:

var:  class.
access:  protected

Type:   LaTeX


[ Top ]

$latex_formula =  ''

[line 162]



Tags:

var:  formula.
access:  private

Type:   Latex


[ Top ]

$latex_path =  K_LATEX_PATH_LATEX

[line 70]



Tags:

var:  to LATEX.
access:  protected

Type:   Path


[ Top ]

$latex_tags_blacklist = array('include', 'def', 'command', 'loop', 'repeat', 'open', 'toks', 'output', 'input', 'catcode', 'name', '^^', '\every', '\errhelp', '\errorstopmode', '\scrollmode', '\nonstopmode', '\batchmode', '\read', '\write', 'csname', '\newhelp', '\uppercase', '\lowercase', '\relax', '\aftergroup', '\afterassignment', '\expandafter', '\noexpand', '\special')

[line 142]



Tags:

var:  of unauthorized LaTeX commands.
access:  protected

Type:   list


[ Top ]

$picture_path =  K_LATEX_PATH_PICTURE

[line 52]



Tags:

var:  path to images directory.
access:  protected

Type:   Absolute


[ Top ]

$picture_path_httpd =  K_LATEX_PATH_PICTURE_HTTPD

[line 58]



Tags:

var:  path to images directory.
access:  protected

Type:   relative


[ Top ]

$string_length_limit =  K_LATEX_MAX_LENGHT

[line 112]



Tags:

var:  limit for input string.
access:  protected

Type:   Size


[ Top ]

$tmp_dir =  K_LATEX_TMP_DIR

[line 64]



Tags:

var:  to temporary directory.
access:  protected

Type:   Path


[ Top ]

$tmp_filename =  ''

[line 156]



Tags:

var:  filename.
access:  private

Type:   Temporary


[ Top ]

$width_limit =  K_LATEX_MAX_WIDTH

[line 100]



Tags:

var:  width limit in pixels.
access:  protected

Type:   Image


[ Top ]



Class Methods


constructor __construct [line 183]

LatexRender __construct( )

Class Constructor.



Tags:

access:  public


[ Top ]

destructor __destruct [line 190]

void __destruct( )

Default destructor.



Tags:

access:  public


[ Top ]

method checkImageDimensions [line 458]

array checkImageDimensions( string $filename)

Check the dimensions of a picture file using 'identify' of the ImageMagick tools.



Tags:

return:  containing the picture dimensions
access:  private


Parameters:

string   $filename   path to a picture

[ Top ]

method cleanTemporaryDirectory [line 439]

void cleanTemporaryDirectory( string $current_dir, [int $error_code = 0])

Removes temporary files.



Tags:

access:  private


Parameters:

string   $current_dir   current directory.
int   $error_code   error code.

[ Top ]

method getErrorCode [line 392]

int getErrorCode( )

Returns the error code



Tags:

return:  error code.
access:  public


[ Top ]

method getFilename [line 408]

minimalistic getFilename( string $latex_formula)

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.




Tags:

return:  LaTeX document containing the given formula
access:  private


Parameters:

string   $latex_formula   formula in LaTeX format

[ Top ]

method getFormulaURL [line 338]

the getFormulaURL( string $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.



Tags:

return:  webserver based URL to a picture which contains the requested LaTeX formula. If anything fails, the result value is false.
access:  public


Parameters:

string   $latex_formula   formula in LaTeX format

[ Top ]

method getImageHeight [line 384]

image getImageHeight( )

Returns Image height



Tags:

return:  height in pixels.
access:  public


[ Top ]

method getImageWidth [line 376]

image getImageWidth( )

Returns Image width



Tags:

return:  width in pixels.
access:  public


[ Top ]

method renderLatex [line 489]

true renderLatex( string $latex_formula)

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.




Tags:

return:  if the picture has been successfully saved to the picture cache directory
access:  private


Parameters:

string   $latex_formula   LaTeX formula

[ Top ]

method setFilenamePrefix [line 307]

void setFilenamePrefix( string $img_prefix)

Set filename prefix for chached images.



Tags:

access:  public


Parameters:

string   $img_prefix   filename prefix.

[ Top ]

method setFontSize [line 290]

void setFontSize( int $font_size)

Set font size.



Tags:

access:  public


Parameters:

int   $font_size   font size in points.

[ Top ]

method setFormulaDensity [line 258]

void setFormulaDensity( int $formula_density)

Set formula density (used by ImageMagick)



Tags:

access:  public


Parameters:

int   $formula_density   formula density.

[ Top ]

method setImageFormat [line 315]

void setImageFormat( string $image_format)

Set the image format (default = PNG).



Tags:

access:  public


Parameters:

string   $image_format   image format(e.g.: png).

[ Top ]

method setLatexBlackList [line 323]

void setLatexBlackList( array $latex_tags_blacklist)

Set the list of unauthorized LaTeX commands.



Tags:

access:  public


Parameters:

array   $latex_tags_blacklist   array of blacklisted commands.

[ Top ]

method setLatexClass [line 299]

void setLatexClass( string $latexclass)

Set LaTeX class.

Install extarticle class if you wish to have smaller font sizes.




Tags:

access:  public


Parameters:

string   $latexclass   LaTeX class.

[ Top ]

method setMaxHeight [line 274]

void setMaxHeight( string $height_limit)

Set image height limit in pixels.



Tags:

access:  public


Parameters:

string   $height_limit   Max image height in pixels.

[ Top ]

method setMaxLenght [line 282]

void setMaxLenght( string $string_length_limit)

Set size limit for input string.



Tags:

access:  public


Parameters:

string   $string_length_limit   max lenght for LaTeX string.

[ Top ]

method setMaxWidth [line 266]

void setMaxWidth( string $width_limit)

Set image width limit in pixels.



Tags:

access:  public


Parameters:

string   $width_limit   Max image width in pixels.

[ Top ]

method setPathToDvips [line 234]

void setPathToDvips( string $dvips_path)

Set path to DVIPS.



Tags:

access:  public


Parameters:

string   $dvips_path   path to DVIPS.

[ Top ]

method setPathToImageMagicConvert [line 242]

void setPathToImageMagicConvert( string $convert_path)

Set path to ImageMagick convert.



Tags:

access:  public


Parameters:

string   $convert_path   path to ImageMagick convert.

[ Top ]

method setPathToImageMagicIdentify [line 250]

void setPathToImageMagicIdentify( string $identify_path)

Set path to ImageMagick identify.



Tags:

access:  public


Parameters:

string   $identify_path   path to ImageMagick identify.

[ Top ]

method setPathToLatex [line 226]

void setPathToLatex( string $latex_path)

Set path to LATEX.



Tags:

access:  public


Parameters:

string   $latex_path   path to LATEX.

[ Top ]

method setPathToPicturesDir [line 202]

void setPathToPicturesDir( string $picture_path)

Set the absolute path to images directory.



Tags:

access:  public


Parameters:

string   $picture_path   absolute path to images directory.

[ Top ]

method setPathToPicturesDirHttpd [line 210]

void setPathToPicturesDirHttpd( string $picture_path_httpd)

Set relative path to images directory.



Tags:

access:  public


Parameters:

string   $picture_path_httpd   relative path to images directory.

[ Top ]

method setPathToTempDir [line 218]

void setPathToTempDir( string $tmp_dir)

Set path to temporary directory.



Tags:

access:  public


Parameters:

string   $tmp_dir   path to temporary directory.

[ Top ]

method wrapFormula [line 421]

minimalistic wrapFormula( string $latex_formula)

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.




Tags:

return:  LaTeX document containing the given formula
access:  private


Parameters:

string   $latex_formula   formula in LaTeX format

[ Top ]


Documentation generated on Mon, 06 Dec 2010 12:03:06 +0100 by phpDocumentor 1.4.3