Documents

Templater has a small API surface, 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:

  1. Grab the latest copy of Templater library
  2. 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 = "Roy", Age = 34 });
            document.Process(new [] {
                new { Name = "Marvin" },
                new { Name = "Easton" },
                new { Name = "Zavier" },
                new { Name = "Darwin" },
                new { Name = "Jair" }
            });
        }
    }
}
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")) {
                ITemplateDocument document = Configuration.factory().open(fis, "docx", fos);
                document.process(new Object() { public final String Tag = "SPARTA"; });
                document.flush();
        }
    }
}
import hr.ngs.templater.*

object Program {
  case class Student(Name: String)
  def main(args: Array[String]) {
    val document = Configuration.factory.open("Spreadsheet.xlsx")
    document.process(new { val Teacher = "Roy"; val Age = "34" })
    document.process(List(
        Student("Jack"),
        Student("Miguel"),
        Student("Harrison"),
        Student("Killian"),
        Student("Javion")
    ))
    document.flush()
  }
}

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, Stream output, string extension)
  • opens a document from the input stream
  • writes the document to the output stream
  • the extension string indicates the type of document in the stream
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

User manual

More information about how Templater works is available in the PDF documentation

User manual and readme can also be found in quick (zip) download.

Javadoc

Javadoc is available here.