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 = "Angel", Age = 49 });
            document.Process(new [] {
                new { Name = "Elijah" },
                new { Name = "Hunter" },
                new { Name = "Bryan" },
                new { Name = "Tyler" },
                new { Name = "Nicholas" }
            });
        }
    }
}
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 chair"; });
        }
    }
}
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 = "Angel"; val Age = "49" })
    document.process(List(
        Student("Brandon"),
        Student("Isaac"),
        Student("Hayden"),
        Student("Parker"),
        Student("Kevin")
    ))
    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.