public class BrowserViewer extends java.lang.Object implements LayoutedPagesConsumer, java.io.Serializable
String reportsRoot="/var/www/reports"; // this directory is publicly visible as "http://www.4js.com/reports". String viewerDirectory=reportsRoot+"/viewer"; // not used. "viewer.html" needs to be in this directory. String documentsDirectory=reportsRoot+"/documents"; String fontsDirectory=reportsRoot+"/fonts"; String uuid=java.uti.UUD.randomUUID().toString(); // yields something like "57e96d13-05bc-408f-8ca1-9e6a2eab374e" BrowserViewer.setDocumentDirectory(documentsDirectory+"/"+uuid) BrowserViewer.setFontDirectory(fontDirectory); String url="http://www.4js.com/reports/viewer/viewer.html?reportId="+uuid; //For a J2SE application we could launch the browser as follows java.awt.Desktop().getDesktop().browse(new java.net.URI(url));
FontInfo
can be used to obtain a full list of supported fonts.
Since web font files can be large the engine supports creating them in a separate directory that is shared among several
documents (see {lin #setFontDirectory(String)}. This allows both the web server and the browser to cache the fonts across documents.
Modifier and Type | Class and Description |
---|---|
static class |
BrowserViewer.FontFileFormat |
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
legalCopyright |
Constructor and Description |
---|
BrowserViewer()
Creates a BrowserViewer object.
|
Modifier and Type | Method and Description |
---|---|
void |
setDocumentDirectory(java.lang.String directory)
Specifies the directory in which the document will be generated
Please note that the directory should be empty or non existent in which case it will be
created during report generation.
|
void |
setDocumentDirectoryURL(java.net.URL directoryURL)
Specifies the URL to the directory by which the generated document will be visible from the web server.
|
void |
setFontDirectory(java.lang.String directory)
Specifies the directory in which web fonts will be placed.
|
void |
setFontDirectoryURL(java.net.URL directoryURL)
Specifies the URL to the directory in which the web fonts will be visible from the web server.
|
void |
setFontFileFormat(BrowserViewer.FontFileFormat format)
Sets the web font file format
format
argument. |
public static final java.lang.String legalCopyright
public void setDocumentDirectory(java.lang.String directory)
directory
- a String specifying the directory in which the document is created.public void setDocumentDirectoryURL(java.net.URL directoryURL)
directoryURL
- of the document directory.public void setFontDirectory(java.lang.String directory)
directory
- a String specifying the directory in which web fonts will be placed.public void setFontDirectoryURL(java.net.URL directoryURL)
directoryURL
- of the fonts directory.public void setFontFileFormat(BrowserViewer.FontFileFormat format)
format
argument.
The default value is woff
.format
- one of the following values: