classes-LatexRender

It appears that you are using AdBlocking software. The cost of running this website is covered by advertisements. If you like it please feel free to a small amount of money to secure the future of this website.
Tags
class

LatexRender 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

authors

Benjamin Zeiss, Nicola Asuni

Table of Contents

$convert_path  : mixed
Path to ImageMagick convert.
$dvips_path  : mixed
Path to DVIPS.
$font_size  : mixed
Font size.
$formula_density  : mixed
Formula density (used by ImageMagick)
$height_limit  : mixed
Image height limit in pixels.
$identify_path  : mixed
Path to ImageMagick identify.
$image_format  : mixed
Image format (default = PNG).
$img_prefix  : mixed
Filename prefix for chached images.
$latex_path  : mixed
Path to LATEX.
$latex_tags_blacklist  : mixed
List of unauthorized LaTeX commands.
$latexclass  : mixed
LaTeX class.
$picture_path  : mixed
Absolute path to images directory.
$picture_path_httpd  : mixed
Relative path to images directory.
$string_length_limit  : mixed
Size limit for input string.
$tmp_dir  : mixed
Path to temporary directory.
$width_limit  : mixed
Image width limit in pixels.
$errorcode  : mixed
Error code.
$img_height  : mixed
Image height.
$img_width  : mixed
Image width.
$latex_formula  : mixed
Latex formula.
$tmp_filename  : mixed
Temporary filename.
__construct()  : mixed
Class Constructor.
__destruct()  : mixed
Default destructor.
getErrorCode()  : mixed
Returns the error code
getFormulaURL()  : mixed
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.
getImageHeight()  : mixed
Returns Image height
getImageWidth()  : mixed
Returns Image width
setFilenamePrefix()  : mixed
Set filename prefix for chached images.
setFontSize()  : mixed
Set font size.
setFormulaDensity()  : mixed
Set formula density (used by ImageMagick)
setImageFormat()  : mixed
Set the image format (default = PNG).
setLatexBlackList()  : mixed
Set the list of unauthorized LaTeX commands.
setLatexClass()  : mixed
Set LaTeX class.
setMaxHeight()  : mixed
Set image height limit in pixels.
setMaxLenght()  : mixed
Set size limit for input string.
setMaxWidth()  : mixed
Set image width limit in pixels.
setPathToDvips()  : mixed
Set path to DVIPS.
setPathToImageMagicConvert()  : mixed
Set path to ImageMagick convert.
setPathToImageMagicIdentify()  : mixed
Set path to ImageMagick identify.
setPathToLatex()  : mixed
Set path to LATEX.
setPathToPicturesDir()  : mixed
Set the absolute path to images directory.
setPathToPicturesDirHttpd()  : mixed
Set relative path to images directory.
setPathToTempDir()  : mixed
Set path to temporary directory.
checkImageDimensions()  : mixed
Check the dimensions of a picture file using 'identify' of the ImageMagick tools.
cleanTemporaryDirectory()  : mixed
Removes temporary files.
getFilename()  : mixed
Wraps a minimalistic LaTeX document around the formula and returns a string containing the whole document as string.
renderLatex()  : mixed
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.
wrapFormula()  : mixed
Wraps a minimalistic LaTeX document around the formula and returns a string containing the whole document as string.

Properties

$convert_path

Path to ImageMagick convert.

protected mixed $convert_path = \K_LATEX_PATH_CONVERT
Tags
protected

$dvips_path

Path to DVIPS.

protected mixed $dvips_path = \K_LATEX_PATH_DVIPS
Tags
protected

$font_size

Font size.

protected mixed $font_size = \K_LATEX_FONT_SIZE
Tags
protected

$formula_density

Formula density (used by ImageMagick)

protected mixed $formula_density = \K_LATEX_FORMULA_DENSITY
Tags
protected

$height_limit

Image height limit in pixels.

protected mixed $height_limit = \K_LATEX_MAX_HEIGHT
Tags
protected

$identify_path

Path to ImageMagick identify.

protected mixed $identify_path = \K_LATEX_PATH_IDENTIFY
Tags
protected

$image_format

Image format (default = PNG).

protected mixed $image_format = \K_LATEX_IMG_FORMAT
Tags
protected

$img_prefix

Filename prefix for chached images.

protected mixed $img_prefix = \K_LATEX_IMG_PREFIX
Tags
protected

$latex_path

Path to LATEX.

protected mixed $latex_path = \K_LATEX_PATH_LATEX
Tags
protected

$latex_tags_blacklist

List of unauthorized LaTeX commands.

protected mixed $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')
Tags
protected

$latexclass

LaTeX class.

protected mixed $latexclass = \K_LATEX_CLASS
Tags
protected

$picture_path

Absolute path to images directory.

protected mixed $picture_path = \K_LATEX_PATH_PICTURE
Tags
protected

$picture_path_httpd

Relative path to images directory.

protected mixed $picture_path_httpd = \K_LATEX_PATH_PICTURE_HTTPD
Tags
protected

$string_length_limit

Size limit for input string.

protected mixed $string_length_limit = \K_LATEX_MAX_LENGHT
Tags
protected

$tmp_dir

Path to temporary directory.

protected mixed $tmp_dir = \K_LATEX_TMP_DIR
Tags
protected

$width_limit

Image width limit in pixels.

protected mixed $width_limit = \K_LATEX_MAX_WIDTH
Tags
protected

$latex_formula

Latex formula.

private mixed $latex_formula = ''
Tags
private

$tmp_filename

Temporary filename.

private mixed $tmp_filename = ''
Tags
private

Methods

__construct()

Class Constructor.

public __construct() : mixed
Return values
mixed

__destruct()

Default destructor.

public __destruct() : mixed
Return values
mixed

getErrorCode()

Returns the error code

public getErrorCode() : mixed
Tags
returns

int error code.

Return values
mixed

getFormulaURL()

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.

public getFormulaURL( $latex_formula) : mixed
Parameters
$latex_formula :

(string) formula in LaTeX format

Tags
returns

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

Return values
mixed

getImageHeight()

Returns Image height

public getImageHeight() : mixed
Tags
returns

image height in pixels.

Return values
mixed

getImageWidth()

Returns Image width

public getImageWidth() : mixed
Tags
returns

image width in pixels.

Return values
mixed

setFilenamePrefix()

Set filename prefix for chached images.

public setFilenamePrefix( $img_prefix) : mixed
Parameters
$img_prefix :

(string) filename prefix.

Return values
mixed

setFontSize()

Set font size.

public setFontSize( $font_size) : mixed
Parameters
$font_size :

(int) font size in points.

Return values
mixed

setFormulaDensity()

Set formula density (used by ImageMagick)

public setFormulaDensity( $formula_density) : mixed
Parameters
$formula_density :

(int) formula density.

Return values
mixed

setImageFormat()

Set the image format (default = PNG).

public setImageFormat( $image_format) : mixed
Parameters
$image_format :

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

Return values
mixed

setLatexBlackList()

Set the list of unauthorized LaTeX commands.

public setLatexBlackList( $latex_tags_blacklist) : mixed
Parameters
$latex_tags_blacklist :

(array) array of blacklisted commands.

Return values
mixed

setLatexClass()

Set LaTeX class.

public setLatexClass( $latexclass) : mixed

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

Parameters
$latexclass :

(string) LaTeX class.

Return values
mixed

setMaxHeight()

Set image height limit in pixels.

public setMaxHeight( $height_limit) : mixed
Parameters
$height_limit :

(string) Max image height in pixels.

Return values
mixed

setMaxLenght()

Set size limit for input string.

public setMaxLenght( $string_length_limit) : mixed
Parameters
$string_length_limit :

(string) max lenght for LaTeX string.

Return values
mixed

setMaxWidth()

Set image width limit in pixels.

public setMaxWidth( $width_limit) : mixed
Parameters
$width_limit :

(string) Max image width in pixels.

Return values
mixed

setPathToDvips()

Set path to DVIPS.

public setPathToDvips( $dvips_path) : mixed
Parameters
$dvips_path :

(string) path to DVIPS.

Return values
mixed

setPathToImageMagicConvert()

Set path to ImageMagick convert.

public setPathToImageMagicConvert( $convert_path) : mixed
Parameters
$convert_path :

(string) path to ImageMagick convert.

Return values
mixed

setPathToImageMagicIdentify()

Set path to ImageMagick identify.

public setPathToImageMagicIdentify( $identify_path) : mixed
Parameters
$identify_path :

(string) path to ImageMagick identify.

Return values
mixed

setPathToLatex()

Set path to LATEX.

public setPathToLatex( $latex_path) : mixed
Parameters
$latex_path :

(string) path to LATEX.

Return values
mixed

setPathToPicturesDir()

Set the absolute path to images directory.

public setPathToPicturesDir( $picture_path) : mixed
Parameters
$picture_path :

(string) absolute path to images directory.

Return values
mixed

setPathToPicturesDirHttpd()

Set relative path to images directory.

public setPathToPicturesDirHttpd( $picture_path_httpd) : mixed
Parameters
$picture_path_httpd :

(string) relative path to images directory.

Return values
mixed

setPathToTempDir()

Set path to temporary directory.

public setPathToTempDir( $tmp_dir) : mixed
Parameters
$tmp_dir :

(string) path to temporary directory.

Return values
mixed

checkImageDimensions()

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

private checkImageDimensions( $filename) : mixed
Parameters
$filename :

(string) path to a picture

Tags
returns

array containing the picture dimensions

Return values
mixed

cleanTemporaryDirectory()

Removes temporary files.

private cleanTemporaryDirectory( $current_dir,  $error_code) : mixed
Parameters
$current_dir :

(string) current directory.

$error_code :

(int) error code.

Return values
mixed

getFilename()

Wraps a minimalistic LaTeX document around the formula and returns a string containing the whole document as string.

private getFilename( $latex_formula) : mixed

Customize if you want other fonts for example.

Parameters
$latex_formula :

(string) formula in LaTeX format

Tags
returns

minimalistic LaTeX document containing the given formula

Return values
mixed

renderLatex()

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.

private renderLatex( $latex_formula) : mixed
  • 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
$latex_formula :

(string) LaTeX formula

Tags
returns

true if the picture has been successfully saved to the picture cache directory

Return values
mixed

wrapFormula()

Wraps a minimalistic LaTeX document around the formula and returns a string containing the whole document as string.

private wrapFormula( $latex_formula) : mixed

Customize if you want other fonts for example.

Parameters
$latex_formula :

(string) formula in LaTeX format

Tags
returns

minimalistic LaTeX document containing the given formula

Return values
mixed
 

© 2004-2022 – Nicola Asuni - Tecnick.com - All rights reserved.
about - disclaimer - privacy