Documents
Templater has a minimal interface API, but a large feature set. A lot of examples are explained in detail at Github examples
Change log
Templater is a mature product with over 10 years of development. Detailed list of changes is available in the change log
Installation
Templater installation is done in two simple steps:
- Grab the latest copy of Templater library →
- Include it in your project…
…or just use it through package managers such as Maven and Nuget
Code sample
using NGS.Templater; class Program { static void Main(string[] args) { using (var document = Configuration.Factory.Open("Spreadsheet.xlsx")) { document.Process(new { Teacher = "Christopher", Age = 31 }); document.Process(new [] { new { Name = "Diego" }, new { Name = "Robert" }, new { Name = "Luis" }, new { Name = "Aaron" }, new { Name = "Nathan" } }); } } }
import hr.ngs.templater.*; import java.io.*; class Program { static void main(String[] args) { try(FileInputStream fis = new FileInputStream("Template.docx"); FileOutputStream fos = new FileOutputStream("Result.docx"); TemplateDocument document = Configuration.factory().open(fis, "docx", fos)) { document.process(new Object() { public final String Tag = "an eye"; }); } } }
import hr.ngs.templater.* object Program { case class Student(Name: String) def main(args: Array[String]) { val document = Configuration.factory.open("Presentation.pptx") document.process(new { val Teacher = "Christopher"; val Age = "31" }) document.process(List( Student("Jack"), Student("Aidan"), Student("Benjamin"), Student("Nathaniel"), Student("Tristan") )) document.close() } }
Full documentation
There are only a few methods that you need to use in order to start processing your templates
- method IDocumentFactory.Open
- Use the Open method to load your template.
-
Open(string path)
- opens a document from the specified path
- Templater will recognize the appropriate document format from the file extension
-
Open(Stream input, string extension, Stream output, CancellationToken cancelToken)
- opens a document from the input stream
- the extension string indicates the type of document in the stream
- writes the document to the output stream
- cancellation token to cancel the processing
- Returns ITemplateDocument
- method ITemplateDocument.Process
- Method Process will replace tags with corresponding data.
-
Process(data)
- modifies the ITemplateDocument file or stream by replacing tags with rules according to specific data types
- Returns ITemplateDocument
Articles
- Introduction to Templater explains the basics of Templater how/why
- Conversion to PDF explains how to convert documents into PDF
- Beyond mail merge shows how Templater can be used beyond simple mail-merge
- Business intelligence friendly shows how to integrate advanced features such as OLAP cube
- No for loops and if statements explains major difference from other document automation solutions
- Processing JSON explains how to deal with JSON data type
Videos
User manual
More information about how Templater works is available in the PDF documentation
Readme can also be found in quick (zip) download.
Javadoc
Javadoc is available here.