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:

  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 = "Jose", Age = 30 });
            document.Process(new [] {
                new { Name = "Max" },
                new { Name = "Liam" },
                new { Name = "Josiah" },
                new { Name = "John" },
                new { Name = "Isaiah" }
            });
        }
    }
}
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 = "a zinc"; });
        }
    }
}
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 = "Jose"; val Age = "30" })
    document.process(List(
        Student("Jesus"),
        Student("Gabriel"),
        Student("Adam"),
        Student("Dominic"),
        Student("Xavier")
    ))
    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

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.