public class Template extends Object implements Iterable<TemplateItem>
TemplateItem objects which represent the items of the template such as text field and table definitions.
Learn more:
| Constructor and Description |
|---|
Template(Iterable<? extends TemplateItem> items)
Initializes a new instance of the
Template class. |
Template(Iterable<? extends TemplateItem> items,
TemplateOptions options)
Initializes a new instance of the
Template class. |
| Modifier and Type | Method and Description |
|---|---|
TemplateItem |
get(int index)
Gets the template item by an index.
|
int |
getCount()
Gets the total number of template items.
|
TemplateOptions |
getOptions()
Gets the template options.
|
Iterator<TemplateItem> |
iterator() |
static Template |
load(InputStream stream)
Loads a template from a stream.
|
static Template |
load(String filePath)
Loads a template from a file.
|
void |
save(OutputStream stream)
Saves a template to a stream.
|
void |
save(String filePath)
Saves a template to a file.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitforEach, spliteratorpublic Template(Iterable<? extends TemplateItem> items)
Template class.
Usage:
// Create an array of template fields
TemplateItem[] fields = new TemplateItem[]
{
new TemplateField(new TemplateRegexPosition("From"), "From", 0),
new TemplateField(
new TemplateLinkedPosition("From", new Size(100, 10), new TemplateLinkedPositionEdges(false, false, false, true)),
"FromCompany",
0),
new TemplateField(
new TemplateLinkedPosition("FromCompany", new Size(100, 30), new TemplateLinkedPositionEdges(false, false, false, true)),
"FromAddress",
0)
};
// Create a document template
Template template = new Template(java.util.Arrays.asList(fields));
items - The collection of TemplateItem objects.public Template(Iterable<? extends TemplateItem> items, TemplateOptions options)
Template class.items - The collection of TemplateItem objects.options - The template options.public int getCount()
public TemplateItem get(int index)
index - The zero-based index of the template item.TemplateItem class.public TemplateOptions getOptions()
TemplateOptions class.public Iterator<TemplateItem> iterator()
iterator in interface Iterable<TemplateItem>public static Template load(String filePath) throws IOException
filePath - The path to the file.Template class with loaded template.IOException - File is not foundGroupDocsParserException - The file does not represent the template in a valid format.public static Template load(InputStream stream)
stream - The input stream.Template class with loaded template.GroupDocsParserException - The file does not represent the template in a valid format.public void save(String filePath) throws IOException
filePath - The path to the file.IOException - File is not foundpublic void save(OutputStream stream)
stream - The output stream.Copyright © 2026. All rights reserved.