Please give a brief summary of your issue:
Create a template from a docx-template fetched from our database
We are investigating how to use PDFTron to use docx-templates and JSON data as input. This is straightforward documented her,
But we shall not read in the docx-template from the filesystem, but from our database. I get my template like this,
var template = templateService.getTemplate(TemplateType.VERKSTED_RAPPORT);
now I have an object holding my docx-template. I have a method that gives me the content as a byte array.
PDFTtron use this,
// Create a TemplateDocument object from an input office file.
TemplateDocument templateDoc = Convert.createOfficeTemplate(input, null);
input is either a string pointing to an file in the filesystem or a Filter. My problem is how I can use the Filter class properly as an input_stream filled with my template or if there is another approach?
//My template from the database
var template = templateService.getTemplate(TemplateType.VERKSTED_RAPPORT, "PLA");
MemoryFilter memoryFilter = new MemoryFilter(template.getFileContent().length, false); // false = sink
// helper filter to allow us to write to buffer
FilterWriter writer = new FilterWriter(memoryFilter);
writer.writeBuffer(template.getFileContent());
writer.flush();
memoryFilter.setAsInputFilter();
TemplateDocument templateDoc = Convert.createOfficeTemplate(memoryFilter, null);