Skip to content

Latest commit

 

History

History
42 lines (30 loc) · 1.54 KB

README.md

File metadata and controls

42 lines (30 loc) · 1.54 KB

templ4docx - Utility library for filling templates in docx files.

The heart of this library is apache-poi

Thanks to templ4docx you can read the entire content (as simple String) of docx file, you can find all variables, register variables pattern and you can fill docx template file by your own map of variables.

The recommended way to get started using templ4docx in your project is a dependency management system – the snippet below can be copied and pasted into your build.

<dependency>
	<groupId>pl.jsolve</groupId>
	<artifactId>templ4docx</artifactId>
	<version>2.0.2</version>
</dependency>

Direct link to jar file

Example usage

Docx docx = new Docx("template.docx");
docx.setVariablePattern(new VariablePattern("#{", "}"));
    
// preparing variables
Variables variables = new Variables();
variables.addTextVariable(new TextVariable("#{firstname}", "Lukasz"));
variables.addTextVariable(new TextVariable("#{lastname}", "Stypka"));
        
// fill template
docx.fillTemplate(variables);
        
// save filled .docx file
docx.save("lstypka.docx");

More details: