com-tecnick-latex
[ class tree: com-tecnick-latex ] [ index: com-tecnick-latex ] [ 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):

  • Nicola Asuni

Variables

Methods



Class Details

[line 70]
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:  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 108]



Tags:

var:  to ImageMagick convert.
access:  protected

Type:   Path


[ Top ]

$dvips_path =  K_LATEX_PATH_DVIPS

[line 102]



Tags:

var:  to DVIPS.
access:  protected

Type:   Path


[ Top ]

$errorcode =  0

[line 176]



Tags:

var:  code.
access:  private

Type:   Error


[ Top ]

$font_size =  K_LATEX_FONT_SIZE

[line 144]



Tags:

var:  size.
access:  protected

Type:   Font


[ Top ]

$formula_density =  K_LATEX_FORMULA_DENSITY

[line 120]



Tags:

var:  density (used by ImageMagick)
access:  protected

Type:   Formula


[ Top ]

$height_limit =  K_LATEX_MAX_HEIGHT

[line 132]



Tags:

var:  height limit in pixels.
access:  protected

Type:   Image


[ Top ]

$identify_path =  K_LATEX_PATH_IDENTIFY

[line 114]



Tags:

var:  to ImageMagick identify.
access:  protected

Type:   Path


[ Top ]

$image_format =  K_LATEX_IMG_FORMAT

[line 162]



Tags:

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

Type:   Image


[ Top ]

$img_height =  0

[line 200]



Tags:

var:  height.
access:  private

Type:   Image


[ Top ]

$img_prefix =  K_LATEX_IMG_PREFIX

[line 156]



Tags:

var:  prefix for chached images.
access:  protected

Type:   Filename


[ Top ]

$img_width =  0

[line 194]



Tags:

var:  width.
access:  private

Type:   Image


[ Top ]

$latexclass =  K_LATEX_CLASS

[line 150]



Tags:

var:  class.
access:  protected

Type:   LaTeX


[ Top ]

$latex_formula =  ''

[line 188]



Tags:

var:  formula.
access:  private

Type:   Latex


[ Top ]

$latex_path =  K_LATEX_PATH_LATEX

[line 96]



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 168]



Tags:

var:  of unauthorized LaTeX commands.
access:  protected

Type:   list


[ Top ]

$picture_path =  K_LATEX_PATH_PICTURE

[line 78]



Tags:

var:  path to images directory.
access:  protected

Type:   Absolute


[ Top ]

$picture_path_httpd =  K_LATEX_PATH_PICTURE_HTTPD

[line 84]



Tags:

var:  path to images directory.
access:  protected

Type:   relative


[ Top ]

$string_length_limit =  K_LATEX_MAX_LENGHT

[line 138]



Tags:

var:  limit for input string.
access:  protected

Type:   Size


[ Top ]

$tmp_dir =  K_LATEX_TMP_DIR

[line 90]



Tags:

var:  to temporary directory.
access:  protected

Type:   Path


[ Top ]

$tmp_filename =  ''

[line 182]



Tags:

var:  filename.
access:  private

Type:   Temporary


[ Top ]

$width_limit =  K_LATEX_MAX_WIDTH

[line 126]



Tags:

var:  width limit in pixels.
access:  protected

Type:   Image


[ Top ]



Class Methods


constructor __construct [line 209]

LatexRender __construct( )

Class Constructor.



Tags:

access:  public


[ Top ]

destructor __destruct [line 216]

void __destruct( )

Default destructor.



Tags:

access:  public


[ Top ]

method checkImageDimensions [line 485]

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 466]

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 418]

int getErrorCode( )

Returns the error code



Tags:

return:  error code.
access:  public


[ Top ]

method getFilename [line 435]

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 364]

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 410]

image getImageHeight( )

Returns Image height



Tags:

return:  height in pixels.
access:  public


[ Top ]

method getImageWidth [line 402]

image getImageWidth( )

Returns Image width



Tags:

return:  width in pixels.
access:  public


[ Top ]

method renderLatex [line 516]

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 333]

void setFilenamePrefix( string $img_prefix)

Set filename prefix for chached images.



Tags:

access:  public


Parameters:

string   $img_prefix   filename prefix.

[ Top ]

method setFontSize [line 316]

void setFontSize( int $font_size)

Set font size.



Tags:

access:  public


Parameters:

int   $font_size   font size in points.

[ Top ]

method setFormulaDensity [line 284]

void setFormulaDensity( int $formula_density)

Set formula density (used by ImageMagick)



Tags:

access:  public


Parameters:

int   $formula_density   formula density.

[ Top ]

method setImageFormat [line 341]

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 349]

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 325]

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 300]

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 308]

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 292]

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 260]

void setPathToDvips( string $dvips_path)

Set path to DVIPS.



Tags:

access:  public


Parameters:

string   $dvips_path   path to DVIPS.

[ Top ]

method setPathToImageMagicConvert [line 268]

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 276]

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 252]

void setPathToLatex( string $latex_path)

Set path to LATEX.



Tags:

access:  public


Parameters:

string   $latex_path   path to LATEX.

[ Top ]

method setPathToPicturesDir [line 228]

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 236]

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 244]

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 448]

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 Fri, 05 Dec 2008 16:03:56 +0100 by phpDocumentor 1.4.1