|
Docmosis API 4.5.0 | ||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.docmosis.document.RenderRequest
This class provides a way way of building the set of parameters for a render request, including less commonly used parameters. For typical render calls, the DocumentProcessor class has methods that can be called without needing to use this class at all. The same request object can be re used making the changes required for each render.
// Simple Example
// build request
RenderRequest rr = new RenderRequest();
rr.setTemplateFile(new File("myTemplate.doc"));
rr.setOutputFile(new File("myResult.pdf"));
DataProviderBuilder dpb = new DataProviderBuilder();
//...add data here...
rr.setDataProvider(dpb.getDataProvider());
// now render
DocumentProcessor.renderDoc(rr);
// Higher Performance Example
// Assumes template ("myTemplate.doc") has already been registered
// build request
RenderRequest rr = new RenderRequest();
rr.setTemplateIdentifier(new TemplateIdentifier("myTemplate.doc"));
ConversionInstruction ci = new ConversionInstruction();
ci.setOutputFileName("myResult") ;
ci.setConversionFormats(new ConversionFormat[] {
ConversionFormat.FORMAT_PDF,
ConversionFormat.FORMAT_WORD
});
rr.setConversionInstruction(ci);
rr.setOutputFile(new File("myResult.zip"));
DataProviderBuilder dpb = new DataProviderBuilder();
//...add data here...
rr.setDataProvider(dpb.getDataProvider());
// now render
DocumentProcessor.renderDoc(rr);
DocumentProcessor
,
ConversionInstruction
Constructor Summary | |
RenderRequest()
|
Method Summary | |
ConversionInstruction |
getConversionInstruction()
Get the conversion instruction to use for this request. |
DataProvider |
getDataProvider()
Get the data provider to use |
ImageScalingDefault |
getImageScalingDefault()
Get the default image scaling if specified, otherwise the system default is returned. |
ImageSupplier |
getImageSupplier()
|
File |
getOutputFile()
Get the output file specified. |
OutputStream |
getOutputStream()
Determine where to stream the result. |
Boolean |
getPopulationErrorsFatal()
Determine if population errors are fatal |
Boolean |
getProcessStylesInText()
Determine whether text data will be parsed for html-like styling. |
boolean |
getRemoveTemplateAfterUse()
Determine if "remove template after use" is specified. |
File |
getTemplateFile()
Get the template file specified |
TemplateIdentifier |
getTemplateIdentifier()
Get the specified template identifier indicating the template to use. |
TemplateStore |
getTemplateStore()
Get the template store. |
NamedInputStream |
getTemplateStream()
Get the template stream setting. |
RenderRequest |
setConversionInstruction(ConversionInstruction conversionInstruction)
Set the conversion instruction to use for this request. |
RenderRequest |
setDataProvider(DataProvider dataProvider)
Set the data to use for the render |
RenderRequest |
setImageScalingDefault(ImageScalingDefault imageScalingDefault)
Set the default image scaling method (eg fit or stretch) to use when inserting images into the template. |
RenderRequest |
setImageSupplier(ImageSupplier imageSupplier)
Set the image supplier to use for sourcing images for population. |
RenderRequest |
setOutputFile(File outputFile)
Set the file to write the result to. |
RenderRequest |
setOutputStream(OutputStream streamTo)
Specify where to stream the result. |
RenderRequest |
setPopulationErrorsFatal(Boolean populationErrorsFatal)
Specify whether population errors should be fatal. |
RenderRequest |
setProcessStylesInText(Boolean processTextStyles)
Specify whether text data should be parsed for HTML-like data. |
RenderRequest |
setRemoveTemplateAfterUse(boolean remove)
Specify whether or not the template should be removed from the TemplateStore (the local cache) after being used for rendering. |
RenderRequest |
setTemplateFile(File templateFile)
Specify the template to use by a direct reference to the source template file. |
RenderRequest |
setTemplateIdentifier(TemplateIdentifier templateIdentifier)
Set the template to use. |
RenderRequest |
setTemplateStore(TemplateStore templateStore)
Set the template store to use. |
RenderRequest |
setTemplateStream(InputStream templateStream,
String name,
boolean removeAfterUse)
Specify that the template is to be obtained by reading the given InputStream. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public RenderRequest()
Method Detail |
public ImageSupplier getImageSupplier()
public RenderRequest setImageSupplier(ImageSupplier imageSupplier)
imageSupplier
-
ImageSupplier
public ImageScalingDefault getImageScalingDefault()
public RenderRequest setImageScalingDefault(ImageScalingDefault imageScalingDefault)
imageScalingDefault
- the setting to use by default
ImageScalingDefault
public TemplateStore getTemplateStore()
public RenderRequest setTemplateStore(TemplateStore templateStore)
templateStore
- the store to use for this requestpublic ConversionInstruction getConversionInstruction()
public RenderRequest setConversionInstruction(ConversionInstruction conversionInstruction)
conversionInstruction
- the instruction
ConversionInstruction
public TemplateIdentifier getTemplateIdentifier()
public RenderRequest setTemplateIdentifier(TemplateIdentifier templateIdentifier)
// template without any context
TemplateIdentifier tid = new TemplateIdentifier("myTemplate.doc");
// template with a context
TemplateIdentifier tid = new TemplateIdentifier("myTemplate.doc", "/projects/projectA");
or
TemplateIdentifier tid = TemplateIdentifier.fromPath("/projects/projectA/myTemplate.doc");
templateIdentifier
- the template
setTemplateFile(File)
,
setTemplateStream(InputStream, String, boolean)
public RenderRequest setTemplateFile(File templateFile)
templateFile
- setTemplateIdentifier(TemplateIdentifier)
,
setTemplateStream(InputStream, String, boolean)
public RenderRequest setTemplateStream(InputStream templateStream, String name, boolean removeAfterUse)
1. The name may be null, in which case a temporary unique name will be used 2. The name may include a "context" path, for example ("temporary/template1.doc") or ("dynamic/templates/template1433"). 3. If the name correlates with a template that already exists, that template will be overwritten.This method does not close the given InputStream, it is expected the caller will close it. Calling this method overrides any previous calls to setTemplateIdentifier(), setTemplateFile() and setRemoveTemplateAfterUse().
templateStream
- the source of the templatename
- the name of the template to use. May be null (in which case removeAfterUse
will be assumed to be true) and may contain a "context" path (see above description)removeAfterUse
- if set to true, the template will be removed from the
TemplateStore after the render is complete.setTemplateIdentifier(TemplateIdentifier)
,
setTemplateFile(File)
,
setRemoveTemplateAfterUse(boolean)
public NamedInputStream getTemplateStream()
public RenderRequest setRemoveTemplateAfterUse(boolean remove)
remove
- the flag indicating cache removal
public boolean getRemoveTemplateAfterUse()
public File getTemplateFile()
public DataProvider getDataProvider()
public RenderRequest setDataProvider(DataProvider dataProvider)
dataProvider
- the data
public Boolean getPopulationErrorsFatal()
public RenderRequest setPopulationErrorsFatal(Boolean populationErrorsFatal)
populationErrorsFatal
- if null the system default behaviour will take effect
public Boolean getProcessStylesInText()
public RenderRequest setProcessStylesInText(Boolean processTextStyles)
This is <b>bold</b> text.
processTextStyles
- if null, the system default behaviour will take effect
public OutputStream getOutputStream()
public RenderRequest setOutputStream(OutputStream streamTo)
streamTo
- setOutputFile(File)
,
setConversionInstruction(ConversionInstruction)
public File getOutputFile()
public RenderRequest setOutputFile(File outputFile)
File out = new File("output/result.pdf");
renderRequest.setOutputFile(out);
specifies both the output format (PDF - inferred from the file name) and
where the result should be written.
Calling this method overrides any previous call to setStreamTo(). If
setConversionInstruction has been called() any settings it holds for
conversion formats and output name will override the format and name
of this method.
outputFile
-
setOutputStream(OutputStream)
,
setConversionInstruction(ConversionInstruction)
|
Docmosis API 4.5.0 | ||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |