|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectides.api.latex.Renderer
public class Renderer
This class allows for rendering of LaTeX documents from within Java. It can be used also for the coversion of LaTeX documents into EPS files (only the first page is output).
The external software that has to be available is:
To use the renderer:
Renderer r = Renderer.getRenderer("path to latex", "path to ghostscript");
Image i = r.renderString("$\\alpha$");
| Field Summary | |
|---|---|
protected java.io.File |
gsPath
The path to ghostscript |
protected java.io.File |
latexPath
The path to latex+dvips |
static int |
SCREEN_RESOLUTION
The resolution to be used when rendering LaTeX files |
static int |
TIMEOUT
The time-out when calling external programs. |
| Method Summary | |
|---|---|
protected void |
fixBoundingBox(java.awt.Rectangle boundary,
java.io.File source,
java.io.File target)
Fixes the BoundingBox comment in EPS files so it reflects
the true boundary of the graphic. |
static java.awt.image.BufferedImage |
getEmptyImage()
Returns an empty image (1x1 pixel, white). |
static Renderer |
getRenderer(java.io.File latexPath,
java.io.File gsPath)
Create a new Renderer which will use the provided paths when
calling LaTeX, dvips and GhostScript. |
void |
latex2EPS(java.io.File doc,
java.io.File target)
Convert the first page of a LaTeX document into an EPS file. |
void |
latex2EPS(java.io.InputStream doc,
java.io.File target)
Convert the first page of a LaTeX document into an EPS file. |
void |
latex2EPS(java.lang.String doc,
java.io.File target)
Convert the first page of a LaTeX document into an EPS file. |
protected java.awt.image.BufferedImage |
latex2PNG(java.io.File latexFile,
int dpi)
Renders the first page of the LaTeX document contained in a file into an uncropped image. |
java.awt.image.BufferedImage |
renderDocument(java.io.File doc)
Render the first page of a LaTeX document. |
java.awt.image.BufferedImage |
renderDocument(java.io.File doc,
java.io.File f)
Render the first page of a LaTeX document into a PNG image file. |
java.awt.image.BufferedImage |
renderDocument(java.io.File doc,
java.io.OutputStream out)
Render the first page of a LaTeX document into a PNG image and output to a stream. |
java.awt.image.BufferedImage |
renderDocument(java.io.InputStream doc)
Render the first page of a LaTeX document. |
java.awt.image.BufferedImage |
renderDocument(java.io.InputStream doc,
java.io.File f)
Render the first page of a LaTeX document into a PNG image file. |
java.awt.image.BufferedImage |
renderDocument(java.io.InputStream doc,
java.io.OutputStream out)
Render the first page of a LaTeX document into a PNG image and output to a stream. |
java.awt.image.BufferedImage |
renderDocument(java.lang.String doc)
Render the first page of a LaTeX document. |
java.awt.image.BufferedImage |
renderDocument(java.lang.String doc,
java.io.File f)
Render the first page of a LaTeX document into a PNG image file. |
java.awt.image.BufferedImage |
renderDocument(java.lang.String doc,
java.io.OutputStream out)
Render the first page of a LaTeX document into a PNG image and output to a stream. |
java.awt.image.BufferedImage |
renderString(java.lang.String s)
Render a piece of LaTeX code. |
java.awt.image.BufferedImage |
renderString(java.lang.String s,
java.io.File f)
Render a piece of LaTeX code into a PNG image file. |
java.awt.image.BufferedImage |
renderString(java.lang.String s,
java.io.OutputStream out)
Render a piece of LaTeX code into a PNG image and output to a stream. |
java.awt.image.BufferedImage |
renderString(java.lang.String s,
java.lang.String header)
Render a piece of LaTeX code. |
java.awt.image.BufferedImage |
renderString(java.lang.String s,
java.lang.String header,
java.io.File f)
Render a piece of LaTeX code into a PNG image file. |
java.awt.image.BufferedImage |
renderString(java.lang.String s,
java.lang.String header,
java.io.OutputStream out)
Render a piece of LaTeX code into a PNG image and output to a stream. |
protected java.awt.image.BufferedImage |
renderTempFile(java.io.File latexFile)
Render the first page of the LaTeX document contained in a temporary file. |
protected void |
tempLatex2EPS(java.io.File latexFile,
java.io.File target)
Convert the first page of a LaTeX document contained in a temporary file into an EPS file. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final int TIMEOUT
public static final int SCREEN_RESOLUTION
protected java.io.File latexPath
protected java.io.File gsPath
| Method Detail |
|---|
public static Renderer getRenderer(java.io.File latexPath,
java.io.File gsPath)
Renderer which will use the provided paths when
calling LaTeX, dvips and GhostScript.
latexPath - the path to latex and dvips (e.g.,
"c:\texmf\miktex\bin")gsPath - the path to gswin32c (e.g., "c:\gs\gs8.14\bin")
Renderer which will use the provided paths
when calling LaTeX, dvips and GhostScript.
public java.awt.image.BufferedImage renderString(java.lang.String s,
java.io.File f)
throws java.io.IOException,
LatexRenderException
s - LaTeX code (the code goes in the body of a LaTeX document)f - file where to save image. If the file exists, its content will
be overwritten.
java.io.IOException - if there was a problem with the IO
LatexRenderException - if there was a problem while rendering the LaTeX coderenderString(String, OutputStream),
renderString(String, String, File),
renderString(String, String, OutputStream),
renderDocument(File, File),
renderDocument(File, OutputStream),
renderDocument(InputStream, File),
renderDocument(InputStream, OutputStream),
renderDocument(String, File),
renderDocument(String, OutputStream),
renderString(String),
renderString(String, String),
renderDocument(File),
renderDocument(InputStream),
renderDocument(String)
public java.awt.image.BufferedImage renderString(java.lang.String s,
java.io.OutputStream out)
throws java.io.IOException,
LatexRenderException
s - LaTeX code (the code goes in the body of a LaTeX document)out - stream where to output image. The stream will not be closed.
java.io.IOException - if there was a problem with the IO
LatexRenderException - if there was a problem while rendering the LaTeX coderenderString(String, File),
renderString(String, String, File),
renderString(String, String, OutputStream),
renderDocument(File, File),
renderDocument(File, OutputStream),
renderDocument(InputStream, File),
renderDocument(InputStream, OutputStream),
renderDocument(String, File),
renderDocument(String, OutputStream),
renderString(String),
renderString(String, String),
renderDocument(File),
renderDocument(InputStream),
renderDocument(String)
public java.awt.image.BufferedImage renderString(java.lang.String s,
java.lang.String header,
java.io.File f)
throws java.io.IOException,
LatexRenderException
s - LaTeX code (the code goes in the body of a LaTeX document)header - LaTeX environment setup, such as usepackage (the
code goes before the body of a LaTeX document)f - file where to save image. If the file exists, its content will
be overwritten.
java.io.IOException - if there was a problem with the IO
LatexRenderException - if there was a problem while rendering the LaTeX coderenderString(String, File),
renderString(String, OutputStream),
renderString(String, String, OutputStream),
renderDocument(File, File),
renderDocument(File, OutputStream),
renderDocument(InputStream, File),
renderDocument(InputStream, OutputStream),
renderDocument(String, File),
renderDocument(String, OutputStream),
renderString(String),
renderString(String, String),
renderDocument(File),
renderDocument(InputStream),
renderDocument(String)
public java.awt.image.BufferedImage renderString(java.lang.String s,
java.lang.String header,
java.io.OutputStream out)
throws java.io.IOException,
LatexRenderException
s - LaTeX code (the code goes in the body of a LaTeX document)header - LaTeX environment setup, such as usepackage (the
code goes before the body of a LaTeX document)out - stream where to output image. The stream will not be closed.
java.io.IOException - if there was a problem with the IO
LatexRenderException - if there was a problem while rendering the LaTeX coderenderString(String, File),
renderString(String, OutputStream),
renderString(String, String, File),
renderDocument(File, File),
renderDocument(File, OutputStream),
renderDocument(InputStream, File),
renderDocument(InputStream, OutputStream),
renderDocument(String, File),
renderDocument(String, OutputStream),
renderString(String),
renderString(String, String),
renderDocument(File),
renderDocument(InputStream),
renderDocument(String)
public java.awt.image.BufferedImage renderDocument(java.lang.String doc,
java.io.File f)
throws java.io.IOException,
LatexRenderException
doc - LaTeX documentf - file where to save image. If the file exists, its content will
be overwritten.
java.io.IOException - if there was a problem with the IO
LatexRenderException - if there was a problem while rendering the LaTeX coderenderString(String, File),
renderString(String, OutputStream),
renderString(String, String, File),
renderString(String, String, OutputStream),
renderDocument(File, File),
renderDocument(File, OutputStream),
renderDocument(InputStream, File),
renderDocument(InputStream, OutputStream),
renderDocument(String, OutputStream),
renderString(String),
renderString(String, String),
renderDocument(File),
renderDocument(InputStream),
renderDocument(String)
public java.awt.image.BufferedImage renderDocument(java.lang.String doc,
java.io.OutputStream out)
throws java.io.IOException,
LatexRenderException
doc - LaTeX documentout - stream where to output image. The stream will not be closed.
java.io.IOException - if there was a problem with the IO
LatexRenderException - if there was a problem while rendering the LaTeX coderenderString(String, File),
renderString(String, OutputStream),
renderString(String, String, File),
renderString(String, String, OutputStream),
renderDocument(File, File),
renderDocument(File, OutputStream),
renderDocument(InputStream, File),
renderDocument(InputStream, OutputStream),
renderDocument(String, File),
renderString(String),
renderString(String, String),
renderDocument(File),
renderDocument(InputStream),
renderDocument(String)
public java.awt.image.BufferedImage renderDocument(java.io.File doc,
java.io.File f)
throws java.io.IOException,
LatexRenderException
doc - file containing the LaTeX documentf - file where to save image. If the file exists, its content will
be overwritten.
java.io.IOException - if there was a problem with the IO
LatexRenderException - if there was a problem while rendering the LaTeX coderenderString(String, File),
renderString(String, OutputStream),
renderString(String, String, File),
renderString(String, String, OutputStream),
renderDocument(File, OutputStream),
renderDocument(InputStream, File),
renderDocument(InputStream, OutputStream),
renderDocument(String, File),
renderDocument(String, OutputStream),
renderString(String),
renderString(String, String),
renderDocument(File),
renderDocument(InputStream),
renderDocument(String)
public java.awt.image.BufferedImage renderDocument(java.io.File doc,
java.io.OutputStream out)
throws java.io.IOException,
LatexRenderException
doc - file containing the LaTeX documentout - stream where to output image. The stream will not be closed.
java.io.IOException - if there was a problem with the IO
LatexRenderException - if there was a problem while rendering the LaTeX coderenderString(String, File),
renderString(String, OutputStream),
renderString(String, String, File),
renderString(String, String, OutputStream),
renderDocument(File, File),
renderDocument(InputStream, File),
renderDocument(InputStream, OutputStream),
renderDocument(String, File),
renderDocument(String, OutputStream),
renderString(String),
renderString(String, String),
renderDocument(File),
renderDocument(InputStream),
renderDocument(String)
public java.awt.image.BufferedImage renderDocument(java.io.InputStream doc,
java.io.File f)
throws java.io.IOException,
LatexRenderException
doc - InputStream from which the LaTeX document will be read. The
stream is closed after reading the document.f - file where to save image. If the file exists, its content will
be overwritten.
java.io.IOException - if there was a problem with the IO
LatexRenderException - if there was a problem while rendering the LaTeX coderenderString(String, File),
renderString(String, OutputStream),
renderString(String, String, File),
renderString(String, String, OutputStream),
renderDocument(File, File),
renderDocument(File, OutputStream),
renderDocument(InputStream, OutputStream),
renderDocument(String, File),
renderDocument(String, OutputStream),
renderString(String),
renderString(String, String),
renderDocument(File),
renderDocument(InputStream),
renderDocument(String)
public java.awt.image.BufferedImage renderDocument(java.io.InputStream doc,
java.io.OutputStream out)
throws java.io.IOException,
LatexRenderException
doc - InputStream from which the LaTeX document will be read. The
stream is closed after reading the document.out - stream where to output image. The stream will not be closed.
java.io.IOException - if there was a problem with the IO
LatexRenderException - if there was a problem while rendering the LaTeX coderenderString(String, File),
renderString(String, OutputStream),
renderString(String, String, File),
renderString(String, String, OutputStream),
renderDocument(File, File),
renderDocument(File, OutputStream),
renderDocument(InputStream, File),
renderDocument(String, File),
renderDocument(String, OutputStream),
renderString(String),
renderString(String, String),
renderDocument(File),
renderDocument(InputStream),
renderDocument(String)
public java.awt.image.BufferedImage renderString(java.lang.String s)
throws java.io.IOException,
LatexRenderException
s - LaTeX code (the code goes in the body of a LaTeX document)
java.io.IOException - if there was a problem with the IO
LatexRenderException - if there was a problem while rendering the LaTeX coderenderString(String, File),
renderString(String, OutputStream),
renderString(String, String, File),
renderString(String, String, OutputStream),
renderDocument(File, File),
renderDocument(File, OutputStream),
renderDocument(InputStream, File),
renderDocument(InputStream, OutputStream),
renderDocument(String, File),
renderDocument(String, OutputStream),
renderString(String, String),
renderDocument(File),
renderDocument(InputStream),
renderDocument(String)
public java.awt.image.BufferedImage renderString(java.lang.String s,
java.lang.String header)
throws java.io.IOException,
LatexRenderException
s - LaTeX code (the code goes in the body of a LaTeX document)header - LaTeX environment setup, such as usepackage (the
code goes before the body of a LaTeX document)
java.io.IOException - if there was a problem with the IO
LatexRenderException - if there was a problem while rendering the LaTeX coderenderString(String, File),
renderString(String, OutputStream),
renderString(String, String, File),
renderString(String, String, OutputStream),
renderDocument(File, File),
renderDocument(File, OutputStream),
renderDocument(InputStream, File),
renderDocument(InputStream, OutputStream),
renderDocument(String, File),
renderDocument(String, OutputStream),
renderString(String),
renderDocument(File),
renderDocument(InputStream),
renderDocument(String)
public java.awt.image.BufferedImage renderDocument(java.lang.String doc)
throws java.io.IOException,
LatexRenderException
doc - LaTeX document
java.io.IOException - if there was a problem with the IO
LatexRenderException - if there was a problem while rendering the LaTeX coderenderString(String, File),
renderString(String, OutputStream),
renderString(String, String, File),
renderString(String, String, OutputStream),
renderDocument(File, File),
renderDocument(File, OutputStream),
renderDocument(InputStream, File),
renderDocument(InputStream, OutputStream),
renderDocument(String, File),
renderDocument(String, OutputStream),
renderString(String),
renderString(String, String),
renderDocument(File),
renderDocument(InputStream)
public java.awt.image.BufferedImage renderDocument(java.io.File doc)
throws java.io.IOException,
LatexRenderException
doc - file containing the LaTeX document
java.io.IOException - if there was a problem with the IO
LatexRenderException - if there was a problem while rendering the LaTeX coderenderString(String, File),
renderString(String, OutputStream),
renderString(String, String, File),
renderString(String, String, OutputStream),
renderDocument(File, File),
renderDocument(File, OutputStream),
renderDocument(InputStream, File),
renderDocument(InputStream, OutputStream),
renderDocument(String, File),
renderDocument(String, OutputStream),
renderString(String),
renderString(String, String),
renderDocument(InputStream),
renderDocument(String)
public java.awt.image.BufferedImage renderDocument(java.io.InputStream doc)
throws java.io.IOException,
LatexRenderException
doc - InputStream from which the LaTeX document will be read. The
stream is closed after reading the document.
java.io.IOException - if there was a problem with the IO
LatexRenderException - if there was a problem while rendering the LaTeX coderenderString(String, File),
renderString(String, OutputStream),
renderString(String, String, File),
renderString(String, String, OutputStream),
renderDocument(File, File),
renderDocument(File, OutputStream),
renderDocument(InputStream, File),
renderDocument(InputStream, OutputStream),
renderDocument(String, File),
renderDocument(String, OutputStream),
renderString(String),
renderString(String, String),
renderDocument(File),
renderDocument(String)public static java.awt.image.BufferedImage getEmptyImage()
protected java.awt.image.BufferedImage renderTempFile(java.io.File latexFile)
throws java.io.IOException,
LatexRenderException
latexFile - file containing the LaTeX document
java.io.IOException - if there was a problem with the IO
LatexRenderException - if there was a problem while rendering the LaTeX coderenderString(String, File),
renderString(String, OutputStream),
renderString(String, String, File),
renderString(String, String, OutputStream),
renderDocument(File, File),
renderDocument(File, OutputStream),
renderDocument(InputStream, File),
renderDocument(InputStream, OutputStream),
renderDocument(String, File),
renderDocument(String, OutputStream),
renderString(String),
renderString(String, String),
renderDocument(File),
renderDocument(InputStream),
renderDocument(String)
protected java.awt.image.BufferedImage latex2PNG(java.io.File latexFile,
int dpi)
throws java.io.IOException,
LatexRenderException
latexFile - file containing the LaTeX documentdpi - the resolution to be used for the redering (in dots per inch)
java.io.IOException - if there was a problem with the IO
LatexRenderException - if there was a problem while rendering the LaTeX coderenderTempFile(File),
tempLatex2EPS(File, File)
public void latex2EPS(java.lang.String doc,
java.io.File target)
throws java.io.IOException,
LatexRenderException
doc - LaTeX documenttarget - file where to save the EPS. If the file exists, its content
will be overwritten.
java.io.IOException - if there was a problem with the IO
LatexRenderException - if there was a problem while rendering the LaTeX codelatex2EPS(File, File),
latex2EPS(InputStream, File)
public void latex2EPS(java.io.File doc,
java.io.File target)
throws java.io.IOException,
LatexRenderException
doc - file containing the LaTeX documenttarget - file where to save the EPS. If the file exists, its content
will be overwritten.
java.io.IOException - if there was a problem with the IO
LatexRenderException - if there was a problem while rendering the LaTeX codelatex2EPS(InputStream, File),
latex2EPS(String, File)
public void latex2EPS(java.io.InputStream doc,
java.io.File target)
throws java.io.IOException,
LatexRenderException
doc - InputStream from which the LaTeX document will be read. The
stream is closed after reading the document.target - file where to save the EPS. If the file exists, its content
will be overwritten.
java.io.IOException - if there was a problem with the IO
LatexRenderException - if there was a problem while rendering the LaTeX codelatex2EPS(File, File),
latex2EPS(String, File)
protected void tempLatex2EPS(java.io.File latexFile,
java.io.File target)
throws java.io.IOException,
LatexRenderException
latexFile - file containing the LaTeX documenttarget - file where to save the EPS. If the file exists, its content
will be overwritten.
java.io.IOException - if there was a problem with the IO
LatexRenderException - if there was a problem while rendering the LaTeX codelatex2EPS(File, File),
latex2EPS(InputStream, File),
latex2EPS(String, File)
protected void fixBoundingBox(java.awt.Rectangle boundary,
java.io.File source,
java.io.File target)
throws java.io.IOException
BoundingBox comment in EPS files so it reflects
the true boundary of the graphic. Some tools (notably dvips)
may not always generate a correct BoundingBox comment.
boundary - the correct boundary of the graphicsource - EPS file which needs to be fixed. Cannot be the same as the
target file.target - file where the corrected EPS will be written. Cannot be the
same as the source file.
java.io.IOException - if there was a problem with the IOtempLatex2EPS(File, File)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||